import { ApiProperty } from "@nestjs/swagger";
import { Transform } from "class-transformer";
import { IsArray, IsBoolean, IsEmpty,IsEmail,IsEnum, IsNumber, IsOptional, IsString, isEnum, isString } from "class-validator";

export enum device_type {
    WEB = 'WEB',
    ANDROID = 'ANDROID',
    IOS = 'IOS'
}
export enum media_type {
    IMAGE = "IMAGE",
    VIDEO = "VIDEO"
}

class MediaUrlObject {

    @ApiProperty({ enum: media_type, default: "IMAGE", required:false})
    @IsEnum(media_type)
    @IsString()
    type: media_type;

    @ApiProperty({ description: "URL of the media", example: "media_url.png", required: false })
    @IsString()
    url: string;

    @ApiProperty({ description: "Pass only in case of video", example: "media_url.png", required: false })
    @IsString()
    thumbnail_url?: string;
}

export class verifyPhone {

    @ApiProperty({ required: false })
    @IsString()
    token: string

    @ApiProperty({ required: false })
    @IsNumber()
    otp: number

    @ApiProperty({ required: false })
    @IsString()
    fcm_token: string;

    @IsOptional()
    @ApiProperty({ required: false, enum: Object.values(device_type), default: device_type.WEB })
    @IsString()
    device_type: string;

}


export class editUserProfile {

    @IsOptional()
    @ApiProperty({ required: false })
    @IsString()
    name: string;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsString()
    bio: string;

    // @IsOptional()
    // @ApiProperty({ required: false })
    // @IsString()
    // email: string;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsString()
    profile_pic: string;

    @IsOptional()
    @IsString()
    @ApiProperty({ required: false })
    gender: string;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsNumber()
    dob: number;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsArray()
    interest: string[];

    @IsOptional()
    @ApiProperty({ required: false })
    @IsNumber()
    chat_price: number;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsNumber()
    video_call_price: number;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsBoolean()
    last_seen_and_online: boolean;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsBoolean()
    read_receipts: boolean;

    @IsOptional()
    @ApiProperty({ required: false })
    @IsBoolean()
    app_lock: boolean;
}


export class  add_store {

    @ApiProperty({ type: 'string', required: false, default: "John Doe" })
    @IsString()
    store_name: string;

    @ApiProperty({ type: 'string', required: false, default: "john_doe" })
    @IsString()
    address: string;

    @ApiProperty({ type: 'string', required: false, default: "john_doe@yopmail.com" })
    // @IsEmail()
    country: string;

    @ApiProperty({ type: 'string', format: 'password', required: true, default: "qwerty" })
    @IsString()
    city: string;

    @ApiProperty({ type: 'string', format: 'password', required: true, default: "qwerty" })
    @IsString()
    street_address: string;

    @ApiProperty({ type: 'string', format: 'password', required: true, default: "qwerty" })
    @IsString()
    description: string;

    @ApiProperty({ required: false })
    @IsNumber()
    postal_code: number

}

export class pagination_limit {

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    pagination: number;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    limit: number;


}



export class list_category{

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    pagination: number;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    limit: number;

    @ApiProperty({ required: false })
    @IsString()
    @IsOptional()
    search: string;

}





// {,,,,,,,,,,,highlights,clone_product_id,language} 

export class  add_product {
    @ApiProperty({ type: 'string', required: false, default: "" })
    @IsString()
    store_id: string;

    @ApiProperty({ type: 'string', required: true, default: "" })
    @IsString()
    category_id: string;

    @ApiProperty({ type: 'string', required: false, default: "" })
    @IsString()
    sub_category_id: string;

    @ApiProperty({ type: 'string', required: false, default: "John Doe" })
    @IsString()
    name: string;

    @ApiProperty({ type: 'string', required: false, default: "john_doe" })
    @IsString()
    description: string;

    @ApiProperty({ type: 'string', required: false})
    // @IsEmail()
    product_type: string;

    @ApiProperty({
        type: [MediaUrlObject],
        default: [{
            type: "IMAGE",
            url: "media_url.png",
            thumbnail_url: "Pass only in case of video"
        }],
        required: true
    })
    @IsArray()
    images: MediaUrlObject[];
  
    // @ApiProperty({ type: 'string', required: true, default: "qwerty" })
    // @IsString()
    // images: string;

    @ApiProperty({
        type: 'array',
        items: {
            type: 'object',
            properties: {
             store_id: {
                    type: 'string',
                },
                quantity : {
                    type: 'number',
                }
            },
        },
    })
    store_details :Array<{store_id:string, quantity:string }>;

    // @ApiProperty({
    //     type: 'array',
    //     items: {
    //         type: 'object',
    //         properties: {
    //             content: {
    //                 type: 'string',
    //             }
    //         },
    //     },
    // })
    // services :Array<{content:string}>;

    @ApiProperty({ required: true })
    @IsNumber()
    quantity: number

    @ApiProperty({ required: true })
    @IsNumber()
    price: number


    @ApiProperty({ required: false })
    @IsNumber()
    sell_price: number

    @ApiProperty({ required: false })
    @IsNumber()
    tax_percentage: number

    @ApiProperty({ required: false })
    @IsNumber()
    discount_percantage: number

}

export class  edit_product {

    @ApiProperty({ type: 'string', required: true, default: "" })
    @IsString()
    product_id: string;

    @ApiProperty({ type: 'string', required: false, default: "" })
    @IsString()
    store_id: string;

    @ApiProperty({ type: 'string', required: false, default: "" })
    @IsString()
    category_id: string;

    @ApiProperty({ type: 'string', required: false, default: "" })
    @IsString()
    sub_category_id: string;

    @ApiProperty({ type: 'string', required: false, default: "John Doe" })
    @IsString()
    name: string;

    @ApiProperty({ type: 'string', required: false, default: "john_doe" })
    @IsString()
    description: string;

    @ApiProperty({ type: 'string', required: false})
    // @IsEmail()
    product_type: string;

    @ApiProperty({
        type: [MediaUrlObject],
        default: [{
            type: "IMAGE",
            url: "media_url.png",
            thumbnail_url: "Pass only in case of video"
        }],
        required: false
    })
    @IsArray()
    images: MediaUrlObject[];
  
    // @ApiProperty({ type: 'string', required: true, default: "qwerty" })
    // @IsString()
    // images: string;

    // @ApiProperty({
    //     type: 'array',
    //     items: {
    //         type: 'object',
    //         properties: {
    //             key: {
    //                 type: 'string',
    //             },
    //             value: {
    //                 type: 'string',
    //             }
    //         },
    //     },
    // })
    // product_details :Array<{key:string, value:string }>;

    // @ApiProperty({
    //     type: 'array',
    //     items: {
    //         type: 'object',
    //         properties: {
    //             content: {
    //                 type: 'string',
    //             }
    //         },
    //     },
    // })
    // services :Array<{content:string}>;

    @ApiProperty({ required: false })
    @IsNumber()
    quantity: number

    @ApiProperty({ required: false })
    @IsNumber()
    price: number


    @ApiProperty({ required: false })
    @IsNumber()
    sell_price: number

    @ApiProperty({ required: false })
    @IsNumber()
    tax_percentage: number

    @ApiProperty({ required: false })
    @IsNumber()
    discount_percantage: number

}


export class product_list {
    @ApiProperty({ type: String, description: "search by title and caption", required: false })
    @IsString()
    @IsOptional()
    search?: string;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    pagination: number;

    @Transform(({ value }) => parseInt(value))
    @ApiProperty({ required: false })
    @IsNumber()
    @IsOptional()
    limit: number;


}


// }