-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from shubhagarwal1/route
Implement Order History View for Customer Dashboard [Backend + Routes]
- Loading branch information
Showing
3 changed files
with
65 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' }; | ||
} | ||
} |
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