contest update form fix
This commit is contained in:
@@ -27,6 +27,16 @@ interface Mission {
|
|||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toUtc(localDateTime?: string): string {
|
||||||
|
if (!localDateTime) return '';
|
||||||
|
|
||||||
|
// Создаём дату (она автоматически считается как локальная)
|
||||||
|
const date = new Date(localDateTime);
|
||||||
|
|
||||||
|
// Возвращаем ISO-строку с 'Z' (всегда в UTC)
|
||||||
|
return date.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Страница создания / редактирования контеста
|
* Страница создания / редактирования контеста
|
||||||
*/
|
*/
|
||||||
@@ -117,7 +127,14 @@ const ContestEditor = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateContest = () => {
|
const handleUpdateContest = () => {
|
||||||
dispatch(updateContest({ ...contest, contestId }));
|
dispatch(
|
||||||
|
updateContest({
|
||||||
|
...contest,
|
||||||
|
endsAt: toUtc(contest.endsAt),
|
||||||
|
startsAt: toUtc(contest.startsAt),
|
||||||
|
contestId,
|
||||||
|
}),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteContest = () => {
|
const handleDeleteContest = () => {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ const EditContestItem: React.FC<EditContestItemProps> = ({
|
|||||||
: 'grid-cols-[1fr,150px,190px,110px,130px]',
|
: 'grid-cols-[1fr,150px,190px,110px,130px]',
|
||||||
)}
|
)}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (!started) {
|
if (!started && username != myname) {
|
||||||
toastWarning('Контест еще не начался');
|
toastWarning('Контест еще не начался');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,10 @@ import {
|
|||||||
setGroupsStatus,
|
setGroupsStatus,
|
||||||
} from '../../../../redux/slices/groups';
|
} from '../../../../redux/slices/groups';
|
||||||
import ConfirmModal from '../../../../components/modal/ConfirmModal';
|
import ConfirmModal from '../../../../components/modal/ConfirmModal';
|
||||||
import { DropDownList } from '../../../../components/filters/DropDownList';
|
import {
|
||||||
|
DropDownList,
|
||||||
|
DropDownListItem,
|
||||||
|
} from '../../../../components/filters/DropDownList';
|
||||||
import { ReverseButton } from '../../../../components/button/ReverseButton';
|
import { ReverseButton } from '../../../../components/button/ReverseButton';
|
||||||
|
|
||||||
interface ModalUpdateProps {
|
interface ModalUpdateProps {
|
||||||
@@ -79,11 +82,20 @@ const ModalUpdate: FC<ModalUpdateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [user]);
|
}, [user]);
|
||||||
|
|
||||||
const roles = [
|
const roles: DropDownListItem[] = [
|
||||||
'Member',
|
{ value: 'Member', text: 'Участник' },
|
||||||
'Administrator',
|
{ value: 'Administrator', text: 'Администратор' },
|
||||||
...(adminUser?.role.includes('Creator') ? ['Creator'] : []),
|
|
||||||
];
|
];
|
||||||
|
if (adminUser?.role.includes('Creator')) {
|
||||||
|
roles.push({ value: 'Creator', text: 'Владелец' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const casrtRoleMap: Record<'Member' | 'Administrator' | 'Creator', string> =
|
||||||
|
{
|
||||||
|
Member: 'Участник',
|
||||||
|
Administrator: 'Администратор',
|
||||||
|
Creator: 'Владелец',
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -100,15 +112,21 @@ const ModalUpdate: FC<ModalUpdateProps> = ({
|
|||||||
"{groupName}" #{groupId}
|
"{groupName}" #{groupId}
|
||||||
</div>
|
</div>
|
||||||
<div className="my-[5px]">Пользователь: {user?.username}</div>
|
<div className="my-[5px]">Пользователь: {user?.username}</div>
|
||||||
<div>Текущая роль: {user?.role}</div>
|
<div>
|
||||||
|
Текущая роль:{' '}
|
||||||
|
{casrtRoleMap[user?.role as keyof typeof casrtRoleMap]}
|
||||||
|
</div>
|
||||||
<div className="flex flex-row w-full items-center justify-between mt-[20px] gap-[20px]">
|
<div className="flex flex-row w-full items-center justify-between mt-[20px] gap-[20px]">
|
||||||
<div>
|
<div>
|
||||||
<DropDownList
|
<DropDownList
|
||||||
defaultState={{ value: userRole, text: userRole }}
|
defaultState={{
|
||||||
|
value: userRole,
|
||||||
|
text: casrtRoleMap[
|
||||||
|
userRole as keyof typeof casrtRoleMap
|
||||||
|
],
|
||||||
|
}}
|
||||||
weight="w-[230px]"
|
weight="w-[230px]"
|
||||||
items={roles.map((v) => {
|
items={roles}
|
||||||
return { text: v, value: v };
|
|
||||||
})}
|
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
setUserRole(v);
|
setUserRole(v);
|
||||||
}}
|
}}
|
||||||
|
|||||||
Reference in New Issue
Block a user