|
|
|
@ -3,7 +3,14 @@ import { useState } from 'react';
|
|
|
|
|
import { Controller, useForm } from 'react-hook-form';
|
|
|
|
|
import { CalendarDaysIcon, UserIcon } from '@heroicons/react/24/outline';
|
|
|
|
|
import type { QuestionsQuestionType } from '@prisma/client';
|
|
|
|
|
import { Button, CheckboxInput, Select, TextArea, TextInput } from '@tih/ui';
|
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
CheckboxInput,
|
|
|
|
|
HorizontalDivider,
|
|
|
|
|
Select,
|
|
|
|
|
TextArea,
|
|
|
|
|
TextInput,
|
|
|
|
|
} from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
import { QUESTION_TYPES } from '~/utils/questions/constants';
|
|
|
|
|
import {
|
|
|
|
@ -52,17 +59,9 @@ export default function ContributeQuestionForm({
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
|
<form
|
|
|
|
|
className=" flex flex-1 flex-col items-stretch justify-center pb-[50px]"
|
|
|
|
|
className="flex flex-1 flex-col items-stretch justify-center gap-y-4"
|
|
|
|
|
onSubmit={handleSubmit(onSubmit)}>
|
|
|
|
|
<TextArea
|
|
|
|
|
label="Question Prompt"
|
|
|
|
|
placeholder="Contribute a question"
|
|
|
|
|
required={true}
|
|
|
|
|
rows={5}
|
|
|
|
|
{...register('questionContent')}
|
|
|
|
|
/>
|
|
|
|
|
<div className="mt-3 mb-1 flex flex-wrap items-end gap-2">
|
|
|
|
|
<div className="mr-2 min-w-[113px] max-w-[113px] flex-1">
|
|
|
|
|
<div className="min-w-[113px] max-w-[113px] flex-1">
|
|
|
|
|
<Select
|
|
|
|
|
defaultValue="coding"
|
|
|
|
|
label="Type"
|
|
|
|
@ -71,28 +70,35 @@ export default function ContributeQuestionForm({
|
|
|
|
|
{...selectRegister('questionType')}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="min-w-[150px] max-w-[300px] flex-1">
|
|
|
|
|
<Controller
|
|
|
|
|
control={control}
|
|
|
|
|
name="company"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<CompaniesTypeahead
|
|
|
|
|
onSelect={({ id }) => {
|
|
|
|
|
field.onChange(id);
|
|
|
|
|
}}
|
|
|
|
|
<TextArea
|
|
|
|
|
label="Question Prompt"
|
|
|
|
|
placeholder="Contribute a question"
|
|
|
|
|
required={true}
|
|
|
|
|
rows={5}
|
|
|
|
|
{...register('questionContent')}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
<HorizontalDivider />
|
|
|
|
|
<h2 className="text-md text-primary-800 font-semibold">
|
|
|
|
|
Additional information
|
|
|
|
|
</h2>
|
|
|
|
|
<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]">
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Location"
|
|
|
|
|
required={true}
|
|
|
|
|
startAddOn={CalendarDaysIcon}
|
|
|
|
|
startAddOnType="icon"
|
|
|
|
|
{...register('location')}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="min-w-[150px] max-w-[300px] flex-1">
|
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[300px]">
|
|
|
|
|
<Controller
|
|
|
|
|
control={control}
|
|
|
|
|
name="date"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<MonthYearPicker
|
|
|
|
|
value={{
|
|
|
|
|
month: (field.value.getMonth() + 1) as Month,
|
|
|
|
|
month: ((field.value.getMonth() as number) + 1) as Month,
|
|
|
|
|
year: field.value.getFullYear(),
|
|
|
|
|
}}
|
|
|
|
|
onChange={({ month, year }) =>
|
|
|
|
@ -103,17 +109,21 @@ export default function ContributeQuestionForm({
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="justify-left flex flex-wrap items-end gap-2">
|
|
|
|
|
<div className="min-w-[150px] max-w-[300px] flex-1">
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Location"
|
|
|
|
|
required={true}
|
|
|
|
|
startAddOn={CalendarDaysIcon}
|
|
|
|
|
startAddOnType="icon"
|
|
|
|
|
{...register('location')}
|
|
|
|
|
<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]">
|
|
|
|
|
<Controller
|
|
|
|
|
control={control}
|
|
|
|
|
name="company"
|
|
|
|
|
render={({ field }) => (
|
|
|
|
|
<CompaniesTypeahead
|
|
|
|
|
onSelect={({ id }) => {
|
|
|
|
|
field.onChange(id);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="min-w-[150px] max-w-[200px] flex-1">
|
|
|
|
|
<div className="flex-1 sm:min-w-[150px] sm:max-w-[200px]">
|
|
|
|
|
<TextInput
|
|
|
|
|
label="Role"
|
|
|
|
|
required={true}
|
|
|
|
@ -142,8 +152,13 @@ export default function ContributeQuestionForm({
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</div> */}
|
|
|
|
|
<div className="bg-primary-50 fixed bottom-0 left-0 w-full px-4 py-3 sm:flex sm:flex-row sm:justify-between sm:px-6">
|
|
|
|
|
<div className="mb-1 flex">
|
|
|
|
|
<div
|
|
|
|
|
className="bg-primary-50 flex w-full flex-col gap-y-2 py-3 shadow-[0_0_0_100vmax_theme(colors.primary.50)] sm:flex-row sm:justify-between"
|
|
|
|
|
style={{
|
|
|
|
|
// Hack to make the background bleed outside the container
|
|
|
|
|
clipPath: 'inset(0 -100vmax)',
|
|
|
|
|
}}>
|
|
|
|
|
<div className="my-2 flex sm:my-0">
|
|
|
|
|
<CheckboxInput
|
|
|
|
|
label="I have checked that my question is new"
|
|
|
|
|
value={canSubmit}
|
|
|
|
|