thêm giao diện quản lý thuyền
This commit is contained in:
24
state/use-ship-groups.ts
Normal file
24
state/use-ship-groups.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { queryShipGroups } from "@/controller/DeviceController";
|
||||
import { create } from "zustand";
|
||||
|
||||
type ShipGroups = {
|
||||
shipGroups: Model.ShipGroup[] | null;
|
||||
getShipGroups: () => Promise<void>;
|
||||
error: string | null;
|
||||
loading?: boolean;
|
||||
};
|
||||
|
||||
export const useShipGroups = create<ShipGroups>((set) => ({
|
||||
shipGroups: null,
|
||||
getShipGroups: async () => {
|
||||
try {
|
||||
const response = await queryShipGroups();
|
||||
set({ shipGroups: response.data, loading: false });
|
||||
} catch (error) {
|
||||
console.error("Error when fetch Port: ", error);
|
||||
set({ error: "Failed to fetch Port data", loading: false });
|
||||
set({ shipGroups: null });
|
||||
}
|
||||
},
|
||||
error: null,
|
||||
}));
|
||||
Reference in New Issue
Block a user