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,49 @@
import { authInstance } from "@shared";
import { makeAutoObservable, runInAction } from "mobx";
export type Country = {
code: string;
name: string;
};
class CountryStore {
countries: Country[] = [];
country: Country | null = null;
constructor() {
makeAutoObservable(this);
}
getCountries = async () => {
const response = await authInstance.get("/country");
runInAction(() => {
this.countries = response.data;
});
};
getCountry = async (code: string) => {
const response = await authInstance.get(`/country/${code}`);
runInAction(() => {
this.country = response.data;
});
};
deleteCountry = async (code: string) => {
await authInstance.delete(`/country/${code}`);
runInAction(() => {
this.countries = this.countries.filter(
(country) => country.code !== code
);
});
};
createCountry = async (code: string, name: string) => {
await authInstance.post("/country", { code: code, name: name });
await this.getCountries();
};
}
export const countryStore = new CountryStore();