Skip to content

Commit

Permalink
add customer dash routes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhagarwal1 committed Nov 9, 2024
1 parent 2a4af50 commit 1457e1c
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
21 changes: 21 additions & 0 deletions alimento-nextjs/actions/customer-dash/customerVendorData.tsx
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' };
}
}
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' };
}
}

0 comments on commit 1457e1c

Please sign in to comment.