From 3260f0e5d2c37d287afb9a34fb53ea5feebc2f28 Mon Sep 17 00:00:00 2001 From: semantics Date: Thu, 14 Dec 2023 08:06:29 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BB=D0=B8=D0=BD=D1=82=D0=B5=D1=80,=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA?= =?UTF-8?q?=D1=83=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customAddButton/CustomAddButton.tsx | 12 +++++++ .../UIComponents/customInput/CustomInput.tsx | 5 +++ .../components/authentication/AuthForm.tsx | 9 +++-- frontend/src/components/mapMenu/MapMenu.tsx | 2 +- .../mapMenu/SuperUserMap/SuperUserMap.tsx | 36 ++++++++++--------- frontend/tsconfig.json | 15 +++++--- 6 files changed, 52 insertions(+), 27 deletions(-) create mode 100644 frontend/src/UIComponents/customAddButton/CustomAddButton.tsx diff --git a/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx b/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx new file mode 100644 index 0000000..e09687d --- /dev/null +++ b/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx @@ -0,0 +1,12 @@ +import React from 'react'; + +const CustomAddButton: React.FC = () => { + return ( + + + + + ); +}; + +export default CustomAddButton; diff --git a/frontend/src/UIComponents/customInput/CustomInput.tsx b/frontend/src/UIComponents/customInput/CustomInput.tsx index 9bf851e..ebc0e1c 100644 --- a/frontend/src/UIComponents/customInput/CustomInput.tsx +++ b/frontend/src/UIComponents/customInput/CustomInput.tsx @@ -18,6 +18,7 @@ interface IPropTypes { register?: UseFormRegister, required?: boolean, value?: string, + handleOnChange?: (e: string) => void, } const CustomInput: React.FC = @@ -33,6 +34,8 @@ const CustomInput: React.FC = defaultValue, register, validateRules, + value, + handleOnChange, ...inputProps }) => { return ( @@ -49,6 +52,8 @@ const CustomInput: React.FC = defaultValue={defaultValue} {...register !== undefined && name !== undefined ? {...register(name, validateRules)} : ""} {...inputProps} + value={value} + onChange={(e) => handleOnChange ? (e.target.value) : undefined} /> {/*{error.message && {error.message}}*/} diff --git a/frontend/src/components/authentication/AuthForm.tsx b/frontend/src/components/authentication/AuthForm.tsx index 56da911..bb7a63e 100644 --- a/frontend/src/components/authentication/AuthForm.tsx +++ b/frontend/src/components/authentication/AuthForm.tsx @@ -1,15 +1,15 @@ import React, {useCallback, useState} from 'react'; -import CustomInput from "../../UIComponents/customInput/CustomInput.tsx"; -import CustomCheckbox from "../../UIComponents/customCheckbox/CustomCheckbox.tsx"; +import CustomInput from "../../UIComponents/customInput/CustomInput"; +import CustomCheckbox from "../../UIComponents/customCheckbox/CustomCheckbox"; import {useNavigate} from "react-router-dom" import {useForm} from "react-hook-form"; import {observer} from "mobx-react-lite"; -import authStore from "../../store/authStore.ts"; -import auth from "../../utils/auth.ts"; +import authStore from "../../store/authStore"; +import auth from "../../utils/auth"; import Starfield from "react-starfield"; export type FormValues = { @@ -29,7 +29,6 @@ const AuthForm: React.FC = observer(() => { const onHandleSubmit = useCallback((data: { login: string, password: string }) => { authStore.signIn(data.login, data.password).then(() => navigateTo('/map')) - console.log(data.login, data.password) }, [navigateTo]) return ( diff --git a/frontend/src/components/mapMenu/MapMenu.tsx b/frontend/src/components/mapMenu/MapMenu.tsx index 51a2ea3..2fb3c97 100644 --- a/frontend/src/components/mapMenu/MapMenu.tsx +++ b/frontend/src/components/mapMenu/MapMenu.tsx @@ -54,7 +54,7 @@ const MapMenu: React.FC = observer(() => { speedFactor={0.05} backgroundColor="black" /> - {user?.is_superuser + {!user?.is_superuser ? : } diff --git a/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx b/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx index 5522a0b..b61c9a6 100644 --- a/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx +++ b/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useState} from 'react'; +import React, {useCallback, useEffect, useState} from 'react'; import CustomButton from "../../../UIComponents/customButton/CustomButton.tsx"; import mapMenuStore from "../../../store/mapMenuStore.ts"; import CustomInput from "../../../UIComponents/customInput/CustomInput.tsx"; @@ -26,31 +26,33 @@ const SuperUserMap: React.FC = observer(() => { mapMenuStore.selectMap(map).then(() => mapMenuStore.changeCurrentMapIndex(indexMap)) } - function handleOnClickChangeIsModalOpen() { + const handleOnClickChangeIsModalOpen = useCallback(() => { setIsUserListModalOpen(!isUsersListModalOpen) - } - + }, [isUsersListModalOpen]) return (
- {isUsersListModalOpen - ? } - windowContentStyles="" - /> - : ""} + { + isUsersListModalOpen + ? } + windowContentStyles="" + /> + : "" + } - + + {/**/}
- mapMenuStore.changeNewMapName(e)}/> mapMenuStore.createMap(mapMenuStore.newNameMap)}/> + mapMenuStore.changeNewMapName(e)}/>
- {mapMenuStore.availableMaps?.map((map, index) => - )} - mapMenuStore.deleteMap(mapMenuStore.mapMenu?.id)}/> - +
+ mapMenuStore.createMap(mapMenuStore.newNameMap)}/> + mapMenuStore.changeNewMapName(e)}/> +
- + {/**/} + + {/**/}
); }); From 98e32497c512821f08cdf9670f6e3bbda574a791 Mon Sep 17 00:00:00 2001 From: semantics Date: Thu, 14 Dec 2023 11:27:12 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=D0=B5=D1=82=20?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8/=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customAddButton/CustomAddButton.tsx | 3 +- .../customAddButton.module.scss | 5 +++ .../mapMenu/SuperUserMap/SuperUserMap.tsx | 35 ++++++++++++------- frontend/src/store/mapMenuStore.ts | 8 ++--- frontend/src/styles/mapMenu.scss | 11 ++++++ 5 files changed, 45 insertions(+), 17 deletions(-) create mode 100644 frontend/src/UIComponents/customAddButton/customAddButton.module.scss diff --git a/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx b/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx index 5ef8405..6362092 100644 --- a/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx +++ b/frontend/src/UIComponents/customAddButton/CustomAddButton.tsx @@ -1,4 +1,5 @@ import React from 'react'; +import styles from "./customAddButton.module.scss" interface ICustomAddButton { handleOnClick: () => void; @@ -6,7 +7,7 @@ interface ICustomAddButton { const CustomAddButton: React.FC = ({handleOnClick}) => { return ( -
+
diff --git a/frontend/src/UIComponents/customAddButton/customAddButton.module.scss b/frontend/src/UIComponents/customAddButton/customAddButton.module.scss new file mode 100644 index 0000000..faa5668 --- /dev/null +++ b/frontend/src/UIComponents/customAddButton/customAddButton.module.scss @@ -0,0 +1,5 @@ +.add__btn{ + :hover { + cursor: pointer + } +} diff --git a/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx b/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx index 61d142c..7b65452 100644 --- a/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx +++ b/frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx @@ -8,6 +8,7 @@ import moduleMenuStore from "../../../store/moduleMenuStore.ts"; import {IMapType} from "../../../types/MapType.ts"; import ModalWindow from "../../../UIComponents/modalWindow/ModalWindow.tsx"; import UsersListModalBody from "./UsersListModalBody.tsx"; +import CustomAddButton from "../../../UIComponents/customAddButton/CustomAddButton.tsx"; interface ISuperUserMap { @@ -16,6 +17,10 @@ interface ISuperUserMap { const SuperUserMap: React.FC = observer(() => { const [isUsersListModalOpen, setIsUserListModalOpen] = useState(false) + const [mapName, setMapName] = useState("") + const [moduleName, setModuleName] = useState("") + const [levelName, setLevelName] = useState("") + useEffect(() => { mapMenuStore.fetchAvailableMaps() .then(() => mapMenuStore.fetchMapById(mapMenuStore.availableMaps[mapMenuStore.currentMapIndex].id) @@ -41,7 +46,10 @@ const SuperUserMap: React.FC = observer(() => { /> : null } - + + + {/**/}
- mapMenuStore.createMap(mapMenuStore.newNameMap)}/> - mapMenuStore.changeNewMapName(e)}/> + mapMenuStore.changeNewMapName(e)} + /> + mapMenuStore.createMap(mapMenuStore.newNameMap)} + />
@@ -62,13 +73,13 @@ const SuperUserMap: React.FC = observer(() => { handleOnChange={(e) => mapMenuStore.changeNewMapName(e)}/>
- {/**/} + + mapMenuStore.deleteMap(mapMenuStore.mapMenu?.id)}/> {/*