-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a4af50
commit 1457e1c
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
alimento-nextjs/actions/customer-dash/customerVendorData.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use server'; | ||
|
||
import prismadb from '@/lib/prismadb'; | ||
|
||
export async function getCustomerVendorData() { | ||
try { | ||
const customers = await prismadb.customer.findMany(); | ||
const vendors = await prismadb.vendor.findMany(); | ||
|
||
return { | ||
success: true, | ||
data: { | ||
customers, | ||
vendors, | ||
}, | ||
}; | ||
} catch (error) { | ||
console.error('[GET_CUSTOMER_VENDOR_ERROR]', error); | ||
return { success: false, error: 'Error fetching data' }; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
alimento-nextjs/actions/customer-dash/customerVendorOrderHistory.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use server'; | ||
|
||
import prismadb from '@/lib/prismadb'; | ||
|
||
export async function getOrderHistory({ | ||
customerId, | ||
vendorId, | ||
}: { | ||
customerId?: string; | ||
vendorId?: string; | ||
}) { | ||
try { | ||
const orders = await prismadb.order.findMany({ | ||
where: { | ||
...(customerId ? { customerId } : {}), | ||
...(vendorId ? { vendorId } : {}), | ||
}, | ||
include: { | ||
customer: true, | ||
vendor: true, | ||
}, | ||
}); | ||
|
||
return { | ||
success: true, | ||
data: orders, | ||
}; | ||
} catch (error) { | ||
console.error('[GET_ORDER_HISTORY_ERROR]', error); | ||
return { success: false, error: 'Error fetching order history' }; | ||
} | ||
} |