Commit cae1eab3 authored by Ermolaev Timur's avatar Ermolaev Timur

#149 Добавил валидации для полей если ты не автор

parent fe5adeb6
...@@ -14,13 +14,12 @@ const StyledTooltip = styled(({ className, ...props }) => ( ...@@ -14,13 +14,12 @@ const StyledTooltip = styled(({ className, ...props }) => (
} }
`; `;
function EditRow({ buttons, dateTimeTasks, onChangeCurrentTaskHandler, currentTask, allUserProjectsForModalTask, onDateChangeEditHandler, user }) { function EditRow({ buttons, dateTimeTasks, onChangeCurrentTaskHandler, currentTask, allUserProjectsForModalTask, onDateChangeEditHandler, user }) {
const workers = useMemo(() => { const workers = useMemo(() => {
if (currentTask?.project) { if (currentTask?.project) {
currentTask.project = allUserProjectsForModalTask.find((project) => project?.value?.id === currentTask?.project?.id)?.value currentTask.project = allUserProjectsForModalTask.find((project) => project?.value?.id === currentTask?.project?.id)?.value
const arrUsers = currentTask?.project?.members.map((member) => { return { value: member.user, text: member.user.displayName } }) const arrUsers = currentTask?.project?.members.map((member) => { return { value: member.user, text: member.user.displayName } })
arrUsers.push({value: null, text: 'Никто'}) arrUsers.push({ value: null, text: 'Никто' })
return arrUsers return arrUsers
} else { } else {
return [{ value: '', text: 'Выберите проект' }] return [{ value: '', text: 'Выберите проект' }]
...@@ -30,66 +29,74 @@ function EditRow({ buttons, dateTimeTasks, onChangeCurrentTaskHandler, currentTa ...@@ -30,66 +29,74 @@ function EditRow({ buttons, dateTimeTasks, onChangeCurrentTaskHandler, currentTa
return ( return (
<> <>
<TableCell sx={{ width: '4%' }}> <TableCell sx={{ width: '4%' }}>
<CustomSelect {user.id === currentTask.author.id ?
defaultValue={priorities[0]?.value} <CustomSelect
value={currentTask.priority} defaultValue={priorities[0]?.value}
name={'priority'} value={currentTask.priority}
variant={'outlined'} name={'priority'}
onChange={onChangeCurrentTaskHandler} variant={'outlined'}
id={'priority-type'} onChange={onChangeCurrentTaskHandler}
items={priorities} id={'priority-type'}
sx={{ width: '100%' }} items={priorities}
/> sx={{ width: '100%' }}
/>
: currentTask.priority}
</TableCell> </TableCell>
<TableCell sx={{ width: '10%' }}>{moment(currentTask.createdAt).format('DD.MM.YYYY')}</TableCell> <TableCell sx={{ width: '10%' }}>{moment(currentTask.createdAt).format('DD.MM.YYYY')}</TableCell>
<Tooltip title={currentTask.description}> <Tooltip title={currentTask.description}>
<TableCell sx={{ width: '25%', overflow: 'hidden', textOverflow: 'ellipsis' }}> <TableCell sx={{ width: '25%', overflow: 'hidden', textOverflow: 'ellipsis' }}>
<StyledTooltip {user.id === currentTask.author.id ?
title={<TextField <StyledTooltip
id="task-description" title={<TextField
value={currentTask.description} id="task-description"
variant="outlined" value={currentTask.description}
name='description' variant="outlined"
placeholder='Описание' name='description'
sx={{ width: '300px' }} placeholder='Описание'
onChange={onChangeCurrentTaskHandler} sx={{ width: '300px' }}
multiline onChange={onChangeCurrentTaskHandler}
rows={5} multiline
rows={5}
/>}> />}>
<TextField <TextField
id="task-title" id="task-title"
value={currentTask.title} value={currentTask.title}
variant="outlined" variant="outlined"
name='title' name='title'
onChange={onChangeCurrentTaskHandler} onChange={onChangeCurrentTaskHandler}
sx={{ width: '90%' }} sx={{ width: '90%' }}
/> />
</StyledTooltip> </StyledTooltip>
: currentTask.title}
</TableCell> </TableCell>
</Tooltip> </Tooltip>
<TableCell sx={{ width: '10%' }}> <TableCell sx={{ width: '10%' }}>
<CustomSelect {user.id === currentTask.author.id ?
value={currentTask.project} <CustomSelect
name={'project'} value={currentTask.project}
variant={'outlined'} name={'project'}
onChange={onChangeCurrentTaskHandler} variant={'outlined'}
id={'project'} onChange={onChangeCurrentTaskHandler}
items={allUserProjectsForModalTask} id={'project'}
sx={{ width: '100%' }} items={allUserProjectsForModalTask}
/> sx={{ width: '100%' }}
/>
: currentTask.projectTitle}
</TableCell> </TableCell>
<TableCell sx={{ width: '8%' }}> <TableCell sx={{ width: '8%' }}>
<CustomSelect {user.id === currentTask.author.id ?
value={currentTask.executor} <CustomSelect
name={'executor'} value={currentTask.executor}
variant={'outlined'} name={'executor'}
onChange={onChangeCurrentTaskHandler} variant={'outlined'}
id={'executor'} onChange={onChangeCurrentTaskHandler}
items={workers} id={'executor'}
sx={{ width: '100%' }} items={workers}
/> sx={{ width: '100%' }}
/>
: currentTask.executorName}
</TableCell> </TableCell>
<TableCell sx={{ width: '8%' }}>{currentTask.authorName}</TableCell> <TableCell sx={{ width: '8%' }}>{currentTask.authorName}</TableCell>
...@@ -98,11 +105,13 @@ function EditRow({ buttons, dateTimeTasks, onChangeCurrentTaskHandler, currentTa ...@@ -98,11 +105,13 @@ function EditRow({ buttons, dateTimeTasks, onChangeCurrentTaskHandler, currentTa
</TableCell> </TableCell>
<TableCell sx={{ width: '10%' }}> <TableCell sx={{ width: '10%' }}>
<MaterialUIPickers {user.id === currentTask.author.id ?
task={currentTask} <MaterialUIPickers
name="dateTimeDeadLine" task={currentTask}
onChange={onDateChangeEditHandler} name="dateTimeDeadLine"
/> onChange={onDateChangeEditHandler}
/>
: currentTask.dateTimeDeadLine ? moment(currentTask.dateTimeDeadLine).utc().format('DD.MM.YYYY HH:MM') : null}
</TableCell> </TableCell>
<TableCell sx={{ width: '7%' }}> <TableCell sx={{ width: '7%' }}>
<CustomSelect <CustomSelect
......
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