Skip to content

Commit

Permalink
Декомпозицирует типы, добавляет стейтменеджер для карты
Browse files Browse the repository at this point in the history
  • Loading branch information
semant1cs committed Nov 16, 2023
1 parent 85a9cb2 commit dd9a075
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 34 deletions.
3 changes: 2 additions & 1 deletion frontend/src/components/mapMenu/MapMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './../../styles/mapMenu.scss'
import ChooseModuleWindow from "./UIMapMenu/ChooseModuleWindow.tsx";
import UserProfile from "./UIMapMenu/UserProfile.tsx";
import Geolocation from "./UIMapMenu/Level/Geolocation.tsx";
import {GeolocationType} from "../../types/GeolocationType.ts";

const MapMenu: React.FC = () => {
const navigate = useNavigate()
Expand All @@ -16,7 +17,7 @@ const MapMenu: React.FC = () => {
navigate('/')
}

const geolocations = [
const geolocations: GeolocationType[] = [
{
id: 1,
level: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from 'react';
import ArrowLeft from "./UIChooseModule/ArrowLeft.tsx";
import ArrowRight from "./UIChooseModule/ArrowRight.tsx";

interface IPropTypes {

Expand All @@ -10,13 +8,7 @@ const ChooseModuleWindow: React.FC<IPropTypes> = () => {
return (
<div className="choose-module-window">
<div className="choose-module-window__wrapper">
<div className="left-arrow">
<ArrowLeft/>
</div>
МОДУЛЬ 1
<div className="right-arrow">
<ArrowRight/>
</div>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import React, {useState} from 'react';
import ModalWindow from "../../../../UIComponents/modalWindow/ModalWindow.tsx";
import ModalLevelBody, {IModalLevelProps} from "./ModalLevelBody.tsx";
import ModalLevelBody from "./ModalLevelBody.tsx";
import {GeolocationType} from "../../../../types/GeolocationType.ts";

interface IGeolocationProps {
id: number,
level: IModalLevelProps
}

const Geolocation: React.FC<IGeolocationProps> = ({id, level}) => {
const Geolocation: React.FC<GeolocationType> = ({id, level}) => {
const [isOpenModalWindow, setOpenModalWindow] = useState(false)
const classNameGeolocation = "geolocation-" + id
return (
Expand Down
22 changes: 3 additions & 19 deletions frontend/src/components/mapMenu/UIMapMenu/Level/ModalLevelBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@ import React, {useState} from 'react';
import "./modalLevelBody.scss"
import ArrowLeft from "../UIChooseModule/ArrowLeft.tsx";
import ArrowRight from "../UIChooseModule/ArrowRight.tsx";
import {LevelType} from "../../../../types/LevelType.ts";

export interface IModalLevelProps {
levelName: string,
title: string,
menu: MenuType[]
}

type MenuType = {
taskName: string,
body: string
}

interface taskType {
name: string,
element: JSX.Element
}


const ModalLevelBody: React.FC<IModalLevelProps> = ({levelName, title, menu}) => {
const tasks: taskType[] = [
const ModalLevelBody: React.FC<LevelType> = ({levelName, title, menu}) => {
const tasks = [
{name: "theory", element: <Theory/>},
{name: "video", element: <Video/>},
{name: "test", element: <Test/>}
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/store/authStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {makeAutoObservable} from "mobx";

class AuthStore {
isUserAuthorized: boolean = false
userRole: string | null = null

userLogin: string = ""
userPassword: string = ""

Expand All @@ -24,6 +26,10 @@ class AuthStore {
changeUserPassword(newPassword: string) {
this.userPassword = newPassword
}

setUserRole(newUserRole: string) {
this.userRole = newUserRole
}
}

export default new AuthStore()
15 changes: 15 additions & 0 deletions frontend/src/store/mapMenuStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {makeAutoObservable} from "mobx";
import {GeolocationType} from "../types/GeolocationType.ts";

class MapMenuStore {

coinsCount: number = 0
moduleId: string | null = null
geolocations: GeolocationType[] = []

constructor() {
makeAutoObservable(this)
}
}

export default new MapMenuStore()
6 changes: 6 additions & 0 deletions frontend/src/types/GeolocationType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {LevelType} from "./LevelType.ts";

export type GeolocationType = {
id: number;
level: LevelType
}
7 changes: 7 additions & 0 deletions frontend/src/types/LevelType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {TaskType} from "./TaskType.ts";

export type LevelType = {
levelName: string,
title: string
menu: TaskType[]
}
4 changes: 4 additions & 0 deletions frontend/src/types/TaskType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type TaskType = {
taskName: string,
body: string
}

0 comments on commit dd9a075

Please sign in to comment.