Refactor routing and component structure by removing transactions-related routes and components, consolidating login functionality across multiple nodes. Update type definitions and server load functions to reflect these changes, enhancing code maintainability and streamlining user navigation. Adjust UI components to focus on receipts, improving user experience.
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m52s

This commit is contained in:
eewing
2026-02-26 10:13:28 -06:00
parent f8b8ecd88c
commit 39bea5e7a9
40 changed files with 40 additions and 2126 deletions
-36
View File
@@ -6,32 +6,9 @@
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/accounts": [
"src/routes/accounts/+page.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/accounts/new": [
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/accounts/[id]": [
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/api/files/[...path]": [
"src/routes/api/files/[...path]/+server.ts"
],
"/items": [
"src/routes/items/+page.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/items/[id]": [
"src/routes/items/[id]/+page.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/login": [
"src/routes/login/+page.server.ts",
"src/routes/+layout.ts",
@@ -55,18 +32,5 @@
"src/routes/receipts/[id]/+page.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/transactions": [
"src/routes/transactions/+page.server.ts",
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/transactions/new": [
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
],
"/transactions/[id]": [
"src/routes/+layout.ts",
"src/routes/+layout.server.ts"
]
}
+1 -1
View File
@@ -13,7 +13,7 @@ type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageServerParentData = EnsureDefined<LayoutServerData>;
type PageParentData = EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/" | "/receipts" | "/receipts/new" | "/receipts/[id]" | "/logout" | "/transactions" | "/transactions/new" | "/transactions/[id]" | "/accounts" | "/accounts/new" | "/accounts/[id]" | "/items" | "/items/[id]" | "/login" | null
type LayoutRouteId = RouteId | "/" | "/receipts" | "/receipts/new" | "/receipts/[id]" | "/logout" | "/login" | null
type LayoutParams = RouteParams & { id?: string }
type LayoutServerParentData = EnsureDefined<{}>;
type LayoutParentData = EnsureDefined<{}>;
+3 -16
View File
@@ -11,21 +11,8 @@ type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Pa
type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageServerParentData = EnsureDefined<import('../$types.js').LayoutServerData>;
type PageParentData = EnsureDefined<import('../$types.js').LayoutData>;
export type PageServerLoad<OutputData extends OutputDataShape<PageServerParentData> = OutputDataShape<PageServerParentData>> = Kit.ServerLoad<RouteParams, PageServerParentData, OutputData, RouteId>;
export type PageServerLoadEvent = Parameters<PageServerLoad>[0];
type ExcludeActionFailure<T> = T extends Kit.ActionFailure<any> ? never : T extends void ? never : T;
type ActionsSuccess<T extends Record<string, (...args: any) => any>> = { [Key in keyof T]: ExcludeActionFailure<Awaited<ReturnType<T[Key]>>>; }[keyof T];
type ExtractActionFailure<T> = T extends Kit.ActionFailure<infer X> ? X extends void ? never : X : never;
type ActionsFailure<T extends Record<string, (...args: any) => any>> = { [Key in keyof T]: Exclude<ExtractActionFailure<Awaited<ReturnType<T[Key]>>>, void>; }[keyof T];
type ActionsExport = typeof import('./proxy+page.server.js').actions
export type SubmitFunction = Kit.SubmitFunction<Expand<ActionsSuccess<ActionsExport>>, Expand<ActionsFailure<ActionsExport>>>
export type ActionData = Expand<Kit.AwaitedActions<ActionsExport>> | null;
export type PageServerData = Expand<OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+page.server.js').load>>>>>>;
export type PageData = Expand<Omit<PageParentData, keyof PageServerData> & EnsureDefined<PageServerData>>;
export type Action<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Action<RouteParams, OutputData, RouteId>
export type Actions<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Actions<RouteParams, OutputData, RouteId>
export type PageProps = { params: RouteParams; data: PageData; form: ActionData }
export type RequestEvent = Kit.RequestEvent<RouteParams, RouteId>;
export type PageServerData = null;
export type PageData = Expand<PageParentData>;
export type PageProps = { params: RouteParams; data: PageData }
+3 -16
View File
@@ -11,22 +11,9 @@ type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Pa
type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageServerParentData = EnsureDefined<import('../../$types.js').LayoutServerData>;
type PageParentData = EnsureDefined<import('../../$types.js').LayoutData>;
export type EntryGenerator = () => Promise<Array<RouteParams>> | Array<RouteParams>;
export type PageServerLoad<OutputData extends OutputDataShape<PageServerParentData> = OutputDataShape<PageServerParentData>> = Kit.ServerLoad<RouteParams, PageServerParentData, OutputData, RouteId>;
export type PageServerLoadEvent = Parameters<PageServerLoad>[0];
type ExcludeActionFailure<T> = T extends Kit.ActionFailure<any> ? never : T extends void ? never : T;
type ActionsSuccess<T extends Record<string, (...args: any) => any>> = { [Key in keyof T]: ExcludeActionFailure<Awaited<ReturnType<T[Key]>>>; }[keyof T];
type ExtractActionFailure<T> = T extends Kit.ActionFailure<infer X> ? X extends void ? never : X : never;
type ActionsFailure<T extends Record<string, (...args: any) => any>> = { [Key in keyof T]: Exclude<ExtractActionFailure<Awaited<ReturnType<T[Key]>>>, void>; }[keyof T];
type ActionsExport = typeof import('./proxy+page.server.js').actions
export type SubmitFunction = Kit.SubmitFunction<Expand<ActionsSuccess<ActionsExport>>, Expand<ActionsFailure<ActionsExport>>>
export type ActionData = Expand<Kit.AwaitedActions<ActionsExport>> | null;
export type PageServerData = Expand<OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+page.server.js').load>>>>>>;
export type PageData = Expand<Omit<PageParentData, keyof PageServerData> & EnsureDefined<PageServerData>>;
export type Action<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Action<RouteParams, OutputData, RouteId>
export type Actions<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Actions<RouteParams, OutputData, RouteId>
export type PageProps = { params: RouteParams; data: PageData; form: ActionData }
export type RequestEvent = Kit.RequestEvent<RouteParams, RouteId>;
export type PageServerData = null;
export type PageData = Expand<PageParentData>;
export type PageProps = { params: RouteParams; data: PageData }
@@ -1,87 +0,0 @@
// @ts-nocheck
import { error, fail, redirect } from "@sveltejs/kit";
import type { Actions, PageServerLoad } from "./$types";
import type { StackqItem } from "$lib/types/items";
import { parseBool, parseNum } from "$lib/parse-form";
import { validateImageUpload } from "$lib/validate-image-upload";
const COLLECTION = "Stackq_Items";
export const load = async ({ params, locals }: Parameters<PageServerLoad>[0]) => {
const id = params.id;
if (!id) throw error(404, "Item not found");
try {
const item = await locals.pb
.collection(COLLECTION)
.getOne<StackqItem>(id, { expand: "Parent" });
const list = await locals.pb
.collection(COLLECTION)
.getFullList<StackqItem>({ sort: "-created", expand: "Parent" })
.catch(() => [] as StackqItem[]);
const itemsForParent = list.map((i) => ({ id: i.id, Item: i.Item, SKU: i.SKU }));
return { item, itemsForParent };
} catch {
throw error(404, "Item not found");
}
};
export const actions = {
update: async ({ request, locals, params }: import('./$types').RequestEvent) => {
const id = params.id;
if (!id) return fail(400, { error: "Missing id", form: "update" });
const form = await request.formData();
const Item = (form.get("Item") as string)?.trim() ?? "";
const SKU = (form.get("SKU") as string)?.trim() ?? "";
const Description = (form.get("Description") as string)?.trim() ?? "";
const UOM = (form.get("UOM") as string)?.trim() ?? "";
const Cost = parseNum(form.get("Cost"));
const Vendor = (form.get("Vendor") as string)?.trim() ?? "";
const Catagory = (form.get("Catagory") as string)?.trim() ?? "";
const Sub_Catagory = (form.get("Sub_Catagory") as string)?.trim() ?? "";
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 (imageFile) {
const imgError = validateImageUpload(imageFile);
if (imgError) return fail(400, { error: imgError, form: "update" });
}
if (!Item) return fail(400, { error: "Item name is required", form: "update" });
try {
const body: Record<string, unknown> = {
Item,
SKU,
Description,
UOM: UOM || undefined,
Cost: Cost ?? 0,
Vendor,
Catagory: Catagory || undefined,
Sub_Catagory: Sub_Catagory || undefined,
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" });
}
return { success: true };
},
delete: async ({ locals, params }: import('./$types').RequestEvent) => {
const id = params.id;
if (!id) return fail(400, { error: "Missing id", form: "delete" });
try {
await locals.pb.collection(COLLECTION).delete(id);
} catch (e: unknown) {
const message = e && typeof e === "object" && "message" in e ? String((e as { message: string }).message) : "Delete failed";
return fail(500, { error: message, form: "delete" });
}
throw redirect(303, "/items");
},
};
;null as any as Actions;
@@ -1,134 +0,0 @@
// @ts-nocheck
import { fail } from "@sveltejs/kit";
import type { Actions, PageServerLoad } from "./$types";
import type { StackqItem } from "$lib/types/items";
import { parseBool, parseNum } from "$lib/parse-form";
import { validateImageUpload } from "$lib/validate-image-upload";
const COLLECTION = "Stackq_Items";
export const load = async ({ locals }: Parameters<PageServerLoad>[0]) => {
const list = await locals.pb
.collection(COLLECTION)
.getFullList<StackqItem>({
sort: "-created",
expand: "Parent",
})
.catch((err) => {
console.error(COLLECTION, err);
return [] as StackqItem[];
});
const itemsForParent = list.map((i) => ({ id: i.id, Item: i.Item, SKU: i.SKU }));
return { items: list, itemsForParent };
};
export const actions = {
create: async ({ request, locals }: import('./$types').RequestEvent) => {
const form = await request.formData();
const Item = (form.get("Item") as string)?.trim() ?? "";
const SKU = (form.get("SKU") as string)?.trim() ?? "";
const Description = (form.get("Description") as string)?.trim() ?? "";
const UOM = (form.get("UOM") as string)?.trim() ?? "";
const Cost = parseNum(form.get("Cost"));
const Vendor = (form.get("Vendor") as string)?.trim() ?? "";
const Catagory = (form.get("Catagory") as string)?.trim() ?? "";
const Sub_Catagory = (form.get("Sub_Catagory") as string)?.trim() ?? "";
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 (hasImage) {
const imgError = validateImageUpload(imageFileCreate);
if (imgError) return fail(400, { error: imgError, form: "create" });
}
if (!Item) return fail(400, { error: "Item name is required", form: "create" });
try {
const body: Record<string, unknown> = {
Item,
SKU,
Description,
UOM: UOM || undefined,
Cost: Cost ?? 0,
Vendor,
Catagory: Catagory || undefined,
Sub_Catagory: Sub_Catagory || undefined,
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" });
}
return { success: true };
},
update: async ({ request, locals }: import('./$types').RequestEvent) => {
const form = await request.formData();
const id = (form.get("id") as string)?.trim();
if (!id) return fail(400, { error: "Missing id", form: "update" });
const Item = (form.get("Item") as string)?.trim() ?? "";
const SKU = (form.get("SKU") as string)?.trim() ?? "";
const Description = (form.get("Description") as string)?.trim() ?? "";
const UOM = (form.get("UOM") as string)?.trim() ?? "";
const Cost = parseNum(form.get("Cost"));
const Vendor = (form.get("Vendor") as string)?.trim() ?? "";
const Catagory = (form.get("Catagory") as string)?.trim() ?? "";
const Sub_Catagory = (form.get("Sub_Catagory") as string)?.trim() ?? "";
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 (imageFile) {
const imgError = validateImageUpload(imageFile);
if (imgError) return fail(400, { error: imgError, form: "update" });
}
if (!Item) return fail(400, { error: "Item name is required", form: "update" });
try {
const body: Record<string, unknown> = {
Item,
SKU,
Description,
UOM: UOM || undefined,
Cost: Cost ?? 0,
Vendor,
Catagory: Catagory || undefined,
Sub_Catagory: Sub_Catagory || undefined,
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" });
}
return { success: true };
},
delete: async ({ request, locals }: import('./$types').RequestEvent) => {
const form = await request.formData();
const id = (form.get("id") as string)?.trim();
if (!id) return fail(400, { error: "Missing id", form: "delete" });
try {
await locals.pb.collection(COLLECTION).delete(id);
} catch (e: unknown) {
const message = e && typeof e === "object" && "message" in e ? String((e as { message: string }).message) : "Delete failed";
return fail(500, { error: message, form: "delete" });
}
return { success: true };
},
};
;null as any as Actions;
@@ -1,17 +1,8 @@
// @ts-nocheck
import type { Actions, PageServerLoad } from "./$types";
import type { StackqItem } from "$lib/types/items";
const COLLECTION = "Stackq_Items";
export const load = async ({ locals }: Parameters<PageServerLoad>[0]) => {
const list = await locals.pb
.collection(COLLECTION)
.getFullList<StackqItem>({ sort: "-created", expand: "Parent" })
.catch(() => [] as StackqItem[]);
const itemsForParent = list.map((i) => ({ id: i.id, Item: i.Item, SKU: i.SKU }));
return { items: list, itemsForParent };
export const load = async () => {
return {};
};
export const actions = {
@@ -31,4 +22,4 @@ export const actions = {
}
},
};
;null as any as Actions;
;null as any as PageServerLoad;;null as any as Actions;
+3 -10
View File
@@ -11,15 +11,8 @@ type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Pa
type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageServerParentData = EnsureDefined<import('../$types.js').LayoutServerData>;
type PageParentData = EnsureDefined<import('../$types.js').LayoutData>;
export type PageServerLoad<OutputData extends OutputDataShape<PageServerParentData> = OutputDataShape<PageServerParentData>> = Kit.ServerLoad<RouteParams, PageServerParentData, OutputData, RouteId>;
export type PageServerLoadEvent = Parameters<PageServerLoad>[0];
export type ActionData = unknown;
export type PageServerData = Expand<OptionalUnion<EnsureDefined<Kit.LoadProperties<Awaited<ReturnType<typeof import('./proxy+page.server.js').load>>>>>>;
export type PageData = Expand<Omit<PageParentData, keyof PageServerData> & EnsureDefined<PageServerData>>;
export type Action<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Action<RouteParams, OutputData, RouteId>
export type Actions<OutputData extends Record<string, any> | void = Record<string, any> | void> = Kit.Actions<RouteParams, OutputData, RouteId>
export type PageProps = { params: RouteParams; data: PageData; form: ActionData }
export type RequestEvent = Kit.RequestEvent<RouteParams, RouteId>;
export type PageServerData = null;
export type PageData = Expand<PageParentData>;
export type PageProps = { params: RouteParams; data: PageData }
@@ -1,7 +0,0 @@
// @ts-nocheck
import type { PageServerLoad } from "./$types";
export const load = async () => {
return { transactions: [] as { id: string }[] };
};
;null as any as PageServerLoad;