Enhance receipt display by adding conditional rendering for descriptions and editing capabilities. Introduce a derived state for edit permissions and update UI components to reflect these changes, improving user interaction and information visibility.
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m38s

This commit is contained in:
eewing
2026-02-26 14:30:22 -06:00
parent c89329dada
commit fcd2c0342f
5 changed files with 106 additions and 34 deletions
@@ -27,7 +27,7 @@ export const load = async ({ locals }: Parameters<PageServerLoad>[0]) => {
return [] as StackqReceipt[];
});
return { receipts: list };
return { receipts: list, canEdit: isAdmin };
};
export const actions = {
@@ -93,11 +93,9 @@ export const actions = {
return fail(400, { error: "Invalid status", setStatus: null });
}
const isAdmin = user.Admin === true;
if (!isAdmin) return fail(403, { error: "Only admins can change status.", setStatus: null });
try {
const existing = await locals.pb.collection(COLLECTION).getOne<StackqReceipt>(id);
if (!isAdmin && existing.User !== user.id) {
return fail(404, { error: "Receipt not found", setStatus: null });
}
await locals.pb.collection(COLLECTION).getOne<StackqReceipt>(id);
await locals.pb.collection(COLLECTION).update(id, { Status });
} catch (e: unknown) {
const is404 = e && typeof e === "object" && "status" in e && (e as { status: number }).status === 404;