Skip to content

Commit

Permalink
Pulling in additional form values from CHEFS
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle1morel committed Jan 3, 2024
1 parent 014b910 commit 68083e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/src/db/models/submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default {
return {
submissionId: input.submissionId,
confirmationId: input.confirmationId,
submittedAt: new Date(input.submittedAt),
submittedAt: new Date(input.submittedAt ?? Date.now()),
submittedBy: input.submittedBy,
locationPIDs: input.locationPIDs,
contactName: input.contactName,
Expand Down
18 changes: 15 additions & 3 deletions app/src/services/chefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import axios from 'axios';
import config from 'config';

import { getChefsApiKey } from '../components/utils';
import { getChefsApiKey, isTruthy } from '../components/utils';
import prisma from '../db/dataConnection';
import { submission } from '../db/models';

Expand Down Expand Up @@ -52,17 +52,29 @@ const service = {

const submission = response.submission.submission.data;

const financiallySupportedValues = {
financiallySupportedBC: isTruthy(submission.isBCHousingSupported),
financiallySupportedIndigenous: isTruthy(submission.isIndigenousHousingProviderSupported),
financiallySupportedNonProfit: isTruthy(submission.isNonProfitSupported),
financiallySupportedHousingCoop: isTruthy(submission.isHousingCooperativeSupported)
};

await prisma.submission.create({
data: {
submissionId: response.submission.id,
confirmationId: response.submission.confirmationId,
contactEmail: submission.contactEmail,
contactPhoneNumber: submission.contactPhoneNumber,
contactName: `${submission.contactFirstName} ${submission.contactLastName}`,
financiallySupported: Object.values(financiallySupportedValues).includes(true),
...financiallySupportedValues,
intakeStatus: status[0].code,
projectName: submission.projectName,
latitude: parseInt(submission.latitude),
longitude: parseInt(submission.longitude),
naturalDisaster: submission.naturalDisasterInd,
projectName: submission.companyNameRegistered,
queuePriority: parseInt(submission.queuePriority),
singleFamilyUnits: submission.singleFamilyUnits,
singleFamilyUnits: submission.singleFamilyUnits ?? submission.multiFamilyUnits,
streetAddress: submission.streetAddress,
submittedAt: response.submission.createdAt,
submittedBy: response.submission.createdBy
Expand Down

0 comments on commit 68083e5

Please sign in to comment.