Skip to content

Commit

Permalink
добавление модулей
Browse files Browse the repository at this point in the history
  • Loading branch information
semant1cs committed Dec 14, 2023
1 parent 5dade9f commit 6eb910e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 42 deletions.
22 changes: 1 addition & 21 deletions frontend/package-lock.json

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

4 changes: 1 addition & 3 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
"react-starfield": "^1.0.3",
"sass": "^1.69.5",
"serve": "^14.2.1",
"sort-by": "^0.0.2",
"uuid": "^9.0.1"
"sort-by": "^0.0.2"
},
"devDependencies": {
"@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
10 changes: 5 additions & 5 deletions frontend/src/components/mapMenu/MapMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,12 @@ const MapMenu: React.FC = observer(() => {

superUserStore.setAllUsers(response.data)


if (user) {
const date = new Date(Date.parse(user!.registered_at))
setFormattedDate(`${date.getDay()}.${date.getMonth()}.${date.getUTCFullYear()}`)
}
})
}, [user])
}, [])

useEffect(() => {
if (!authStore.isUserAuthorized)
Expand All @@ -54,9 +53,10 @@ const MapMenu: React.FC = observer(() => {
speedFactor={0.05}
backgroundColor="black"
/>
{!user?.is_superuser
? <SuperUserMap/>
: <EmployeeMap user={user} formattedDate={formattedDate}/>
{
user?.is_superuser
? <SuperUserMap/>
: <EmployeeMap user={user} formattedDate={formattedDate}/>
}
</div>
);
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const SuperUserMap: React.FC<ISuperUserMap> = observer(() => {
setMapName(e.currentTarget.value)
}, [])

const handleOnClickCreateMap = useCallback(() => {
const handleOnClickCreateMap = useCallback((mapName: string) => {
mapName !== "" ? mapMenuStore.createMap(mapName) : alert("Введите название карты")
mapMenuStore.fetchAvailableMaps().then()
}, [])
Expand All @@ -56,7 +56,7 @@ const SuperUserMap: React.FC<ISuperUserMap> = observer(() => {
setModuleName(e.currentTarget.value)
}, [])

const handleOnClickCreateModule = useCallback(() => {
const handleOnClickCreateModule = useCallback((moduleName: string) => {
moduleName !== "" ? moduleMenuStore.createModule(moduleName) : alert("Введите название модуля")
moduleMenuStore.fetchModules().then()
}, [])
Expand Down Expand Up @@ -89,21 +89,21 @@ const SuperUserMap: React.FC<ISuperUserMap> = observer(() => {
<CustomInput
type="text"
value={mapName}
handleOnChange={handleOnChangeMapName}
handleOnChange={(e) => handleOnChangeMapName(e)}
/>
<CustomAddButton
handleOnClick={handleOnClickCreateMap}
handleOnClick={() => handleOnClickCreateMap(mapName)}
/>
</div>

<div className="map-creator-item module-create">
<CustomInput
type="text"
value={moduleName}
handleOnChange={handleOnChangeModuleName}
handleOnChange={(e) => handleOnChangeModuleName(e)}
/>
<CustomAddButton
handleOnClick={handleOnClickCreateModule}
handleOnClick={() => handleOnClickCreateModule(moduleName)}
/>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ const UsersListModalBody: React.FC<IUsersListModalBody> = ({users}) => {
<div className="users-list">
{users.map((user) => (
isUsersCardModalOpen
? <ModalWindow body={userProfileModalBody}
onClose={handleOnCloseUserCard}/>
? <ModalWindow
body={userProfileModalBody}
onClose={handleOnCloseUserCard}
/>
: (
<div className="users-list-user" onClick={() => handleOnClickUserCard(user)}>
<div key={user.email} className="users-list-user" onClick={() => handleOnClickUserCard(user)}>
<div className="users-list-user-name">
{user.username}
</div>
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/store/moduleMenuStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,11 @@ class ModuleMenuStore {
}

async createModule(title: string) {
const newId = uuidv4();

await axios.post("http://localhost:8000/maps/" + mapMenuStore.currentMapId + "/modules/", {
map_id: mapMenuStore.currentMapId,
title: title,
previous_module_id: newId,
next_module_id: newId,
previous_module_id: null,
next_module_id: null,
})
}

Expand Down

0 comments on commit 6eb910e

Please sign in to comment.