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";
type Station = {
id: number;
address: string;
city: string;
city_id: number;
description: string;
direction: boolean;
icon: string;
latitude: number;
longitude: number;
name: string;
offset_x: number;
offset_y: number;
system_name: string;
transfers: {
bus: string;
metro_blue: string;
metro_green: string;
metro_orange: string;
metro_purple: string;
metro_red: string;
train: string;
tram: string;
trolleybus: string;
};
};
class StationsStore {
stations: Station[] = [];
station: Station | null = null;
constructor() {
makeAutoObservable(this);
}
getStations = async () => {
const response = await authInstance.get("/station");
runInAction(() => {
this.stations = response.data;
});
};
deleteStation = async (id: number) => {
await authInstance.delete(`/station/${id}`);
runInAction(() => {
this.stations = this.stations.filter((station) => station.id !== id);
});
};
getStation = async (id: number) => {
const response = await authInstance.get(`/station/${id}`);
this.station = response.data;
};
createStation = async (
name: string,
systemName: string,
direction: string
) => {
const response = await authInstance.post("/station", {
station_name: name,
system_name: systemName,
direction,
});
runInAction(() => {
this.stations.push(response.data);
});
};
}
export const stationsStore = new StationsStore();