added vendors table
This commit is contained in:
21
lib/helper/fetchVendors.ts
Normal file
21
lib/helper/fetchVendors.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
// lib/helper/fetchVendors.ts
|
||||
import { Vendor } from '@prisma/client'
|
||||
|
||||
export interface VendorWithAddress extends Vendor {
|
||||
address: {
|
||||
street: string
|
||||
city: string
|
||||
state: string
|
||||
zip: number
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchVendorsClient(): Promise<VendorWithAddress[]> {
|
||||
const res = await fetch('/api/vendors/fetch')
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to fetch vendors')
|
||||
}
|
||||
|
||||
return res.json()
|
||||
}
|
||||
@@ -163,4 +163,8 @@ export const queries = {
|
||||
return await prisma.venue.findMany()
|
||||
},
|
||||
|
||||
async fetchAllVendors() {
|
||||
return await prisma.vendor.findMany()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user