feat: Add more pages
This commit is contained in:
@@ -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 });
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user