feat: implement admin dashboard with full CRUD functionality

This commit is contained in:
2025-06-18 16:20:19 +08:00
parent 95ef4cd617
commit 0ca2d51669
6 changed files with 324 additions and 3 deletions

View File

@ -0,0 +1,24 @@
import { defineEventHandler, createError } from 'h3';
import { db } from '~/server/db';
import { customers } from '~/server/db/schema';
export default defineEventHandler(async () => {
try {
// Select specific fields to avoid exposing sensitive data like passwords
const allCustomers = await db.select({
CustomerID: customers.id,
Name: customers.name,
Contact: customers.contact,
Gender: customers.gender,
IDCard: customers.idCard,
}).from(customers);
return allCustomers;
} catch (error) {
console.error('Error fetching customers:', error);
return createError({
statusCode: 500,
statusMessage: 'Failed to fetch customers',
});
}
});