diff --git a/src/components/input/DateInput.tsx b/src/components/input/DateInput.tsx new file mode 100644 index 0000000..fea3053 --- /dev/null +++ b/src/components/input/DateInput.tsx @@ -0,0 +1,38 @@ +// DateInput.tsx +import React from 'react'; + + +interface DateInputProps { +label?: string; +value?: string; +defaultValue?: string; +onChange: (value: string) => void; +className?: string; +} + + +const DateInput: React.FC = ({ +label = 'Дата', +value, +defaultValue, +onChange, +className = '', +}) => { +return ( +
+ + onChange(e.target.value)} +className="mt-1 block w-full rounded-md border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm" +/> +
+); +}; + + +export default DateInput; \ No newline at end of file diff --git a/src/views/home/contests/ModalCreate.tsx b/src/views/home/contests/ModalCreate.tsx index 8eabd37..625c2eb 100644 --- a/src/views/home/contests/ModalCreate.tsx +++ b/src/views/home/contests/ModalCreate.tsx @@ -12,7 +12,9 @@ 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 { DropDownListItem } from '../../../components/filters/DropDownList'; +import { DropDownList, DropDownListItem } from '../../../components/filters/DropDownList'; +import DateInput from '../../../components/input/DateInput'; +import { cn } from '../../../lib/cn'; function toUtc(localDateTime?: string): string { if (!localDateTime) return ''; @@ -39,21 +41,36 @@ const ModalCreateContest: FC = ({ (state) => state.contests.createContest.status, ); - const scheduleTypeItems: DropDownListItem[] = [ - {value: "", text: ""}, - {value: "", text: ""}, - {value: "", text: ""}, + const visibilityItems: DropDownListItem[] = [ + { value: "Public", text: "Публичный"}, + { value: "GroupPrivate", text: "Для группы"}, ] + + const scheduleTypeItems: DropDownListItem[] = [ + {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); +return local.toISOString().slice(0, 16); +}; const [form, setForm] = useState({ name: '', description: '', scheduleType: 'AlwaysOpen', visibility: 'Public', - startsAt: '', - endsAt: '', - attemptDurationMinutes: 0, - maxAttempts: 0, + startsAt: toLocal(now), + endsAt: toLocal(plus60), + attemptDurationMinutes: 60, + maxAttempts: 1, allowEarlyFinish: false, missionIds: [], articleIds: [], @@ -88,6 +105,7 @@ const ModalCreateContest: FC = ({ ); }; + return ( = ({
- @@ -144,12 +173,19 @@ const ModalCreateContest: FC = ({ - + */}
- @@ -162,38 +198,85 @@ const ModalCreateContest: FC = ({ > - + */}
{/* Даты начала и конца */} -
+ {/*
-
+
*/} + +
+ +
+
+ handleChange('groupId', Number(v))} + /> + +
+ +
+ +{/* Даты */} +
+ handleChange('startsAt', v)} +/> + + + handleChange('endsAt', v)} +/> +
{/* Продолжительность и лимиты */}
handleChange('attemptDurationMinutes', Number(v)) } /> handleChange('maxAttempts', Number(v))} />
+ + {/* Разрешить раннее завершение */} {/*