Skip to content

Commit

Permalink
update slack msg
Browse files Browse the repository at this point in the history
  • Loading branch information
crisner1978 committed Dec 23, 2023
1 parent c28c38d commit 52a634b
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/app/utils/airtable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const fromAirtable = async (base: string, table: string, id: string) => {
}

export const searchAirtable = async (base: string, table: string, query: string) => {
const d = await fetch(`https://airtable.vin/${base}/${table}?filterByFormula=${query}`, {
const d = await fetch(`https://airtable.vin/${base}/${table}?${query}`, {
headers: { Authorization: `Bearer ${process.env.VIN_UNIVERSE_KEY}` },
})

Expand Down
4 changes: 2 additions & 2 deletions src/app/utils/getVehicleDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import z from 'zod'
import getListing from '@drivly/ui/dist/lib/getListing'
import { formatDigits } from '@drivly/ui'
import { conciergeBase, searchAirtable } from './airtable'
import { searchAirtable } from './airtable'

const vehicleSchema = z.object({
year: z.string(),
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function getVehicleDetails(id: string) {
}

export const fetchPrice = async (id: string) => {
const data = await searchAirtable('CRM', 'Vehicles', `AND({VIN}='${id}')`)
const data = await searchAirtable('CRM', 'Vehicles', `vin='${id}`)
if (!data?.length) return null

const highestPricedRecord = findHighestPricedRecord(data)
Expand Down
124 changes: 79 additions & 45 deletions src/utils/slackMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'section',
text: {
type: 'mrkdwn',
text: `*CREDIT APP* REQUEST ${date} :rocket:\n* ${data.primary.firstName} ${data.primary.lastName} | ${data.primary.email}*`,
text: `*${data.primary.firstName} ${data.primary.lastName}* | ${date} :moneybag:\n* ${data.primary.email} | ${date}*`,
},
})
blocks.push({
Expand All @@ -40,20 +40,22 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
data.primary?.middleName || ''
} ${data.primary.lastName}\n*Phone:* ${data.primary.phone} ${
data.primary.phoneType
}\n*Email:* ${data.primary.email}\n*Date of Birth:* ${data.primary.dateOfBirth}\n*SSN:* ${
data.primary.ssn
}`,
}\n*Email:* ${data.primary.email}\n*Date of Birth:* ${
data.primary.dateOfBirth
}\n*SSN:* ${data.primary.ssn}`,
},
})
blocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: `*Residence*\n*Address:* ${data.primary.addressLine1} \n*City:* ${
data.primary.city
}\n*State:* ${data.primary.state}\n*Zip Code:* ${
data.primary.zipCode
}\n*Time at address:* ${data.primary.addressYears} yrs ${
text: `*Residence*\n*Address:* ${
data.primary.addressLine1
} \n*City:* ${data.primary.city}\n*State:* ${
data.primary.state
}\n*Zip Code:* ${data.primary.zipCode}\n*Time at address:* ${
data.primary.addressYears
} yrs ${
data.primary.addressMonths ? data.primary.addressMonths + 'mo' : ''
}\n*Monthly payment/rent:* ${data.primary.rentMortgagePaymentAmount}`,
},
Expand All @@ -63,13 +65,19 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'section',
text: {
type: 'mrkdwn',
text: `*Previous Residence*\n*Address:* ${data.primary.prevAddressLine1} \n*City:* ${
data.primary.prevCity
}\n*State:* ${data.primary.prevState}\n*Zip Code:* ${
data.primary.zipCode
}\n*Time at address:* ${data.primary.prevAddressYears} yrs ${
data.primary.prevAddressMonths ? data.primary.prevAddressMonths + 'mo' : ''
}\n*Monthly payment/rent:* ${data.primary.prevRentMortgagePaymentAmount}`,
text: `*Previous Residence*\n*Address:* ${
data.primary.prevAddressLine1
} \n*City:* ${data.primary.prevCity}\n*State:* ${
data.primary.prevState
}\n*Zip Code:* ${data.primary.zipCode}\n*Time at address:* ${
data.primary.prevAddressYears
} yrs ${
data.primary.prevAddressMonths
? data.primary.prevAddressMonths + 'mo'
: ''
}\n*Monthly payment/rent:* ${
data.primary.prevRentMortgagePaymentAmount
}`,
},
})
blocks.push({
Expand All @@ -85,12 +93,14 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'mrkdwn',
text: `*Employment History*\n*Employer name:* ${
data.primary.employerName
}\n*Employment Status:* ${data.primary.employmentStatusCode}\n*Employer phone:* ${
data.primary?.employerPhone
}\n*Occupation:* ${data.primary?.employmentTitle}\n*Time on job:* ${
data.primary?.timeOnJobYears
} yrs ${
data.primary?.timeOnJobMonths ? data.primary?.timeOnJobMonths + 'mo' : ''
}\n*Employment Status:* ${
data.primary.employmentStatusCode
}\n*Employer phone:* ${data.primary?.employerPhone}\n*Occupation:* ${
data.primary?.employmentTitle
}\n*Time on job:* ${data.primary?.timeOnJobYears} yrs ${
data.primary?.timeOnJobMonths
? data.primary?.timeOnJobMonths + 'mo'
: ''
}\n*Monthly income:* ${data.primary?.incomeAmount}`,
},
})
Expand All @@ -101,10 +111,14 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'mrkdwn',
text: `*Previous Employment*\n*Employer name:* ${
data.primary?.previousEmployerName
}\n*Employer phone:* ${data.primary?.prevEmployerPhone}\n*Occupation:* ${
}\n*Employer phone:* ${
data.primary?.prevEmployerPhone
}\n*Occupation:* ${
data.primary?.prevEmploymentTitle
}\n*Time on job:* ${data.primary?.prevTimeOnJobYears} yrs ${
data.primary?.prevTimeOnJobMonths ? data.primary?.prevTimeOnJobMonths + 'mo' : ''
data.primary?.prevTimeOnJobMonths
? data.primary?.prevTimeOnJobMonths + 'mo'
: ''
}\n*Monthly income:* ${data.primary?.prevIncomeAmount}`,
},
})
Expand All @@ -130,27 +144,39 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'section',
text: {
type: 'mrkdwn',
text: `*Residence*\n*Address:* ${data.secondary.addressLine1} \n*City:* ${
data.secondary.city
}\n*State:* ${data.secondary.state}*Zip Code:* ${
data.secondary.zipCode
}\n*Time at address:* ${data.secondary.addressYears} yrs ${
data.secondary.addressMonths ? data.secondary.addressMonths + 'mo' : ''
}\n*Monthly payment/rent:* ${data.secondary.rentMortgagePaymentAmount}`,
text: `*Residence*\n*Address:* ${
data.secondary.addressLine1
} \n*City:* ${data.secondary.city}\n*State:* ${
data.secondary.state
}*Zip Code:* ${data.secondary.zipCode}\n*Time at address:* ${
data.secondary.addressYears
} yrs ${
data.secondary.addressMonths
? data.secondary.addressMonths + 'mo'
: ''
}\n*Monthly payment/rent:* ${
data.secondary.rentMortgagePaymentAmount
}`,
},
})
Number(data.secondary.addressYears) < 2 &&
blocks.push({
type: 'section',
text: {
type: 'mrkdwn',
text: `*Previous Residence*\n*Address:* ${data.secondary.prevAddressLine1} \n*City:* ${
data.secondary.prevCity
}\n*State:* ${data.secondary.prevState}\n*Zip Code:* ${
data.secondary.prevZipCode
}\n*Time at address:* ${data.secondary.prevAddressYears} yrs ${
data.secondary.prevAddressMonths ? data.secondary.prevAddressMonths + 'mo' : ''
}\n*Monthly payment/rent:* ${data.secondary.prevRentMortgagePaymentAmount}`,
text: `*Previous Residence*\n*Address:* ${
data.secondary.prevAddressLine1
} \n*City:* ${data.secondary.prevCity}\n*State:* ${
data.secondary.prevState
}\n*Zip Code:* ${data.secondary.prevZipCode}\n*Time at address:* ${
data.secondary.prevAddressYears
} yrs ${
data.secondary.prevAddressMonths
? data.secondary.prevAddressMonths + 'mo'
: ''
}\n*Monthly payment/rent:* ${
data.secondary.prevRentMortgagePaymentAmount
}`,
},
})
blocks.push({
Expand All @@ -166,12 +192,16 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'mrkdwn',
text: `*Employment History*\n*Employer name:* ${
data?.secondary?.employerName
}\n*Employment Status:* ${data?.secondary?.employmentStatusCode}\n*Employer phone:* ${
}\n*Employment Status:* ${
data?.secondary?.employmentStatusCode
}\n*Employer phone:* ${
data?.secondary?.employerPhone
}\n*Occupation:* ${data?.secondary?.employmentTitle}\n*Time on job:* ${
data?.secondary?.timeOnJobYears
} yrs ${
data?.secondary?.timeOnJobMonths ? data?.secondary?.timeOnJobMonths + 'mo' : ''
}\n*Occupation:* ${
data?.secondary?.employmentTitle
}\n*Time on job:* ${data?.secondary?.timeOnJobYears} yrs ${
data?.secondary?.timeOnJobMonths
? data?.secondary?.timeOnJobMonths + 'mo'
: ''
}\n*Monthly income:* ${data?.secondary?.incomeAmount}`,
},
})
Expand All @@ -182,10 +212,14 @@ export async function slackMsgRequest({ url, data }: SlackMsgRequest) {
type: 'mrkdwn',
text: `*Previous Employment*\n*Employer name:* ${
data?.secondary?.previousEmployerName
}\n*Employer phone:* ${data?.secondary?.prevEmployerPhone}\n*Occupation:* ${
}\n*Employer phone:* ${
data?.secondary?.prevEmployerPhone
}\n*Occupation:* ${
data?.secondary?.prevEmploymentTitle
}\n*Time on job:* ${data?.secondary?.prevTimeOnJobYears} yrs ${
data?.secondary?.prevTimeOnJobMonths ? data?.secondary?.prevTimeOnJobMonths + 'mo' : ''
data?.secondary?.prevTimeOnJobMonths
? data?.secondary?.prevTimeOnJobMonths + 'mo'
: ''
}\n*Monthly income:* ${data?.secondary?.prevIncomeAmount}`,
},
})
Expand Down

1 comment on commit 52a634b

@vercel
Copy link

@vercel vercel bot commented on 52a634b Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks for Deployment have failed

Please sign in to comment.