feat: Add edit/create/list
sight page
This commit is contained in:
25
src/shared/store/CityStore/index.tsx
Normal file
25
src/shared/store/CityStore/index.tsx
Normal file
@ -0,0 +1,25 @@
|
||||
import { authInstance } from "@shared";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
type City = {
|
||||
id: number;
|
||||
name: string;
|
||||
country_code: string;
|
||||
country: string;
|
||||
arms?: string;
|
||||
};
|
||||
|
||||
class CityStore {
|
||||
cities: City[] = [];
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
getCities = async () => {
|
||||
const response = await authInstance.get("/city");
|
||||
this.cities = response.data;
|
||||
};
|
||||
}
|
||||
|
||||
export const cityStore = new CityStore();
|
@ -2,7 +2,7 @@ import { API_URL, authInstance } from "@shared";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
class DevicesStore {
|
||||
devices: any[] = [];
|
||||
devices: string[] = [];
|
||||
uuid: string | null = null;
|
||||
sendSnapshotModalOpen = false;
|
||||
|
||||
@ -12,7 +12,6 @@ class DevicesStore {
|
||||
|
||||
getDevices = async () => {
|
||||
const response = await authInstance.get(`${API_URL}/devices/connected`);
|
||||
console.log(response.data);
|
||||
this.devices = response.data;
|
||||
};
|
||||
|
||||
|
87
src/shared/store/SightsStore/index.tsx
Normal file
87
src/shared/store/SightsStore/index.tsx
Normal file
@ -0,0 +1,87 @@
|
||||
import { authInstance } from "@shared";
|
||||
import { makeAutoObservable, runInAction } from "mobx";
|
||||
|
||||
export type Language = "ru" | "en" | "zh";
|
||||
|
||||
export type MultilingualContent = {
|
||||
[key in Language]: {
|
||||
name: string;
|
||||
description: string;
|
||||
address: string;
|
||||
// Add other fields that need to be multilingual
|
||||
};
|
||||
};
|
||||
|
||||
export type Sight = {
|
||||
id: number;
|
||||
name: string;
|
||||
city_id: number;
|
||||
city: string;
|
||||
address: string;
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
thumbnail: string | null;
|
||||
watermark_lu: string | null;
|
||||
watermark_rd: string | null;
|
||||
left_article: number;
|
||||
preview_media: string;
|
||||
video_preview: string | null;
|
||||
};
|
||||
|
||||
class SightsStore {
|
||||
sights: Sight[] = [];
|
||||
sight: Sight | null = null;
|
||||
cachedMultilingualContent: MultilingualContent | null = null;
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
}
|
||||
|
||||
getSights = async () => {
|
||||
const response = await authInstance.get("/sight");
|
||||
runInAction(() => {
|
||||
this.sights = response.data;
|
||||
});
|
||||
};
|
||||
|
||||
getSight = async (id: number) => {
|
||||
const response = await authInstance.get(`/sight/${id}`);
|
||||
|
||||
runInAction(() => {
|
||||
this.sight = response.data;
|
||||
});
|
||||
};
|
||||
|
||||
setCachedMultilingualContent = (content: MultilingualContent) => {
|
||||
runInAction(() => {
|
||||
this.cachedMultilingualContent = content;
|
||||
});
|
||||
};
|
||||
|
||||
updateCachedLanguageContent = (
|
||||
language: Language,
|
||||
content: Partial<MultilingualContent[Language]>
|
||||
) => {
|
||||
runInAction(() => {
|
||||
if (!this.cachedMultilingualContent) {
|
||||
this.cachedMultilingualContent = {
|
||||
ru: { name: "", description: "", address: "" },
|
||||
en: { name: "", description: "", address: "" },
|
||||
zh: { name: "", description: "", address: "" },
|
||||
};
|
||||
}
|
||||
this.cachedMultilingualContent[language] = {
|
||||
...this.cachedMultilingualContent[language],
|
||||
...content,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
clearCachedMultilingualContent = () => {
|
||||
runInAction(() => {
|
||||
this.cachedMultilingualContent = null;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export const sightsStore = new SightsStore();
|
@ -2,8 +2,15 @@ import { authInstance } from "@shared";
|
||||
import { API_URL } from "@shared";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
type Snapshot = {
|
||||
ID: string;
|
||||
Name: string;
|
||||
ParentID: string;
|
||||
CreationTime: string;
|
||||
};
|
||||
|
||||
class SnapshotStore {
|
||||
snapshots: any[] = [];
|
||||
snapshots: Snapshot[] = [];
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
|
@ -1,8 +1,27 @@
|
||||
import { API_URL, authInstance } from "@shared";
|
||||
import { makeAutoObservable } from "mobx";
|
||||
|
||||
type Vehicle = {
|
||||
vehicle: {
|
||||
id: number;
|
||||
tail_number: number;
|
||||
type: number;
|
||||
carrier_id: number;
|
||||
carrier: string;
|
||||
uuid?: string;
|
||||
};
|
||||
device_status?: {
|
||||
device_uuid: string;
|
||||
online: boolean;
|
||||
gps_ok: boolean;
|
||||
media_service_ok: boolean;
|
||||
last_update: string;
|
||||
is_connected: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
class VehicleStore {
|
||||
vehicles: any[] = [];
|
||||
vehicles: Vehicle[] = [];
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this);
|
||||
|
@ -3,3 +3,5 @@ export * from "./LanguageStore";
|
||||
export * from "./DevicesStore";
|
||||
export * from "./VehicleStore";
|
||||
export * from "./SnapshotStore";
|
||||
export * from "./SightsStore";
|
||||
export * from "./CityStore";
|
||||
|
Reference in New Issue
Block a user