28 lines
475 B
TypeScript
28 lines
475 B
TypeScript
import { create } from "zustand";
|
|
|
|
// Type definition
|
|
interface CarType {
|
|
name: string;
|
|
id: number;
|
|
}
|
|
|
|
interface CarStore {
|
|
initialCar: CarType;
|
|
setInitialCar: (data: CarType) => void;
|
|
clearCar: () => void; // Tozalash uchun
|
|
}
|
|
|
|
export const useCarType = create<CarStore>((set) => ({
|
|
initialCar: {
|
|
name: "",
|
|
id: 0,
|
|
},
|
|
|
|
setInitialCar: (data) => set({ initialCar: data }),
|
|
|
|
clearCar: () =>
|
|
set({
|
|
initialCar: { name: "", id: 0 },
|
|
}),
|
|
}));
|