|
|
@ -1,7 +1,6 @@
|
|
|
|
import { startOfMonth } from 'date-fns';
|
|
|
|
import { startOfMonth } from 'date-fns';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { Controller, useForm } from 'react-hook-form';
|
|
|
|
import { Controller, useForm } from 'react-hook-form';
|
|
|
|
import { CalendarDaysIcon, UserIcon } from '@heroicons/react/24/outline';
|
|
|
|
|
|
|
|
import type { QuestionsQuestionType } from '@prisma/client';
|
|
|
|
import type { QuestionsQuestionType } from '@prisma/client';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
Button,
|
|
|
@ -9,10 +8,10 @@ import {
|
|
|
|
HorizontalDivider,
|
|
|
|
HorizontalDivider,
|
|
|
|
Select,
|
|
|
|
Select,
|
|
|
|
TextArea,
|
|
|
|
TextArea,
|
|
|
|
TextInput,
|
|
|
|
Typeahead,
|
|
|
|
} from '@tih/ui';
|
|
|
|
} from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
|
|
import { QUESTION_TYPES } from '~/utils/questions/constants';
|
|
|
|
import { LOCATIONS, QUESTION_TYPES, ROLES } from '~/utils/questions/constants';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
useFormRegister,
|
|
|
|
useFormRegister,
|
|
|
|
useSelectRegister,
|
|
|
|
useSelectRegister,
|
|
|
@ -83,12 +82,25 @@ export default function ContributeQuestionForm({
|
|
|
|
</h2>
|
|
|
|
</h2>
|
|
|
|
<div className="flex flex-col flex-wrap items-stretch gap-2 sm:flex-row sm:items-end">
|
|
|
|
<div className="flex flex-col flex-wrap items-stretch gap-2 sm:flex-row sm:items-end">
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[300px]">
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[300px]">
|
|
|
|
<TextInput
|
|
|
|
<Controller
|
|
|
|
|
|
|
|
control={control}
|
|
|
|
|
|
|
|
name="location"
|
|
|
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
|
|
|
<Typeahead
|
|
|
|
label="Location"
|
|
|
|
label="Location"
|
|
|
|
|
|
|
|
options={LOCATIONS}
|
|
|
|
required={true}
|
|
|
|
required={true}
|
|
|
|
startAddOn={CalendarDaysIcon}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
startAddOnType="icon"
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
{...register('location')}
|
|
|
|
onSelect={(option) => {
|
|
|
|
|
|
|
|
field.onChange(option.value);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
{...field}
|
|
|
|
|
|
|
|
value={LOCATIONS.find(
|
|
|
|
|
|
|
|
(location) => location.value === field.value,
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[300px]">
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[300px]">
|
|
|
@ -97,10 +109,12 @@ export default function ContributeQuestionForm({
|
|
|
|
name="date"
|
|
|
|
name="date"
|
|
|
|
render={({ field }) => (
|
|
|
|
render={({ field }) => (
|
|
|
|
<MonthYearPicker
|
|
|
|
<MonthYearPicker
|
|
|
|
|
|
|
|
monthRequired={true}
|
|
|
|
value={{
|
|
|
|
value={{
|
|
|
|
month: ((field.value.getMonth() as number) + 1) as Month,
|
|
|
|
month: ((field.value.getMonth() as number) + 1) as Month,
|
|
|
|
year: field.value.getFullYear(),
|
|
|
|
year: field.value.getFullYear(),
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
|
|
|
|
yearRequired={true}
|
|
|
|
onChange={({ month, year }) =>
|
|
|
|
onChange={({ month, year }) =>
|
|
|
|
field.onChange(startOfMonth(new Date(year, month - 1)))
|
|
|
|
field.onChange(startOfMonth(new Date(year, month - 1)))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -124,12 +138,23 @@ export default function ContributeQuestionForm({
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[200px]">
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[200px]">
|
|
|
|
<TextInput
|
|
|
|
<Controller
|
|
|
|
|
|
|
|
control={control}
|
|
|
|
|
|
|
|
name="role"
|
|
|
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
|
|
|
<Typeahead
|
|
|
|
label="Role"
|
|
|
|
label="Role"
|
|
|
|
|
|
|
|
options={ROLES}
|
|
|
|
required={true}
|
|
|
|
required={true}
|
|
|
|
startAddOn={UserIcon}
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
startAddOnType="icon"
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
{...register('role')}
|
|
|
|
onSelect={(option) => {
|
|
|
|
|
|
|
|
field.onChange(option.value);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
{...field}
|
|
|
|
|
|
|
|
value={ROLES.find((role) => role.value === field.value)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|