feat: Add more pages

This commit is contained in:
2025-06-06 16:08:15 +03:00
parent f2aab1ab33
commit d74789a0d8
67 changed files with 3491 additions and 787 deletions

View File

@ -1,4 +1,4 @@
import { API_URL, authInstance } from "@shared";
import { authInstance } from "@shared";
import { makeAutoObservable } from "mobx";
export type Vehicle = {
@ -22,15 +22,43 @@ export type Vehicle = {
class VehicleStore {
vehicles: Vehicle[] = [];
vehicle: Vehicle | null = null;
constructor() {
makeAutoObservable(this);
}
getVehicles = async () => {
const response = await authInstance.get(`${API_URL}/vehicle`);
const response = await authInstance.get(`/vehicle`);
this.vehicles = response.data;
};
deleteVehicle = async (id: number) => {
await authInstance.delete(`/vehicle/${id}`);
this.vehicles = this.vehicles.filter(
(vehicle) => vehicle.vehicle.id !== id
);
};
getVehicle = async (id: number) => {
const response = await authInstance.get(`/vehicle/${id}`);
this.vehicle = response.data;
};
createVehicle = async (
tailNumber: number,
type: string,
carrier: string,
carrierId: number
) => {
await authInstance.post("/vehicle", {
tail_number: tailNumber,
type,
carrier,
carrier_id: carrierId,
});
await this.getVehicles();
};
}
export const vehicleStore = new VehicleStore();