UNPKG

test-iki-mini-app

Version:

ứng dựng bán hàng trên mini app z a l o

30 lines (27 loc) 702 B
import { create } from "zustand"; import { RepositoryRemote } from "../services"; import { alerts } from "../utils/alerts"; const allCategory = { id: 1, name: "Tất cả", image_url: "", position: 0, is_show_home: true, slug: "tat-ca", category_children: [], }; export const useCategoryStore = create((set) => ({ categories: [], loading: false, allCategory: async (onSuccess, onFail) => { try { set({ loading: true }); const response = await RepositoryRemote.category.allCategory(); set({ categories: [allCategory, ...response.data.data] }); onSuccess(response); } catch (error) { onFail(error); } set({ loading: false }); }, }));