hiển thị thuyền thông tin tàu

This commit is contained in:
Tran Anh Tuan
2025-12-03 16:22:25 +07:00
parent 47e9bac0f9
commit 22a3b591c6
22 changed files with 2135 additions and 260 deletions

24
state/use-ship-types.ts Normal file
View File

@@ -0,0 +1,24 @@
import { queryShipTypes } from "@/controller/DeviceController";
import { create } from "zustand";
type ShipType = {
shipTypes: Model.ShipType[] | [];
getShipTypes: () => Promise<void>;
error: string | null;
loading?: boolean;
};
export const useShipTypes = create<ShipType>((set) => ({
shipTypes: [],
getShipTypes: async () => {
try {
const response = await queryShipTypes();
set({ shipTypes: response.data, loading: false });
} catch (error) {
console.error("Error when fetch shipTypes: ", error);
set({ error: "Failed to fetch shipTypes data", loading: false });
set({ shipTypes: [] });
}
},
error: null,
}));