From 68083e581eb293340e579c5e5c5383ca2e22d443 Mon Sep 17 00:00:00 2001 From: Kyle Morel Date: Fri, 29 Dec 2023 13:33:11 -0800 Subject: [PATCH] Pulling in additional form values from CHEFS --- app/src/db/models/submission.ts | 2 +- app/src/services/chefs.ts | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/db/models/submission.ts b/app/src/db/models/submission.ts index 32e399d3..d9a8453b 100644 --- a/app/src/db/models/submission.ts +++ b/app/src/db/models/submission.ts @@ -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, diff --git a/app/src/services/chefs.ts b/app/src/services/chefs.ts index 140fa33a..9aef592a 100644 --- a/app/src/services/chefs.ts +++ b/app/src/services/chefs.ts @@ -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'; @@ -52,6 +52,13 @@ 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, @@ -59,10 +66,15 @@ const service = { 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