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,44 @@
import { authInstance } from "@shared";
import { makeAutoObservable, runInAction } from "mobx";
export type User = {
id: number;
email: string;
is_admin: boolean;
name: string;
};
class UserStore {
users: User[] = [];
user: User | null = null;
constructor() {
makeAutoObservable(this);
}
getUsers = async () => {
const response = await authInstance.get("/user");
runInAction(() => {
this.users = response.data;
});
};
getUser = async (id: number) => {
const response = await authInstance.get(`/user/${id}`);
runInAction(() => {
this.user = response.data as User;
});
};
deleteUser = async (id: number) => {
await authInstance.delete(`/users/${id}`);
runInAction(() => {
this.users = this.users.filter((user) => user.id !== id);
});
};
}
export const userStore = new UserStore();