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
@@ -33,9 +33,11 @@ const actions = {
const Has_Parent = parseBool(form.get("Has_Parent"));
const Parent = form.get("Parent")?.trim() ?? "";
const Stock = parseBool(form.get("Stock"));
const imageFileCreate = form.get("Image");
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 = {
Item,
SKU,
Description,
@@ -47,7 +49,9 @@ const actions = {
Has_Parent: !!Has_Parent,
Parent: Parent || null,
Stock: !!Stock
});
};
if (hasImage) body.Image = imageFileCreate;
await locals.pb.collection(COLLECTION).create(body);
} catch (e) {
const message = e && typeof e === "object" && "message" in e ? String(e.message) : "Create failed";
return fail(500, { error: message, form: "create" });
@@ -69,9 +73,11 @@ const actions = {
const Has_Parent = parseBool(form.get("Has_Parent"));
const Parent = form.get("Parent")?.trim() ?? "";
const Stock = parseBool(form.get("Stock"));
const Image = form.get("Image");
const imageFile = Image && Image.size > 0 ? Image : void 0;
if (!Item) return fail(400, { error: "Item name is required", form: "update" });
try {
await locals.pb.collection(COLLECTION).update(id, {
const body = {
Item,
SKU,
Description,
@@ -83,7 +89,9 @@ const 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) {
const message = e && typeof e === "object" && "message" in e ? String(e.message) : "Update failed";
return fail(500, { error: message, form: "update" });