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

@ -0,0 +1,76 @@
import { authInstance } from "@shared";
import { makeAutoObservable, runInAction } from "mobx";
export type Carrier = {
id: number;
short_name: string;
full_name: string;
slogan: string;
city: string;
city_id: number;
logo: string;
main_color: string;
left_color: string;
right_color: string;
};
class CarrierStore {
carriers: Carrier[] = [];
carrier: Carrier | null = null;
constructor() {
makeAutoObservable(this);
}
getCarriers = async () => {
const response = await authInstance.get("/carrier");
runInAction(() => {
this.carriers = response.data;
});
};
deleteCarrier = async (id: number) => {
await authInstance.delete(`/carrier/${id}`);
runInAction(() => {
this.carriers = this.carriers.filter((carrier) => carrier.id !== id);
});
};
getCarrier = async (id: number) => {
const response = await authInstance.get(`/carrier/${id}`);
runInAction(() => {
this.carrier = response.data;
});
return response.data;
};
createCarrier = async (
fullName: string,
shortName: string,
city: string,
cityId: number,
primaryColor: string,
secondaryColor: string,
accentColor: string,
slogan: string,
logoId: string
) => {
const response = await authInstance.post("/carrier", {
full_name: fullName,
short_name: shortName,
city,
city_id: cityId,
primary_color: primaryColor,
secondary_color: secondaryColor,
accent_color: accentColor,
slogan,
logo: logoId,
});
runInAction(() => {
this.carriers.push(response.data);
});
};
}
export const carrierStore = new CarrierStore();