file name and location updayed for better be
This commit is contained in:
22
zustand/useCategory.ts
Normal file
22
zustand/useCategory.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { CategoryType } from "@/lib/types";
|
||||
import { create } from "zustand";
|
||||
|
||||
interface CategoryZustandType {
|
||||
category: CategoryType;
|
||||
setCategory: (category: CategoryType) => void;
|
||||
clearCatalog: () => void;
|
||||
}
|
||||
|
||||
const demoCategory: CategoryType = {
|
||||
id: 0,
|
||||
name: "",
|
||||
description: "",
|
||||
image: "",
|
||||
have_sub_category: false,
|
||||
};
|
||||
|
||||
export const useCategory = create<CategoryZustandType>((set) => ({
|
||||
category: demoCategory,
|
||||
setCategory: (data) => set({ category: data }),
|
||||
clearCatalog: () => set({ category: demoCategory }),
|
||||
}));
|
||||
22
zustand/useProceModalStore.ts
Normal file
22
zustand/useProceModalStore.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface Product {
|
||||
id: number;
|
||||
name: string;
|
||||
image: string;
|
||||
inStock: boolean;
|
||||
}
|
||||
|
||||
interface PriceModalStore {
|
||||
isOpen: boolean;
|
||||
product: Product | null;
|
||||
openModal: (product: Product) => void;
|
||||
closeModal: () => void;
|
||||
}
|
||||
|
||||
export const usePriceModalStore = create<PriceModalStore>((set) => ({
|
||||
isOpen: false,
|
||||
product: null,
|
||||
openModal: (product) => set({ isOpen: true, product }),
|
||||
closeModal: () => set({ isOpen: false, product: null }),
|
||||
}));
|
||||
18
zustand/useProduct.ts
Normal file
18
zustand/useProduct.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ProductsPageTypes } from "@/lib/types";
|
||||
import { create } from "zustand";
|
||||
|
||||
const demoProductPageData = {
|
||||
id: 0,
|
||||
name: "",
|
||||
image: "",
|
||||
};
|
||||
|
||||
interface ProductPageZustanType {
|
||||
product: ProductsPageTypes;
|
||||
setProducts: (data: ProductsPageTypes) => void;
|
||||
}
|
||||
|
||||
export const useProductPageInfo = create<ProductPageZustanType>((set) => ({
|
||||
product: demoProductPageData,
|
||||
setProducts: (data) => set({ product: data }),
|
||||
}));
|
||||
14
zustand/useService.ts
Normal file
14
zustand/useService.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
interface ServiceIdZustandType {
|
||||
serviceId: number;
|
||||
setServiceId: (serviceId: number) => void;
|
||||
}
|
||||
|
||||
export const useServiceDetail = create<ServiceIdZustandType>((set) => ({
|
||||
serviceId: 0,
|
||||
setServiceId: (data: number) =>
|
||||
set({
|
||||
serviceId: data,
|
||||
}),
|
||||
}));
|
||||
20
zustand/useSubCategory.ts
Normal file
20
zustand/useSubCategory.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { SubCategoryType } from "@/lib/types";
|
||||
import { create } from "zustand";
|
||||
|
||||
interface SubCategoryZustandType {
|
||||
subCategory: SubCategoryType;
|
||||
setSubCategory: (subCategory: SubCategoryType) => void;
|
||||
clearSubCategory: () => void;
|
||||
}
|
||||
|
||||
const demoSubCategory = {
|
||||
id: 0,
|
||||
name: "",
|
||||
category: 0,
|
||||
image: "",
|
||||
};
|
||||
export const useSubCategory = create<SubCategoryZustandType>((set) => ({
|
||||
subCategory: demoSubCategory,
|
||||
setSubCategory: (data) => set({ subCategory: data }),
|
||||
clearSubCategory: () => set({ subCategory: demoSubCategory }),
|
||||
}));
|
||||
Reference in New Issue
Block a user