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,6 +1,6 @@
import { authInstance } from "@shared";
import { API_URL } from "@shared";
import { makeAutoObservable } from "mobx";
import { makeAutoObservable, runInAction } from "mobx";
type Snapshot = {
ID: string;
@@ -11,14 +11,42 @@ type Snapshot = {
class SnapshotStore {
snapshots: Snapshot[] = [];
snapshot: Snapshot | null = null;
constructor() {
makeAutoObservable(this);
}
getSnapshots = async () => {
const response = await authInstance.get(`${API_URL}/snapshots`);
this.snapshots = response.data;
const response = await authInstance.get(`/snapshots`);
runInAction(() => {
this.snapshots = response.data;
});
};
deleteSnapshot = async (id: string) => {
await authInstance.delete(`/snapshots/${id}`);
runInAction(() => {
this.snapshots = this.snapshots.filter((snapshot) => snapshot.ID !== id);
});
};
getSnapshot = async (id: string) => {
const response = await authInstance.get(`/snapshots/${id}`);
runInAction(() => {
this.snapshot = response.data;
});
};
restoreSnapshot = async (id: string) => {
await authInstance.post(`/snapshots/${id}/restore`);
};
createSnapshot = async (name: string) => {
await authInstance.post(`/snapshots`, { name });
};
}