fix(repair-details): update file handling and type definitions
- Modified the file handling in the repair details page to use the correct repair ID and simplified the key assignment for photo files. - Updated the API route to cast the status parameter to the new RepairStatus type for improved type safety. - Expanded the RepairFileField type to include "delivery_note" for better file management. - Removed unused helper functions to clean up the codebase and improve maintainability.
This commit is contained in:
parent
663c018a70
commit
fb283765fb
3 changed files with 6 additions and 19 deletions
|
|
@ -547,12 +547,12 @@ export default function RepairDetailPage({
|
|||
<div className="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-6 gap-2">
|
||||
{photoFiles.map((f) => (
|
||||
<a
|
||||
key={f.field + f.name}
|
||||
href={`/api/v1/files/repairs/${item.id}/${f.name}`}
|
||||
key={f}
|
||||
href={`/api/v1/files/repairs/${repair.id}/${f}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex h-7 w-7 items-center justify-center rounded hover:bg-muted"
|
||||
title={`${f.field}: ${f.name}`}
|
||||
title={f}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<img
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import {
|
|||
createRepair,
|
||||
listRepairs,
|
||||
type CreateRepairInput,
|
||||
type RepairStatus,
|
||||
} from "@/lib/server/repairs-service";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
|
@ -29,7 +30,7 @@ export async function GET(req: NextRequest) {
|
|||
100,
|
||||
);
|
||||
const search = searchParams.get("search") ?? "";
|
||||
const status = searchParams.get("status") ?? "";
|
||||
const status = (searchParams.get("status") ?? "") as RepairStatus | "";
|
||||
const sort = searchParams.get("sort") ?? "-created";
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ export async function generateRepairDeliveryNote(
|
|||
* File upload helpers (photos / quote / purchase_order)
|
||||
* ========================================================================== */
|
||||
|
||||
export type RepairFileField = "photos" | "quote" | "purchase_order";
|
||||
export type RepairFileField = "photos" | "quote" | "purchase_order" | "delivery_note";
|
||||
|
||||
export async function uploadRepairFile(
|
||||
repairId: string,
|
||||
|
|
@ -626,17 +626,3 @@ export async function searchOrdersForRepairForm(
|
|||
};
|
||||
}
|
||||
|
||||
/* ============================================================================
|
||||
* Misc helpers
|
||||
* ========================================================================== */
|
||||
|
||||
/** Resolve the user id of the operator (for the audit stamp). */
|
||||
export async function getMe(): Promise<{ id: string; name?: string } | null> {
|
||||
const pb = await getAdminPocketBase();
|
||||
try {
|
||||
const me = await pb.collection(USERS).getAuthRecord();
|
||||
return me ? { id: (me as User).id, name: (me as User).name } : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue