This commit is contained in:
Виталий Лавшонок
2025-12-09 16:24:40 +03:00
parent 46e27616b2
commit 4391114dc3
5 changed files with 114 additions and 127 deletions

View File

@@ -1,7 +1,6 @@
// DateInput.tsx
import React from 'react';
interface DateInputProps {
label?: string;
value?: string;
@@ -10,7 +9,6 @@ onChange: (value: string) => void;
className?: string;
}
const DateInput: React.FC<DateInputProps> = ({
label = 'Дата',
value,
@@ -34,5 +32,4 @@ className="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500
);
};
export default DateInput;

View File

@@ -46,14 +46,12 @@ const ContestEditor = () => {
const now = new Date();
const plus60 = new Date(now.getTime() + 60 * 60 * 1000);
const toLocal = (d: Date) => {
const off = d.getTimezoneOffset();
const local = new Date(d.getTime() - off * 60000);
return local.toISOString().slice(0, 16);
};
const [contest, setContest] = useState<CreateContestBody>({
name: '',
description: '',

View File

@@ -2,7 +2,10 @@ import { useEffect } from 'react';
import { useAppDispatch, useAppSelector } from '../../../redux/hooks';
import { setMenuActivePage } from '../../../redux/slices/store';
import { Navigate, Route, Routes, useParams } from 'react-router-dom';
import { fetchContestById, fetchMyAttemptsInContest } from '../../../redux/slices/contests';
import {
fetchContestById,
fetchMyAttemptsInContest,
} from '../../../redux/slices/contests';
import ContestMissions from './Missions';
import Submissions from './Submissions';

View File

@@ -1,7 +1,4 @@
import {
FilterDropDown,
FilterItem,
} from '../../../components/filters/Filter';
import { FilterDropDown, FilterItem } from '../../../components/filters/Filter';
import { SorterDropDown } from '../../../components/filters/Sorter';
import { SearchInput } from '../../../components/input/SearchInput';

View File

@@ -9,10 +9,12 @@ import {
setContestStatus,
} from '../../../redux/slices/contests';
import { CreateContestBody } from '../../../redux/slices/contests';
import DateRangeInput from '../../../components/input/DateRangeInput';
import { useNavigate } from 'react-router-dom';
import { NumberInput } from '../../../components/input/NumberInput';
import { DropDownList, DropDownListItem } from '../../../components/filters/DropDownList';
import {
DropDownList,
DropDownListItem,
} from '../../../components/filters/DropDownList';
import DateInput from '../../../components/input/DateInput';
import { cn } from '../../../lib/cn';
@@ -42,20 +44,19 @@ const ModalCreateContest: FC<ModalCreateContestProps> = ({
);
const visibilityItems: DropDownListItem[] = [
{ value: "Public", text: "Публичный"},
{ value: "GroupPrivate", text: "Для группы"},
]
{ value: 'Public', text: 'Публичный' },
{ value: 'GroupPrivate', text: 'Для группы' },
];
const scheduleTypeItems: DropDownListItem[] = [
{value: "AlwaysOpen", text: "Всегда открыт"},
{value: "FixedWindow", text: "Фиксированое окно"},
{value: "RollingWindow", text: "Скользящее окно"},
]
{ value: 'AlwaysOpen', text: 'Всегда открыт' },
{ value: 'FixedWindow', text: 'Фиксированое окно' },
{ value: 'RollingWindow', text: 'Скользящее окно' },
];
const now = new Date();
const plus60 = new Date(now.getTime() + 60 * 60 * 1000);
const toLocal = (d: Date) => {
const off = d.getTimezoneOffset();
const local = new Date(d.getTime() - off * 60000);
@@ -105,7 +106,6 @@ return local.toISOString().slice(0, 16);
);
};
return (
<Modal
className="bg-liquid-background border-liquid-lighter border-[2px] p-[25px] rounded-[20px] text-liquid-white"
@@ -136,11 +136,8 @@ return local.toISOString().slice(0, 16);
onChange={(v) => handleChange('description', v)}
/>
<div className="grid grid-cols-2 gap-[10px] mt-[10px]">
<div>
<label className="block text-sm mb-1">
Тип контеста
</label>
@@ -148,13 +145,11 @@ return local.toISOString().slice(0, 16);
<DropDownList
items={scheduleTypeItems}
onChange={(v) => {
handleChange("scheduleType", v);
handleChange('scheduleType', v);
}}
weight='w-full'
weight="w-full"
/>
{/* <select
className="w-full p-2 rounded-md bg-liquid-darker border border-liquid-lighter"
value={form.scheduleType}
@@ -181,9 +176,9 @@ return local.toISOString().slice(0, 16);
<DropDownList
items={visibilityItems}
onChange={(v) => {
handleChange("visibility", v);
handleChange('visibility', v);
}}
weight='w-full'
weight="w-full"
/>
{/* <select
className="w-full p-2 rounded-md bg-liquid-darker border border-liquid-lighter"
@@ -215,12 +210,12 @@ return local.toISOString().slice(0, 16);
<div
className={cn(
' grid grid-flow-row grid-rows-[0fr] opacity-0 transition-all duration-200',
form.visibility == "GroupPrivate" && 'grid-rows-[1fr] opacity-100',
form.visibility == 'GroupPrivate' &&
'grid-rows-[1fr] opacity-100',
)}
>
<div className="overflow-hidden">
<div className='grid grid-cols-2 gap-[10px] mt-[10px]'>
<div className="grid grid-cols-2 gap-[10px] mt-[10px]">
<NumberInput
defaultState={form.groupId ?? 1}
name="groupId"
@@ -228,21 +223,22 @@ return local.toISOString().slice(0, 16);
placeholder="Например: 3"
minValue={1}
maxValue={1000000000000000}
onChange={(v) => handleChange('groupId', Number(v))}
onChange={(v) =>
handleChange('groupId', Number(v))
}
/>
</div></div>
</div>
</div>
</div>
{/* Даты */}
<div
className={cn(
' grid grid-flow-row grid-rows-[0fr] opacity-0 transition-all duration-200',
form.scheduleType != "AlwaysOpen" && 'grid-rows-[1fr] opacity-100',
form.scheduleType != 'AlwaysOpen' &&
'grid-rows-[1fr] opacity-100',
)}
>
<div className="overflow-hidden">
<div className="grid grid-cols-2 gap-[10px] mt-[10px]">
<DateInput
@@ -251,7 +247,6 @@ value={form.startsAt}
onChange={(v) => handleChange('startsAt', v)}
/>
<DateInput
label="Дата окончания"
value={form.endsAt}
@@ -259,7 +254,6 @@ onChange={(v) => handleChange('endsAt', v)}
/>
</div>
</div>
</div>
{/* Продолжительность и лимиты */}
@@ -286,8 +280,6 @@ onChange={(v) => handleChange('endsAt', v)}
/>
</div>
{/* Разрешить раннее завершение */}
{/* <div className="flex items-center gap-[10px] mt-[15px]">
<input