import { create } from 'zustand'; import { IProductVariantDetail } from '~/types/productVariant'; type State = { activeVariantId: number | null; activePrice: IProductVariantDetail['price'] | null; quantityInput: string; askAdminUrl: string; isApproval : boolean; selectedVariant : any; sla : any; }; type Action = { setActive: (variant: IProductVariantDetail) => void; setQuantityInput: (value: string) => void; setAskAdminUrl: (url: string) => void; setIsApproval : (value : boolean) => void; setSelectedVariant : (value : any) => void; setSla : (value : any) => void; }; export const useProductDetail = create((set, get) => ({ activeVariantId: null, activePrice: null, quantityInput: '1', askAdminUrl: '', isApproval : false, selectedVariant: null, sla : null, setActive: (variant) => { set({ activeVariantId: variant?.id, activePrice: variant?.price }); }, setQuantityInput: (value: string) => { set({ quantityInput: value }); }, setAskAdminUrl: (url: string) => { set({ askAdminUrl: url }); }, setIsApproval : (value : boolean) => { set({ isApproval : value }) }, setSelectedVariant : (value : any) => { set({ selectedVariant : value }) }, setSla : (value : any ) => { set({ sla : value }) } }));