Refactor environment variable declarations, enhance image handling in item forms, and update asset references in SvelteKit project for improved functionality and performance.
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m53s

This commit is contained in:
eewing
2026-02-17 15:13:03 -06:00
parent 9022114c8d
commit 7ac169c1e4
238 changed files with 35126 additions and 1344 deletions
+12 -4
View File
@@ -45,11 +45,13 @@ export const actions: Actions = {
const Has_Parent = parseBool(form.get("Has_Parent"));
const Parent = (form.get("Parent") as string)?.trim() ?? "";
const Stock = parseBool(form.get("Stock"));
const imageFileCreate = form.get("Image") as File | null;
const hasImage = imageFileCreate && imageFileCreate.size > 0;
if (!Item) return fail(400, { error: "Item name is required", form: "create" });
try {
await locals.pb.collection(COLLECTION).create({
const body: Record<string, unknown> = {
Item,
SKU,
Description,
@@ -61,7 +63,9 @@ export const actions: Actions = {
Has_Parent: !!Has_Parent,
Parent: Parent || null,
Stock: !!Stock,
});
};
if (hasImage) body.Image = imageFileCreate;
await locals.pb.collection(COLLECTION).create(body);
} catch (e: unknown) {
const message = e && typeof e === "object" && "message" in e ? String((e as { message: string }).message) : "Create failed";
return fail(500, { error: message, form: "create" });
@@ -85,11 +89,13 @@ export const actions: Actions = {
const Has_Parent = parseBool(form.get("Has_Parent"));
const Parent = (form.get("Parent") as string)?.trim() ?? "";
const Stock = parseBool(form.get("Stock"));
const Image = form.get("Image") as File | null;
const imageFile = Image && Image.size > 0 ? Image : undefined;
if (!Item) return fail(400, { error: "Item name is required", form: "update" });
try {
await locals.pb.collection(COLLECTION).update(id, {
const body: Record<string, unknown> = {
Item,
SKU,
Description,
@@ -101,7 +107,9 @@ export const actions: Actions = {
Has_Parent: !!Has_Parent,
Parent: Parent || null,
Stock: !!Stock,
});
};
if (imageFile) body.Image = imageFile;
await locals.pb.collection(COLLECTION).update(id, body);
} catch (e: unknown) {
const message = e && typeof e === "object" && "message" in e ? String((e as { message: string }).message) : "Update failed";
return fail(500, { error: message, form: "update" });