import { type FC } from 'react'
import type { FormikProps } from 'formik'
import SwitchComponent from '@/components/Switch'
import CategorySelector from './CategorySelector'
import FoodSelector from './FoodSelector'
import type { CreateCouponType } from '../types/Types'

interface Category {
    id: string
    title: string
}

interface Food {
    id: string
    title: string
}

interface CouponSidebarProps {
    formik: FormikProps<CreateCouponType>
    categories: Category[]
    foods: Food[]
}

const CouponSidebar: FC<CouponSidebarProps> = ({ formik, categories, foods }) => {
    return (
        <div className='bg-white rounded-4xl p-4 sm:p-6'>
            <div className='mb-6'>
                <div className='text-sm mb-3'>وضعیت تخفیف</div>
                <SwitchComponent
                    active={formik.values.isActive}
                    onChange={(value) => formik.setFieldValue('isActive', value)}
                    label={formik.values.isActive ? 'فعال' : 'غیرفعال'}
                />
            </div>

            <CategorySelector formik={formik} categories={categories} />
            <FoodSelector formik={formik} foods={foods} />
        </div>
    )
}

export default CouponSidebar

