1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
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<State & Action>((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 })
}
}));
|