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

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

Loading…
Cancel
Save