Skip to content

Commit

Permalink
fix(update at.vin): update at.do to at.vin
Browse files Browse the repository at this point in the history
  • Loading branch information
crisner1978 committed Oct 10, 2023
1 parent 44531af commit 33a2958
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 2 additions & 4 deletions src/app/utils/airtable.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export const conciergeBase = 'app0ha03ugcl45qM1'

export const fromAirtable = async (base: string, table: string, id: string) => {
const d = await fetch(`https://drivly.airtable.do/${base}/${table}/${id}`, {
const d = await fetch(`https://airtable.vin/${base}/${table}/${id}`, {
headers: {
Authorization: `Bearer ${process.env.VIN_UNIVERSE_KEY}`,
},
Expand All @@ -13,7 +11,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://drivly.airtable.do/${base}/${table}?filterByFormula=${query}`, {
const d = await fetch(`https://airtable.vin/${base}/${table}?filterByFormula=${query}`, {
headers: { Authorization: `Bearer ${process.env.VIN_UNIVERSE_KEY}` },
})

Expand Down
6 changes: 3 additions & 3 deletions src/app/utils/getATVehicleById.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'server-only'
import { formatDigits } from '@drivly/ui'
import { conciergeBase, fromAirtable } from './airtable'
import 'server-only'
import { fromAirtable } from './airtable'
import { VehicleDetailProps } from './getVehicleDetails'

export async function getATVehicleById(id: string) {
const data = await fromAirtable(conciergeBase, 'Vehicles', `rec${id}`)
const data = await fromAirtable('CRM', 'Vehicles', `rec${id}`)
const price = findAirtablePrice(data)

return {
Expand Down
14 changes: 7 additions & 7 deletions src/app/utils/getVehicleDetails.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use server'

import z from 'zod'
import getListing from '@drivly/ui/dist/lib/getListing'
import { formatDigits } from '@drivly/ui'
import { conciergeBase, searchAirtable } from './airtable'
import getListing from '@drivly/ui/dist/lib/getListing'
import z from 'zod'
import { searchAirtable } from './airtable'

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

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

const highestPricedRecord = findHighestPricedRecord(data?.records)
const data = await searchAirtable('CRM', 'Vehicles', `AND({VIN}='${id}')`)
if (data?.length === 0) return null
const highestPricedRecord = findHighestPricedRecord(data)
const salesPrice = highestPricedRecord?.salesPrice || ''
const buyNow = highestPricedRecord?.buyNow || ''
const retailPrice = highestPricedRecord?.retailPrice || ''
Expand Down

0 comments on commit 33a2958

Please sign in to comment.