feat(03-02): server actions + getAllServices query for service catalog
- Create src/app/admin/catalog/actions.ts with createService, updateService, toggleServiceActive - Each action includes requireAdmin() guard via getServerSession - Zod validation: name (min 1), unit_price (coerce.number min 0.01) - Add getAllServices() to src/lib/admin-queries.ts ordered by name - Import service_catalog and ServiceCatalog types in admin-queries.ts
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
documents,
|
||||
notes,
|
||||
time_entries,
|
||||
service_catalog,
|
||||
} from "@/db/schema";
|
||||
import { eq, inArray, asc, isNull, sql } from "drizzle-orm";
|
||||
import type {
|
||||
@@ -20,6 +21,7 @@ import type {
|
||||
Document,
|
||||
Note,
|
||||
Comment,
|
||||
ServiceCatalog,
|
||||
} from "@/db/schema";
|
||||
|
||||
export type ClientWithPayments = {
|
||||
@@ -188,4 +190,11 @@ export async function getClientFullDetail(id: string): Promise<ClientFullDetail
|
||||
notes: notesRows,
|
||||
comments: commentsRows,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getAllServices(): Promise<ServiceCatalog[]> {
|
||||
return db
|
||||
.select()
|
||||
.from(service_catalog)
|
||||
.orderBy(asc(service_catalog.name));
|
||||
}
|
||||
Reference in New Issue
Block a user