Skip to content

Commit

Permalink
удаление карты, модуля, уровня v1
Browse files Browse the repository at this point in the history
  • Loading branch information
semant1cs committed Dec 14, 2023
1 parent 2e8a823 commit 5dade9f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
7 changes: 7 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"@types/progressbar.js": "^1.1.7",
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react-swc": "^3.3.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const SuperUserMap: React.FC<ISuperUserMap> = observer(() => {
mapMenuStore.selectMap(map).then(() => mapMenuStore.changeCurrentMapIndex(indexMap))
}, [])

const handleOnClickOptionModule = useCallback((module: IModuleType, index) => {
const handleOnClickOptionModule = useCallback((module: IModuleType, index: number) => {
console.log(module)
moduleMenuStore.selectModule(module).then(() => moduleMenuStore.changeCurrentModuleIndex(index))
}, [])

Expand Down
17 changes: 13 additions & 4 deletions frontend/src/store/levelStore.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {makeAutoObservable} from "mobx";

import axios from "axios";

import mapMenuStore from "./mapMenuStore.ts";
import {IModuleType} from "../types/ModuleType.ts";
import moduleMenuStore from "./moduleMenuStore.ts";

import {ILevelType} from "../types/LevelType.ts";

class levelStore {
chosenTaskIndex: number = 1
availableLevels: ILevelType[] = []

constructor() {
makeAutoObservable(this)
Expand All @@ -18,11 +23,15 @@ class levelStore {
this.chosenTaskIndex = 1
}

setAvailableLevels(levels: ILevelType[]) {
this.availableLevels = levels
}

async fetchLevels() {
await axios.get("http://localhost:8000/maps/" + mapMenuStore.currentMapId + "/modules/")
await axios.get("http://localhost:8000/maps/" + mapMenuStore.currentMapId + "/modules/" + moduleMenuStore.currentModuleId + "/levels")
.then((response) => {
this.setAvailableModules([])
this.setAvailableModules(response.data.filter((module: IModuleType) => module.map_id === mapMenuStore.currentMapId))
this.setAvailableLevels([])
this.setAvailableLevels(response.data)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/store/moduleMenuStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ModuleMenuStore {

async deleteModule(id?: string) {
console.log(id)
axios.delete("http://localhost:8000/modules/" + id).catch(() => alert("Выберите модуль"))
axios.delete("http://localhost:8000/maps/" + mapMenuStore.currentMapId + "/modules/" + id).catch(() => alert("Выберите модуль"))
}

updateModuleById(mapId: string, id: string, title?: string, previousModuleId?: string, nextModuleId?: string, levels?: string[]) {
Expand Down

0 comments on commit 5dade9f

Please sign in to comment.