55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { ResponseApi } from "./response.types";
|
|
import { CacheState, ErrorState, SelectState } from "./store.types";
|
|
|
|
export interface DeviceRepositoryProps {
|
|
getAll: () => Promise<DeviceDataTable[] | []>;
|
|
getDeviceById: (id: string) => Promise<Device>;
|
|
createDevice: (device: DeviceRequest) => Promise<Pick<ResponseApi<any>, "status">>;
|
|
updateDevice: (id: string, device: DeviceRequest) => Promise<Pick<ResponseApi<any>, "status">>;
|
|
getTowerSelect: () => Promise<SelectState[] | null>;
|
|
}
|
|
|
|
export interface Device {
|
|
id: string;
|
|
device_code: string;
|
|
device_type: string;
|
|
longitude: string | number;
|
|
latitude: string | number;
|
|
port_amount: number;
|
|
status: DeviceStatus;
|
|
tower_id: string | null;
|
|
created_at: string;
|
|
updated_at: string;
|
|
}
|
|
|
|
export type DeviceStatus = "active" | "inactive" | "maintenance";
|
|
|
|
export interface DeviceRequest extends Omit<Device, "id" & "created_at" & "updated_at"> {}
|
|
|
|
/**
|
|
* Device State
|
|
* =============
|
|
*/
|
|
export interface DeviceState extends ErrorState, CacheState {
|
|
data?: DeviceDataTable[];
|
|
device?: Device | null;
|
|
isLoading: boolean;
|
|
lastUpdate: number | null;
|
|
towerSelect: SelectState[] | null;
|
|
getTowerSelect: () => Promise<void>;
|
|
getAll: () => Promise<void>;
|
|
find: (id: string) => Promise<void>;
|
|
create: (device: DeviceRequest) => Promise<void>;
|
|
update: (id: string, device: DeviceRequest) => Promise<void>;
|
|
clearDevice: () => void;
|
|
}
|
|
|
|
export interface DeviceDataTable extends Pick<Device, "id" | "device_code" | "device_type" | "port_amount" | "status"> {
|
|
address: string;
|
|
total_used_port: string | number;
|
|
}
|
|
|
|
export interface IGetTowerSelect {
|
|
id: string;
|
|
tower_code: string;
|
|
} |