[resumes][chore] locationId migration

pull/506/head
Keane Chan 3 years ago
parent 6fc312022a
commit 29a6dfee89
No known key found for this signature in database
GPG Key ID: 32718398E1E9F87C

@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `location` on the `ResumesResume` table. All the data in the column will be lost.
- Added the required column `locationId` to the `ResumesResume` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "ResumesResume" DROP COLUMN "location",
ADD COLUMN "locationId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "ResumesResume" ADD CONSTRAINT "ResumesResume_locationId_fkey" FOREIGN KEY ("locationId") REFERENCES "Country"("id") ON DELETE CASCADE ON UPDATE CASCADE;

@ -112,6 +112,7 @@ model Country {
code String @unique code String @unique
states State[] states State[]
questionsQuestionEncounters QuestionsQuestionEncounter[] questionsQuestionEncounters QuestionsQuestionEncounter[]
ResumesResume ResumesResume[]
} }
model State { model State {
@ -148,13 +149,14 @@ model ResumesResume {
// TODO: Update role, experience, location to use Enums // TODO: Update role, experience, location to use Enums
role String @db.Text role String @db.Text
experience String @db.Text experience String @db.Text
location String @db.Text locationId String
url String url String
additionalInfo String? @db.Text additionalInfo String? @db.Text
isResolved Boolean @default(false) isResolved Boolean @default(false)
createdAt DateTime @default(now()) createdAt DateTime @default(now())
updatedAt DateTime @updatedAt updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade)
location Country @relation(fields: [locationId], references: [id], onDelete: Cascade)
stars ResumesStar[] stars ResumesStar[]
comments ResumesComment[] comments ResumesComment[]
} }

@ -20,10 +20,10 @@ import {
} from '@tih/ui'; } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import RoleTypeahead from '~/components/questions/typeahead/RoleTypeahead'; import ResumeLocationTypeahead from '~/components/resumes/shared/ResumeLocationTypeahead';
import ResumeRoleTypeahead from '~/components/resumes/shared/ResumeRoleTypeahead';
import ResumeSubmissionGuidelines from '~/components/resumes/submit-form/ResumeSubmissionGuidelines'; import ResumeSubmissionGuidelines from '~/components/resumes/submit-form/ResumeSubmissionGuidelines';
import Container from '~/components/shared/Container'; import Container from '~/components/shared/Container';
import CountriesTypeahead from '~/components/shared/CountriesTypeahead';
import loginPageHref from '~/components/shared/loginPageHref'; import loginPageHref from '~/components/shared/loginPageHref';
import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys'; import { RESUME_STORAGE_KEY } from '~/constants/file-storage-keys';
@ -43,7 +43,7 @@ type IFormInput = {
experience: string; experience: string;
file: File; file: File;
isChecked: boolean; isChecked: boolean;
location: string; locationId: string;
role: string; role: string;
title: string; title: string;
}; };
@ -97,7 +97,7 @@ export default function SubmitResumeForm({
additionalInfo: '', additionalInfo: '',
experience: '', experience: '',
isChecked: false, isChecked: false,
location: '', locationId: '',
role: '', role: '',
title: '', title: '',
...initFormDetails, ...initFormDetails,
@ -161,7 +161,7 @@ export default function SubmitResumeForm({
additionalInfo: data.additionalInfo, additionalInfo: data.additionalInfo,
experience: data.experience, experience: data.experience,
id: initFormDetails?.resumeId, id: initFormDetails?.resumeId,
location: data.location, locationId: data.locationId,
role: data.role, role: data.role,
title: data.title, title: data.title,
url: fileUrl, url: fileUrl,
@ -307,12 +307,15 @@ export default function SubmitResumeForm({
control={control} control={control}
name="role" name="role"
render={() => ( render={() => (
<RoleTypeahead <ResumeRoleTypeahead
disabled={isLoading} disabled={isLoading}
required={true} required={true}
onSelect={(option) => onSelect={(option) => {
onValueChange('role', option.value) if (option == null) {
return;
} }
onValueChange('role', option.value);
}}
/> />
)} )}
rules={{ required: true }} rules={{ required: true }}
@ -329,16 +332,16 @@ export default function SubmitResumeForm({
</div> </div>
<Controller <Controller
control={control} control={control}
name="location" name="locationId"
render={() => ( render={() => (
<CountriesTypeahead <ResumeLocationTypeahead
disabled={isLoading} disabled={isLoading}
required={true} required={true}
onSelect={(option) => { onSelect={(option) => {
if (option == null) { if (option == null) {
return; return;
} }
onValueChange('location', option.value); onValueChange('locationId', option.value);
}} }}
/> />
)} )}

Loading…
Cancel
Save