|
|
@ -2,7 +2,6 @@ import { startOfMonth } from 'date-fns';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { useState } from 'react';
|
|
|
|
import { Button } from '@tih/ui';
|
|
|
|
import { Button } from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
|
|
import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead';
|
|
|
|
|
|
|
|
import type { Month } from '~/components/shared/MonthYearPicker';
|
|
|
|
import type { Month } from '~/components/shared/MonthYearPicker';
|
|
|
|
import MonthYearPicker from '~/components/shared/MonthYearPicker';
|
|
|
|
import MonthYearPicker from '~/components/shared/MonthYearPicker';
|
|
|
|
|
|
|
|
|
|
|
@ -36,115 +35,113 @@ export default function CreateQuestionEncounterForm({
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
<Button
|
|
|
|
<p className="font-md text-md text-slate-600">I saw this question at</p>
|
|
|
|
label="Cancel"
|
|
|
|
{step === 0 && (
|
|
|
|
variant="tertiary"
|
|
|
|
<div>
|
|
|
|
onClick={(event) => {
|
|
|
|
<CompanyTypeahead
|
|
|
|
event.preventDefault();
|
|
|
|
placeholder="Other company"
|
|
|
|
onCancel();
|
|
|
|
suggestedCount={3}
|
|
|
|
}}
|
|
|
|
onSuggestionClick={({ value: company }) => {
|
|
|
|
/>
|
|
|
|
setSelectedCompany(company);
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
setStep(step + 1);
|
|
|
|
<p className="font-md text-md text-slate-600">I saw this question at</p>
|
|
|
|
|
|
|
|
{step === 0 && (
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<CompanyTypeahead
|
|
|
|
|
|
|
|
placeholder="Other company"
|
|
|
|
|
|
|
|
suggestedCount={3}
|
|
|
|
|
|
|
|
onSuggestionClick={({ value: company }) => {
|
|
|
|
|
|
|
|
setSelectedCompany(company);
|
|
|
|
|
|
|
|
setStep(step + 1);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
isLabelHidden={true}
|
|
|
|
|
|
|
|
onSelect={({ value: company }) => {
|
|
|
|
|
|
|
|
setSelectedCompany(company);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{step === 1 && (
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<LocationTypeahead
|
|
|
|
|
|
|
|
suggestedCount={3}
|
|
|
|
|
|
|
|
onSuggestionClick={({ value: location }) => {
|
|
|
|
|
|
|
|
setSelectedLocation(location);
|
|
|
|
|
|
|
|
setStep(step + 1);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
isLabelHidden={true}
|
|
|
|
|
|
|
|
placeholder="Other location"
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
|
|
|
|
onSelect={({ value: location }) => {
|
|
|
|
|
|
|
|
setSelectedLocation(location);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{step === 2 && (
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<RoleTypeahead
|
|
|
|
|
|
|
|
isLabelHidden={true}
|
|
|
|
|
|
|
|
suggestedCount={3}
|
|
|
|
|
|
|
|
onSuggestionClick={({ value: role }) => {
|
|
|
|
|
|
|
|
setSelectedRole(role);
|
|
|
|
|
|
|
|
setStep(step + 1);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
placeholder="Other role"
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
|
|
|
|
onSelect={({ value: role }) => {
|
|
|
|
|
|
|
|
setSelectedRole(role);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{step === 3 && (
|
|
|
|
|
|
|
|
<MonthYearPicker
|
|
|
|
|
|
|
|
yearLabel={''}
|
|
|
|
|
|
|
|
monthLabel={''}
|
|
|
|
|
|
|
|
value={{
|
|
|
|
|
|
|
|
month: ((selectedDate?.getMonth() ?? 0) + 1) as Month,
|
|
|
|
|
|
|
|
year: selectedDate?.getFullYear() as number,
|
|
|
|
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onChange={(value) => {
|
|
|
|
isLabelHidden={true}
|
|
|
|
setSelectedDate(
|
|
|
|
onSelect={({ value: company }) => {
|
|
|
|
startOfMonth(new Date(value.year, value.month - 1)),
|
|
|
|
setSelectedCompany(company);
|
|
|
|
);
|
|
|
|
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
{step < 3 && (
|
|
|
|
)}
|
|
|
|
<Button
|
|
|
|
{step === 1 && (
|
|
|
|
label="Next"
|
|
|
|
<div>
|
|
|
|
variant="primary"
|
|
|
|
<LocationTypeahead
|
|
|
|
onClick={() => {
|
|
|
|
suggestedCount={3}
|
|
|
|
|
|
|
|
onSuggestionClick={({ value: location }) => {
|
|
|
|
|
|
|
|
setSelectedLocation(location);
|
|
|
|
setStep(step + 1);
|
|
|
|
setStep(step + 1);
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
|
|
|
|
isLabelHidden={true}
|
|
|
|
|
|
|
|
placeholder="Other location"
|
|
|
|
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
|
|
|
|
onSelect={({ value: location }) => {
|
|
|
|
|
|
|
|
setSelectedLocation(location);
|
|
|
|
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
{step === 3 && (
|
|
|
|
)}
|
|
|
|
<Button
|
|
|
|
{step === 2 && (
|
|
|
|
label="Submit"
|
|
|
|
<div>
|
|
|
|
variant="primary"
|
|
|
|
<RoleTypeahead
|
|
|
|
onClick={() => {
|
|
|
|
isLabelHidden={true}
|
|
|
|
if (
|
|
|
|
suggestedCount={3}
|
|
|
|
selectedCompany &&
|
|
|
|
onSuggestionClick={({ value: role }) => {
|
|
|
|
selectedLocation &&
|
|
|
|
setSelectedRole(role);
|
|
|
|
selectedRole &&
|
|
|
|
setStep(step + 1);
|
|
|
|
selectedDate
|
|
|
|
}}
|
|
|
|
) {
|
|
|
|
placeholder="Other role"
|
|
|
|
onSubmit({
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
|
|
company: selectedCompany,
|
|
|
|
onQueryChange={() => {}}
|
|
|
|
location: selectedLocation,
|
|
|
|
onSelect={({ value: role }) => {
|
|
|
|
role: selectedRole,
|
|
|
|
setSelectedRole(role);
|
|
|
|
seenAt: selectedDate,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{step === 3 && (
|
|
|
|
|
|
|
|
<MonthYearPicker
|
|
|
|
|
|
|
|
yearLabel={''}
|
|
|
|
|
|
|
|
monthLabel={''}
|
|
|
|
|
|
|
|
value={{
|
|
|
|
|
|
|
|
month: ((selectedDate?.getMonth() ?? 0) + 1) as Month,
|
|
|
|
|
|
|
|
year: selectedDate?.getFullYear() as number,
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
onChange={(value) => {
|
|
|
|
|
|
|
|
setSelectedDate(
|
|
|
|
|
|
|
|
startOfMonth(new Date(value.year, value.month - 1)),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{step < 3 && (
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
label="Next"
|
|
|
|
|
|
|
|
variant="primary"
|
|
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
|
|
setStep(step + 1);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{step === 3 && (
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
label="Submit"
|
|
|
|
|
|
|
|
variant="primary"
|
|
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
selectedCompany &&
|
|
|
|
|
|
|
|
selectedLocation &&
|
|
|
|
|
|
|
|
selectedRole &&
|
|
|
|
|
|
|
|
selectedDate
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
onSubmit({
|
|
|
|
|
|
|
|
company: selectedCompany,
|
|
|
|
|
|
|
|
location: selectedLocation,
|
|
|
|
|
|
|
|
role: selectedRole,
|
|
|
|
|
|
|
|
seenAt: selectedDate,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
label="Cancel"
|
|
|
|
|
|
|
|
variant="tertiary"
|
|
|
|
|
|
|
|
onClick={(event) => {
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
onCancel();
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|