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 3ce39af commit 3260f0e
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 27 deletions.
12 changes: 12 additions & 0 deletions frontend/src/UIComponents/customAddButton/CustomAddButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

const CustomAddButton: React.FC = () => {
return (
<svg width="70" height="70" viewBox="0 0 70 70" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="35" cy="35" r="35" fill="#00D29D"/>
<path d="M35 10V60M10 34.5H35H60" stroke="white" strokeWidth="4"/>
</svg>
);
};

export default CustomAddButton;
5 changes: 5 additions & 0 deletions frontend/src/UIComponents/customInput/CustomInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface IPropTypes {
register?: UseFormRegister<FormValues>,
required?: boolean,
value?: string,
handleOnChange?: (e: string) => void,
}

const CustomInput: React.FC<IPropTypes> =
Expand All @@ -33,6 +34,8 @@ const CustomInput: React.FC<IPropTypes> =
defaultValue,
register,
validateRules,
value,
handleOnChange,
...inputProps
}) => {
return (
Expand All @@ -49,6 +52,8 @@ const CustomInput: React.FC<IPropTypes> =
defaultValue={defaultValue}
{...register !== undefined && name !== undefined ? {...register(name, validateRules)} : ""}
{...inputProps}
value={value}
onChange={(e) => handleOnChange ? (e.target.value) : undefined}
/>
{/*{error.message && <span className="custom-input__error">{error.message}</span>}*/}
</div>
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/authentication/AuthForm.tsx
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/mapMenu/MapMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const MapMenu: React.FC = observer(() => {
speedFactor={0.05}
backgroundColor="black"
/>
{user?.is_superuser
{!user?.is_superuser
? <SuperUserMap/>
: <EmployeeMap user={user} formattedDate={formattedDate}/>
}
Expand Down
36 changes: 19 additions & 17 deletions frontend/src/components/mapMenu/SuperUserMap/SuperUserMap.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -26,31 +26,33 @@ const SuperUserMap: React.FC<ISuperUserMap> = observer(() => {
mapMenuStore.selectMap(map).then(() => mapMenuStore.changeCurrentMapIndex(indexMap))
}

function handleOnClickChangeIsModalOpen() {
const handleOnClickChangeIsModalOpen = useCallback(() => {
setIsUserListModalOpen(!isUsersListModalOpen)
}

}, [isUsersListModalOpen])

return (
<div>
{isUsersListModalOpen
? <ModalWindow
onClose={handleOnClickChangeIsModalOpen}
body={<UsersListModalBody users={superUserStore.allUsers}/>}
windowContentStyles=""
/>
: ""}
{
isUsersListModalOpen
? <ModalWindow
onClose={handleOnClickChangeIsModalOpen}
body={<UsersListModalBody users={superUserStore.allUsers}/>}
windowContentStyles=""
/>
: ""
}
<CustomButton handleOnClick={handleOnClickChangeIsModalOpen} text="Открыть список сотрудников"/>
<select>
{superUserStore.allUsers.map((user) =>
<option key={user.username} value={user.username}>{user.username}</option>)}
</select>

{/*<select>*/}
{/* {superUserStore.allUsers.map((user) =>*/}
{/* <option key={user.username} value={user.username}>{user.username}</option>)}*/}
{/*</select>*/}

<div className="map-create">
<CustomInput type="text" value={mapMenuStore.newNameMap}
handleOnChange={(e) => mapMenuStore.changeNewMapName(e)}/>
<CustomButton text="Создать новую карту"
handleOnClick={() => mapMenuStore.createMap(mapMenuStore.newNameMap)}/>
<CustomInput type="text" value={mapMenuStore.newNameMap}
handleOnChange={(e) => mapMenuStore.changeNewMapName(e)}/>
</div>

<select className="available-maps">
Expand Down
15 changes: 11 additions & 4 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"lib": [
"ES2020",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"skipLibCheck": true,

"esModuleInterop": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
Expand All @@ -24,5 +27,9 @@
"include": [
"src"
],
"references": [{ "path": "./tsconfig.node.json"}]
"references": [
{
"path": "./tsconfig.node.json"
}
]
}

0 comments on commit 3260f0e

Please sign in to comment.