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 Dec 29, 2023
1 parent 014b910 commit b2776d5
Showing 1 changed file with 15 additions and 3 deletions.
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: submission.latitude,
longitude: 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 b2776d5

Please sign in to comment.