Commit cae1eab3 authored by Ermolaev Timur's avatar Ermolaev Timur

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

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