export {};

declare global {
    type ApiPaginated<T> = {
        count: number;
        next: string | null;
        previous: string | null;
        results: T[];
    };

    type LogType = {
        title: string;
        status?: "success" | "error" | "info" | "warning";
        message?: string;
        details?: any;
    };

    type AxiosLogType = {
        url: string;
        method: string;
        status: number;
        code: string;
        requestHeaders: Record<any, any>;
        responseHeaders?: Record<any, any>;
        response?: any;
        payload?: Record<any, any>;
        params?: Record<any, any>;
        date: string;
    };

    type Chat = {
        id: number;
        sender: "ai" | "user";
        content: string;
    };

    type Account = {
        profile_photo: string | null;
        first_name: string;
        last_name: string;
        phone: string;
        gender: string | undefined;
        email: string;
        birth_date: string;
    };

    type ProductVariantAttribute = {
        id: number;
        attribute_type: {
            id: number;
            name: string;
        };
        value: string;
    };

    type ProductImage = {
        id: number;
        name: string;
        image: string;
    };

    type ProductDetailItem = {
        id: number;
        title: string;
        texts: string[];
    };

    type ProductDetail = {
        id: number;
        details: ProductDetailItem[];
        detail_category: number;
    };

    type ProductInPackItem = {
        id: number;
        item_title: string;
        cover: string;
    };

    type ProductVariant = {
        id: number;
        product_attributes: ProductVariantAttribute[];
        price: string;
        price_after_discount: string;
        in_pack_items: ProductInPackItem[];
        details: ProductDetail[];
        images: ProductImage[];
        in_stock: number;
        discount: number;
        color: string;
        video: string | null;
        cart_quantity: number;
        special_discount_amount: string | null;
        special_discount_link: string;
    };

    type Product = {
        id: number;
        variants: ProductVariant[];
        related_products: ProductListItem[];
        name: string;
        description: string;
        rating: number;
        slug: string;
        meta_description: string | null;
        meta_keywords: string | null;
        meta_rating: number;
        category: SubCategory;
        colors: string[];
        added_to_favorites: boolean;
        main_image: string;
        best_deal_price_before_discount: string;
        best_deal_price_after_discount: string;
        best_deal_discount: number;
        customer_pickup_title: null | string;
        customer_pickup_description: null | string;
    };

    type ProductListItem = Pick<
        Product,
        | "id"
        | "name"
        | "rating"
        | "slug"
        | "category"
        | "colors"
        | "main_image"
        | "best_deal_discount"
        | "best_deal_price_after_discount"
        | "best_deal_price_before_discount"
    >;

    type Article = {
        id: number;
        title: string;
        slug: string;
        content: string;
        summery: string;
        created_at: string;
        updated_at: string;
        cover_image: string;
        views: number;
        meta_description: string;
        meta_keywords: string;
        author: {
            full_name: string;
            profile_photo: string;
        };
        category: SubCategory;
    };

    type UserComment = {
        id: number;
        content: string;
        timestamp: string;
        show: boolean;
        product: number;
        user: number;
    };

    type Category = {
        id: number;
        name: string;
        slug: string;
        icon: string;
        product_count: number;
        image: string | null;
        video: string | null;
        subcategorys: SubCategory[];
    };

    type SubCategory = {
        id: number;
        name: string;
        slug: string;
        icon: string;
        image: string;
        product_count: number;
        parent: string;
        subcategorys: SubCategory[];
    };

    type Address = {
        id: number;
        province: string | undefined;
        city: string | undefined;
        postal_code: string | undefined;
        address: string | undefined;
        phone: string | undefined;
        name: string | undefined;
        for_me: "خیر" | "بله" | boolean;
        is_main: boolean;
    };

    type DeliveryMethod = {
        type: string;
        date: string;
        hour: string;
        price: string;
    };

    type DropdownItem = {
        title: string;
        icon: string;
        itemClass?: string;
        iconClass?: string;
        onClick?: () => void;
    };

    type Order = {
        id: number;
        count: number;
        images: string[];
        status: "ADMIN_PENDING" | "PENDING" | "POSTED" | "RECEIVED" | "CANCELED" | "REFUND";
        verbose_status: string;
        is_paid: boolean;
        created_at: string;
        final_price: string;
        order_id: number;
        special_discount_total?: string;
    };

    type DiscountCode = {
        code: string;
        percent: number;
        amount: string;
    };

    type SpecialDiscountCode = {
        code: string;
        user: number;
    };

    type CartItem = {
        id: number;
        product: {
            id: number;
            title: string;
            product_attributes: {
                id: number;
                attribute_type: {
                    id: number;
                    name: string;
                };
                value: string;
            }[];
            category: string;
            in_stock: number;
            price: string;
            discount: number;
            color: string;
            image: string;
            discount_amount: string;
            final_price: string;
        };
        discount: number;
        discount_amount: string;
        special_discount_amount: string;
        price: string;
        final_price: string;
        quantity: number;
    };

    type Cart = {
        discount_code: DiscountCode;
        special_discount_code?: SpecialDiscountCode;
        items: CartItem[];
        cart_total: string;
        items_discount_amount: string;
        special_discount_total: string;
        tax_amount: string;
        final_price: string;
        address: Address;
    };

    type ServerFile = {
        id: number;
        file_link: string;
        date: string;
        size: number;
        name: string;
    };

    type TicketMessage = {
        id: number;
        is_user: boolean;
        content: string;
        created_at: string;
        attachments: ServerFile[];
    };

    type Ticket = {
        id: number;
        messages: TicketMessage[];
        subject: string;
        ticket_category: string;
        status: "در انتظار پاسخ" | "پاسخ داده شده" | "بسته شده";
        created_at: string;
        updated_at: string;
        order: Order;
    };

    type PaymentGateway = {
        id: number;
        picture: string;
        title: string;
        type: "ZARINPAL" | "SEP" | "MELLAT" | "IDPAY" | "ZIBAL" | "BAHAMTA" | "BMI";
    };

    type Transaction = {
        detail: string;
        bank_result?: {
            status: "succeeded" | "canceled" | "pending";
            bank_type: string;
            tracking_code: string;
            amount: string | null;
            created_at: string;
            response_result: string | null;
            reference_number: string | null;
            status_detail: string | null;
        };
    };

    type Notification = {
        title: string;
        content: string;
        created_at: string;
        notif_type: "NEWS" | "USER_NOTIF";
        is_read?: string;
    };
}
