From 2e0f218d28cd1e9f3f68b50757b0f18e14cc7fb5 Mon Sep 17 00:00:00 2001 From: Ai Ling Date: Wed, 2 Nov 2022 19:55:08 +0800 Subject: [PATCH] [offers][feat] Use city typeahead for location field --- .../portal/src/components/offers/constants.ts | 74 +++++++ .../offersSubmission/OffersSubmissionForm.tsx | 51 +++++ .../submissionForm/BackgroundForm.tsx | 17 ++ .../submissionForm/OfferDetailsForm.tsx | 189 ++++++++++++++++++ apps/portal/src/components/offers/types.ts | 3 + 5 files changed, 334 insertions(+) diff --git a/apps/portal/src/components/offers/constants.ts b/apps/portal/src/components/offers/constants.ts index e84dfd4e..ceb3c3e7 100644 --- a/apps/portal/src/components/offers/constants.ts +++ b/apps/portal/src/components/offers/constants.ts @@ -5,10 +5,84 @@ export const JobTypeLabel = { INTERN: 'Internship', }; +<<<<<<< HEAD export const emptyOption = { label: '', value: '', }; +======= +export const internshipCycleOptions = [ + { + label: 'Summer', + value: 'Summer', + }, + { + label: 'Winter', + value: 'Winter', + }, + { + label: 'Spring', + value: 'Spring', + }, + { + label: 'Fall', + value: 'Fall', + }, + { + label: 'Full year', + value: 'Full year', + }, +]; + +export const yearOptions = [ + { + label: '2021', + value: 2021, + }, + { + label: '2022', + value: 2022, + }, + { + label: '2023', + value: 2023, + }, + { + label: '2024', + value: 2024, + }, +]; + +export const educationLevelOptions = Object.entries( + EducationBackgroundType, +).map(([, value]) => ({ + label: value, + value, +})); + +export const educationFieldOptions = [ + { + label: 'Computer Science', + value: 'Computer Science', + }, + { + label: 'Information Security', + value: 'Information Security', + }, + { + label: 'Information Systems', + value: 'Information Systems', + }, + { + label: 'Business Analytics', + value: 'Business Analytics', + }, + { + label: 'Data Science and Analytics', + value: 'Data Science and Analytics', + }, +]; +>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) export enum FieldError { NON_NEGATIVE_NUMBER = 'Please fill in a non-negative number in this field.', diff --git a/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx b/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx index a03782dd..313fedfd 100644 --- a/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx +++ b/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx @@ -289,6 +289,7 @@ export default function OffersSubmissionForm({ steps={breadcrumbSteps} /> +<<<<<<< HEAD
+======= + + + {steps[step]} +
{JSON.stringify(formMethods.watch(), null, 2)}
+ {step === 0 && ( +
+
+ )} + {step === 1 && ( +
+
+ )} + +
+>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) diff --git a/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx b/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx index d2cef0a7..24d2ec86 100644 --- a/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx +++ b/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx @@ -2,7 +2,16 @@ import { useFormContext, useWatch } from 'react-hook-form'; import { JobType } from '@prisma/client'; import { Collapsible, RadioList } from '@tih/ui'; +<<<<<<< HEAD import { FieldError } from '~/components/offers/constants'; +======= +import { + educationFieldOptions, + educationLevelOptions, + emptyOption, + FieldError, +} from '~/components/offers/constants'; +>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) import type { BackgroundPostData } from '~/components/offers/types'; import CitiesTypeahead from '~/components/shared/CitiesTypeahead'; import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead'; @@ -255,6 +264,7 @@ function InternshipJobFields() { }} /> +<<<<<<< HEAD
+======= + +
+>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) >>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) />
diff --git a/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx b/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx index 1fc38fe2..22bef95a 100644 --- a/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx +++ b/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx @@ -22,7 +22,16 @@ import { defaultFullTimeOfferValues, defaultInternshipOfferValues, } from '../OffersSubmissionForm'; +<<<<<<< HEAD import { FieldError, JobTypeLabel } from '../../constants'; +======= +import { + emptyOption, + FieldError, + internshipCycleOptions, + yearOptions, +} from '../../constants'; +>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) import FormMonthYearPicker from '../../forms/FormMonthYearPicker'; import FormSection from '../../forms/FormSection'; import FormSelect from '../../forms/FormSelect'; @@ -106,6 +115,7 @@ function FullTimeOfferDetailsForm({ })} />
+<<<<<<< HEAD
+
+
+ { + if (option) { + setValue(`offers.${index}.companyId`, option.value); + setValue(`offers.${index}.companyName`, option.label); + } + }} + /> + { + if (option) { + setValue(`offers.${index}.cityId`, option.value); + setValue(`offers.${index}.cityName`, option.label); + } else { + setValue(`offers.${index}.cityId`, ''); + setValue(`offers.${index}.cityName`, ''); + } + }} + /> +
+
+ +
+
+ + } + endAddOnType="element" + errorMessage={ + offerFields?.offersFullTime?.totalCompensation?.value?.message + } + label="Total Compensation (Annual)" + placeholder="0" + required={true} + startAddOn="$" + startAddOnType="label" + type="number" + {...register( + `offers.${index}.offersFullTime.totalCompensation.value`, + { + min: { message: FieldError.NON_NEGATIVE_NUMBER, value: 0 }, +>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) required: FieldError.REQUIRED, })} /> @@ -375,6 +472,7 @@ function InternshipOfferDetailsForm({ }} />
+<<<<<<< HEAD
+======= + { + if (option) { + setValue(`offers.${index}.cityId`, option.value); + setValue(`offers.${index}.cityName`, option.label); + } else { + setValue(`offers.${index}.cityId`, ''); + setValue(`offers.${index}.cityName`, ''); + } + }} + /> +
+
+ + +
+
+ +
+
+ + } + endAddOnType="element" + errorMessage={ + offerFields?.offersIntern?.monthlySalary?.value?.message + } + label="Salary (Monthly)" + placeholder="0" + required={true} + startAddOn="$" + startAddOnType="label" + type="number" + {...register(`offers.${index}.offersIntern.monthlySalary.value`, { + min: { message: FieldError.NON_NEGATIVE_NUMBER, value: 0 }, + required: FieldError.REQUIRED, + valueAsNumber: true, + })} + /> +
+
+>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) >>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile) +======= +>>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field) monthlySalary?: Money | null; title?: string | null; totalCompensation?: Money | null;