Commit ef153cfe authored by Ermolaev Timur's avatar Ermolaev Timur

#100 небольшие изменения

parent 98c5286f
import {Button} from "@mui/material"; import { Button } from "@mui/material";
import {NavLink} from "react-router-dom"; import { NavLink } from "react-router-dom";
import { superuserMenuButtons } from "../../../constants"; import { superuserMenuButtons } from "../../../constants";
import ProfileBlock from "../ProfileBlock/ProfileBlock"; import ProfileBlock from "../ProfileBlock/ProfileBlock";
const AdminMenu = () => { const AdminMenu = () => {
return <> return <>
{superuserMenuButtons.map((button, i)=>{ {superuserMenuButtons.map((button, i) => {
return( return (
<Button <Button
key={i} key={i}
component={NavLink} component={NavLink}
...@@ -19,7 +19,7 @@ const AdminMenu = () => { ...@@ -19,7 +19,7 @@ const AdminMenu = () => {
</Button> </Button>
) )
})} })}
<ProfileBlock/> <ProfileBlock />
</> </>
}; };
......
import {Button} from "@mui/material"; import { Button } from "@mui/material";
import {NavLink} from "react-router-dom"; import { NavLink } from "react-router-dom";
import { anonymoysMenuButtons } from "../../../constants"; import { anonymoysMenuButtons } from "../../../constants";
const AnonymousMenu = () => { const AnonymousMenu = () => {
return <> return <>
{anonymoysMenuButtons.map((button, i)=>{ {anonymoysMenuButtons.map((button, i) => {
return( return (
<Button <Button
key={i} key={i}
component={NavLink} component={NavLink}
......
import {Button} from "@mui/material"; import { Button } from "@mui/material";
import {NavLink} from "react-router-dom"; import { NavLink } from "react-router-dom";
import { workerMenuButtons } from "../../../constants"; import { workerMenuButtons } from "../../../constants";
import ProfileBlock from "../ProfileBlock/ProfileBlock"; import ProfileBlock from "../ProfileBlock/ProfileBlock";
const WorkerMenu = () => { const WorkerMenu = () => {
return <> return <>
{workerMenuButtons.map((button, i)=>{ {workerMenuButtons.map((button, i) => {
return( return (
<Button <Button
key={i} key={i}
component={NavLink} component={NavLink}
...@@ -20,7 +20,7 @@ const WorkerMenu = () => { ...@@ -20,7 +20,7 @@ const WorkerMenu = () => {
) )
})} })}
<ProfileBlock/> <ProfileBlock />
</> </>
}; };
......
import { Button, TextField } from "@mui/material"; import { Button, TextField } from "@mui/material";
import { memo } from "react"; import { memo } from "react";
import { priorities } from "../../../constants";
import CustomSelect from '../../UI/СustomSelect/СustomSelect' import CustomSelect from '../../UI/СustomSelect/СustomSelect'
const priorities = [{ value: null, text: '--Приоритет--' }, { value: 'A', text: 'A' }, { value: 'B', text: 'B' }, { value: 'C', text: 'C' }]
function MonthCalendarModalContent({ title, onChangeCurrentTaskHandler, description, priority, sendNewTaskHandler, deleteTaskHandler, startHour, endHour }) { function MonthCalendarModalContent({ title, onChangeCurrentTaskHandler, description, priority, sendNewTaskHandler, deleteTaskHandler, startHour, endHour }) {
return (<> return (<>
......
import {AppBar, Box, Toolbar, Typography} from "@mui/material"; import { AppBar, Box, Toolbar, Typography } from "@mui/material";
import {NavLink} from "react-router-dom"; import { NavLink } from "react-router-dom";
import {useSelector} from "react-redux"; import { useSelector } from "react-redux";
import HasAccess from "../HasAccess/HasAccess"; import HasAccess from "../HasAccess/HasAccess";
import AnonymousMenu from "../../Menus/AnonymousMenu/AnonymousMenu"; import AnonymousMenu from "../../Menus/AnonymousMenu/AnonymousMenu";
import WorkerMenu from "../../Menus/WorkerMenu/WorkerMenu"; import WorkerMenu from "../../Menus/WorkerMenu/WorkerMenu";
...@@ -17,17 +17,17 @@ const AppToolbar = () => { ...@@ -17,17 +17,17 @@ const AppToolbar = () => {
component="div" component="div"
sx={{ flexGrow: 1 }}> sx={{ flexGrow: 1 }}>
<NavLink to='/' style={{textDecoration: 'none', color: 'inherit'}}>Task Manager</NavLink> <NavLink to='/' style={{ textDecoration: 'none', color: 'inherit' }}>Task Manager</NavLink>
</Typography> </Typography>
<HasAccess allowed={!user}> <HasAccess allowed={!user}>
<AnonymousMenu/> <AnonymousMenu />
</HasAccess> </HasAccess>
<HasAccess roles={['user']}> <HasAccess roles={['user']}>
<WorkerMenu/> <WorkerMenu />
</HasAccess> </HasAccess>
<HasAccess roles={['superuser']}> <HasAccess roles={['superuser']}>
<AdminMenu/> <AdminMenu />
</HasAccess> </HasAccess>
</Toolbar> </Toolbar>
</AppBar> </AppBar>
......
import { FormControl, InputLabel, MenuItem, Select} from '@mui/material'; import { FormControl, InputLabel, MenuItem, Select } from '@mui/material';
import { memo } from 'react'; import { memo } from 'react';
function СustomSelect({value, onChange, label, variant='standard', items, id, defaultValue, name}) { function СustomSelect({ value, onChange, label, variant = 'standard', items, id, defaultValue, name }) {
return ( return (
<> <>
...@@ -16,7 +16,7 @@ function СustomSelect({value, onChange, label, variant='standard', items, id, ...@@ -16,7 +16,7 @@ function СustomSelect({value, onChange, label, variant='standard', items, id,
name={name} name={name}
defaultValue={defaultValue} defaultValue={defaultValue}
> >
{items.map((item, i)=>{ {items.map((item, i) => {
return ( return (
<MenuItem <MenuItem
key={i} key={i}
...@@ -26,11 +26,11 @@ function СustomSelect({value, onChange, label, variant='standard', items, id, ...@@ -26,11 +26,11 @@ function СustomSelect({value, onChange, label, variant='standard', items, id,
})} })}
</Select> </Select>
</FormControl> </FormControl>
</> ); </>);
} }
export default memo(СustomSelect, (prevProps, nextProps)=>{ export default memo(СustomSelect, (prevProps, nextProps) => {
if(prevProps.value !== nextProps.value) { if (prevProps.value !== nextProps.value) {
return false return false
} else { } else {
return true return true
......
...@@ -2,8 +2,8 @@ import { useMemo } from "react"; ...@@ -2,8 +2,8 @@ import { useMemo } from "react";
import { getHoursInDayNumbers, getAvailableTasks, getLinesInDay, getSortedTasks } from "../../../../helpers/CalendarHelpers"; import { getHoursInDayNumbers, getAvailableTasks, getLinesInDay, getSortedTasks } from "../../../../helpers/CalendarHelpers";
import CalendarStandartCell from "../../../MonthCalendar/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell"; import CalendarStandartCell from "../../../MonthCalendar/MonthCalendarBody/CalendarStandartCell.js/CalendarStandartCell";
function CalendarRowDayWeek({hoursInDay, tasks, month, year, day, hourFormat}) { function CalendarRowDayWeek({ hoursInDay, tasks, month, year, day, hourFormat }) {
const hours = useMemo(()=>{ const hours = useMemo(() => {
return getHoursInDayNumbers(hoursInDay) return getHoursInDayNumbers(hoursInDay)
}, [hoursInDay]) }, [hoursInDay])
...@@ -18,7 +18,7 @@ function CalendarRowDayWeek({hoursInDay, tasks, month, year, day, hourFormat}) { ...@@ -18,7 +18,7 @@ function CalendarRowDayWeek({hoursInDay, tasks, month, year, day, hourFormat}) {
const linesInDay = useMemo(() => { const linesInDay = useMemo(() => {
return getLinesInDay(availableTasks, sortedTasks, hoursInDay, hours, hourFormat) return getLinesInDay(availableTasks, sortedTasks, hoursInDay, hours, hourFormat)
}, [availableTasks, hourFormat, hours, hoursInDay, sortedTasks]) }, [availableTasks, hourFormat, hours, hoursInDay, sortedTasks])
console.log(linesInDay)
return (<> return (<>
{hoursInDay?.map((hour, i) => { {hoursInDay?.map((hour, i) => {
return ( return (
......
...@@ -3,21 +3,28 @@ export const uploadsUrl = `${apiUrl}/uploads`; ...@@ -3,21 +3,28 @@ export const uploadsUrl = `${apiUrl}/uploads`;
export const workerMenuButtons = [ export const workerMenuButtons = [
{text: 'Проекты', path: '/projects'}, { text: 'Проекты', path: '/projects' },
{text: 'Неделя', path: '/week'}, { text: 'Неделя', path: '/week' },
{text: 'Месяц', path: '/month'}, { text: 'Месяц', path: '/month' },
{text: 'Мои задачи', path: '/my-tasks'} { text: 'Мои задачи', path: '/my-tasks' }
] ]
export const superuserMenuButtons = [ export const superuserMenuButtons = [
{text: 'Проекты', path: '/projects'}, { text: 'Проекты', path: '/projects' },
{text: 'Неделя', path: '/week'}, { text: 'Неделя', path: '/week' },
{text: 'Месяц', path: '/month'}, { text: 'Месяц', path: '/month' },
{text: 'Мои задачи', path: '/my-tasks'}, { text: 'Мои задачи', path: '/my-tasks' },
{text: 'Задачи Сотрудников', path: '/workers-tasks'}, { text: 'Задачи Сотрудников', path: '/workers-tasks' },
{text: 'Создать Сотрудника', path: '/sign-up'} { text: 'Создать Сотрудника', path: '/sign-up' }
] ]
export const anonymoysMenuButtons = [ export const anonymoysMenuButtons = [
{text: 'Вход', path: '/sign-in'}, { text: 'Вход', path: '/sign-in' },
]
export const priorities = [
{ value: null, text: '--Приоритет--' },
{ value: 'A', text: 'A' },
{ value: 'B', text: 'B' },
{ value: 'C', text: 'C' }
] ]
\ No newline at end of file
import {getDaysInMonth, getCurrentMonthString, dateToISOLikeButLocal} from '../helpers/CalendarHelpers'; import {getDaysInMonth, getCurrentMonthString, dateToISOLikeButLocal, getAvailableTasks, getSortedTasks} from '../helpers/CalendarHelpers';
import {getAvailableTasks, getSortedTasks} from '../components/MonthCalendar/MonthCalendarBody/CalendarRowDay/Helpers'
describe('Получение дней в феврале 2022', () => { describe('Получение дней в феврале 2022', () => {
test('Всего дней', () => { test('Всего дней', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment