diff --git a/.svelte-kit/generated/client/app.js b/.svelte-kit/generated/client/app.js index 49406e8f..11502dea 100644 --- a/.svelte-kit/generated/client/app.js +++ b/.svelte-kit/generated/client/app.js @@ -8,34 +8,18 @@ export const nodes = [ () => import('./nodes/4'), () => import('./nodes/5'), () => import('./nodes/6'), - () => import('./nodes/7'), - () => import('./nodes/8'), - () => import('./nodes/9'), - () => import('./nodes/10'), - () => import('./nodes/11'), - () => import('./nodes/12'), - () => import('./nodes/13'), - () => import('./nodes/14'), - () => import('./nodes/15') + () => import('./nodes/7') ]; export const server_loads = [0]; export const dictionary = { "/": [~2], - "/accounts": [~10], - "/accounts/new": [11], - "/accounts/[id]": [12], - "/items": [~13], - "/items/[id]": [~14], - "/login": [~15], + "/login": [~7], "/logout": [~6], "/receipts": [~3], "/receipts/new": [4], - "/receipts/[id]": [~5], - "/transactions": [~7], - "/transactions/new": [8], - "/transactions/[id]": [9] + "/receipts/[id]": [~5] }; export const hooks = { diff --git a/.svelte-kit/generated/client/nodes/10.js b/.svelte-kit/generated/client/nodes/10.js index e442b828..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/10.js +++ b/.svelte-kit/generated/client/nodes/10.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/accounts/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/11.js b/.svelte-kit/generated/client/nodes/11.js index cee0eab9..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/11.js +++ b/.svelte-kit/generated/client/nodes/11.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/accounts/new/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/12.js b/.svelte-kit/generated/client/nodes/12.js index 585ed523..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/12.js +++ b/.svelte-kit/generated/client/nodes/12.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/accounts/[id]/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/13.js b/.svelte-kit/generated/client/nodes/13.js index 3e8c3e68..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/13.js +++ b/.svelte-kit/generated/client/nodes/13.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/items/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/14.js b/.svelte-kit/generated/client/nodes/14.js index 389ba1f3..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/14.js +++ b/.svelte-kit/generated/client/nodes/14.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/items/[id]/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/7.js b/.svelte-kit/generated/client/nodes/7.js index 37a1a420..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/7.js +++ b/.svelte-kit/generated/client/nodes/7.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/transactions/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/8.js b/.svelte-kit/generated/client/nodes/8.js index 24808434..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/8.js +++ b/.svelte-kit/generated/client/nodes/8.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/transactions/new/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/generated/client/nodes/9.js b/.svelte-kit/generated/client/nodes/9.js index 674c1f36..f2b26cd1 100644 --- a/.svelte-kit/generated/client/nodes/9.js +++ b/.svelte-kit/generated/client/nodes/9.js @@ -1 +1 @@ -export { default as component } from "../../../../src/routes/transactions/[id]/+page.svelte"; \ No newline at end of file +export { default as component } from "../../../../src/routes/login/+page.svelte"; \ No newline at end of file diff --git a/.svelte-kit/non-ambient.d.ts b/.svelte-kit/non-ambient.d.ts index 357a7727..156dbfaf 100644 --- a/.svelte-kit/non-ambient.d.ts +++ b/.svelte-kit/non-ambient.d.ts @@ -56,7 +56,7 @@ declare module "$app/types" { "/transactions/new": Record; "/transactions/[id]": { id: string } }; - Pathname(): "/" | "/accounts" | "/accounts/new" | `/accounts/${string}` & {} | `/api/files/${string}` & {} | "/items" | `/items/${string}` & {} | "/login" | "/logout" | "/receipts" | "/receipts/new" | `/receipts/${string}` & {} | "/transactions" | "/transactions/new" | `/transactions/${string}` & {}; + Pathname(): "/" | `/api/files/${string}` & {} | "/login" | "/logout" | "/receipts" | "/receipts/new" | `/receipts/${string}` & {}; ResolvedPathname(): `${"" | `/${string}`}${ReturnType}`; Asset(): "/icon.svg" | "/manifest.webmanifest" | string & {}; } diff --git a/.svelte-kit/types/route_meta_data.json b/.svelte-kit/types/route_meta_data.json index a51d9fa6..ef6e4741 100644 --- a/.svelte-kit/types/route_meta_data.json +++ b/.svelte-kit/types/route_meta_data.json @@ -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" ] } \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/$types.d.ts b/.svelte-kit/types/src/routes/$types.d.ts index 42b0a58d..4eccddc1 100644 --- a/.svelte-kit/types/src/routes/$types.d.ts +++ b/.svelte-kit/types/src/routes/$types.d.ts @@ -13,7 +13,7 @@ type OptionalUnion, A extends keyof U = U extends export type Snapshot = Kit.Snapshot; type PageServerParentData = EnsureDefined; type PageParentData = EnsureDefined; -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<{}>; diff --git a/.svelte-kit/types/src/routes/items/$types.d.ts b/.svelte-kit/types/src/routes/items/$types.d.ts index be9baa5f..d2c6be58 100644 --- a/.svelte-kit/types/src/routes/items/$types.d.ts +++ b/.svelte-kit/types/src/routes/items/$types.d.ts @@ -11,21 +11,8 @@ type OutputDataShape = MaybeWithVoid> & Pa type EnsureDefined = T extends null | undefined ? {} : T; type OptionalUnion, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude]?: never } & U : never; export type Snapshot = Kit.Snapshot; -type PageServerParentData = EnsureDefined; type PageParentData = EnsureDefined; -export type PageServerLoad = OutputDataShape> = Kit.ServerLoad; -export type PageServerLoadEvent = Parameters[0]; -type ExcludeActionFailure = T extends Kit.ActionFailure ? never : T extends void ? never : T; -type ActionsSuccess any>> = { [Key in keyof T]: ExcludeActionFailure>>; }[keyof T]; -type ExtractActionFailure = T extends Kit.ActionFailure ? X extends void ? never : X : never; -type ActionsFailure any>> = { [Key in keyof T]: Exclude>>, void>; }[keyof T]; -type ActionsExport = typeof import('./proxy+page.server.js').actions -export type SubmitFunction = Kit.SubmitFunction>, Expand>> -export type ActionData = Expand> | null; -export type PageServerData = Expand>>>>>; -export type PageData = Expand & EnsureDefined>; -export type Action | void = Record | void> = Kit.Action -export type Actions | void = Record | void> = Kit.Actions -export type PageProps = { params: RouteParams; data: PageData; form: ActionData } -export type RequestEvent = Kit.RequestEvent; \ No newline at end of file +export type PageServerData = null; +export type PageData = Expand; +export type PageProps = { params: RouteParams; data: PageData } \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/items/[id]/$types.d.ts b/.svelte-kit/types/src/routes/items/[id]/$types.d.ts index 986bc20d..0f06c109 100644 --- a/.svelte-kit/types/src/routes/items/[id]/$types.d.ts +++ b/.svelte-kit/types/src/routes/items/[id]/$types.d.ts @@ -11,22 +11,9 @@ type OutputDataShape = MaybeWithVoid> & Pa type EnsureDefined = T extends null | undefined ? {} : T; type OptionalUnion, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude]?: never } & U : never; export type Snapshot = Kit.Snapshot; -type PageServerParentData = EnsureDefined; type PageParentData = EnsureDefined; export type EntryGenerator = () => Promise> | Array; -export type PageServerLoad = OutputDataShape> = Kit.ServerLoad; -export type PageServerLoadEvent = Parameters[0]; -type ExcludeActionFailure = T extends Kit.ActionFailure ? never : T extends void ? never : T; -type ActionsSuccess any>> = { [Key in keyof T]: ExcludeActionFailure>>; }[keyof T]; -type ExtractActionFailure = T extends Kit.ActionFailure ? X extends void ? never : X : never; -type ActionsFailure any>> = { [Key in keyof T]: Exclude>>, void>; }[keyof T]; -type ActionsExport = typeof import('./proxy+page.server.js').actions -export type SubmitFunction = Kit.SubmitFunction>, Expand>> -export type ActionData = Expand> | null; -export type PageServerData = Expand>>>>>; -export type PageData = Expand & EnsureDefined>; -export type Action | void = Record | void> = Kit.Action -export type Actions | void = Record | void> = Kit.Actions -export type PageProps = { params: RouteParams; data: PageData; form: ActionData } -export type RequestEvent = Kit.RequestEvent; \ No newline at end of file +export type PageServerData = null; +export type PageData = Expand; +export type PageProps = { params: RouteParams; data: PageData } \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/items/[id]/proxy+page.server.ts b/.svelte-kit/types/src/routes/items/[id]/proxy+page.server.ts deleted file mode 100644 index d023e403..00000000 --- a/.svelte-kit/types/src/routes/items/[id]/proxy+page.server.ts +++ /dev/null @@ -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[0]) => { - const id = params.id; - if (!id) throw error(404, "Item not found"); - - try { - const item = await locals.pb - .collection(COLLECTION) - .getOne(id, { expand: "Parent" }); - const list = await locals.pb - .collection(COLLECTION) - .getFullList({ 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 = { - 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; \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/items/proxy+page.server.ts b/.svelte-kit/types/src/routes/items/proxy+page.server.ts deleted file mode 100644 index 308c870a..00000000 --- a/.svelte-kit/types/src/routes/items/proxy+page.server.ts +++ /dev/null @@ -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[0]) => { - const list = await locals.pb - .collection(COLLECTION) - .getFullList({ - 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 = { - 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 = { - 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; \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/proxy+page.server.ts b/.svelte-kit/types/src/routes/proxy+page.server.ts index 02074636..3e33e22c 100644 --- a/.svelte-kit/types/src/routes/proxy+page.server.ts +++ b/.svelte-kit/types/src/routes/proxy+page.server.ts @@ -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[0]) => { - const list = await locals.pb - .collection(COLLECTION) - .getFullList({ 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; \ No newline at end of file +;null as any as PageServerLoad;;null as any as Actions; \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/transactions/$types.d.ts b/.svelte-kit/types/src/routes/transactions/$types.d.ts index 6aee248b..85606c53 100644 --- a/.svelte-kit/types/src/routes/transactions/$types.d.ts +++ b/.svelte-kit/types/src/routes/transactions/$types.d.ts @@ -11,15 +11,8 @@ type OutputDataShape = MaybeWithVoid> & Pa type EnsureDefined = T extends null | undefined ? {} : T; type OptionalUnion, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude]?: never } & U : never; export type Snapshot = Kit.Snapshot; -type PageServerParentData = EnsureDefined; type PageParentData = EnsureDefined; -export type PageServerLoad = OutputDataShape> = Kit.ServerLoad; -export type PageServerLoadEvent = Parameters[0]; -export type ActionData = unknown; -export type PageServerData = Expand>>>>>; -export type PageData = Expand & EnsureDefined>; -export type Action | void = Record | void> = Kit.Action -export type Actions | void = Record | void> = Kit.Actions -export type PageProps = { params: RouteParams; data: PageData; form: ActionData } -export type RequestEvent = Kit.RequestEvent; \ No newline at end of file +export type PageServerData = null; +export type PageData = Expand; +export type PageProps = { params: RouteParams; data: PageData } \ No newline at end of file diff --git a/.svelte-kit/types/src/routes/transactions/proxy+page.server.ts b/.svelte-kit/types/src/routes/transactions/proxy+page.server.ts deleted file mode 100644 index 5cb4fdaf..00000000 --- a/.svelte-kit/types/src/routes/transactions/proxy+page.server.ts +++ /dev/null @@ -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; \ No newline at end of file diff --git a/src/lib/components/BarcodeScanDialog.svelte b/src/lib/components/BarcodeScanDialog.svelte deleted file mode 100644 index 4d35187a..00000000 --- a/src/lib/components/BarcodeScanDialog.svelte +++ /dev/null @@ -1,182 +0,0 @@ - - - - stopScan()} - > - - {title} - Scan a barcode or type a code to look up an item. - -
-
- e.key === "Enter" && submitSearch()} - class="min-h-11 flex-1" - /> - -
-

or use camera below

- {#if scanError} -

{scanError}

- {:else if stream} - - {:else} -

Starting camera…

- {/if} -
- -
-
-
-
diff --git a/src/lib/constants/items.ts b/src/lib/constants/items.ts deleted file mode 100644 index 90373277..00000000 --- a/src/lib/constants/items.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** UOM options for Stackq_Items (single select). */ -export const UOM_OPTIONS = ["EA", "BX", "CA", "PK", "PLT", "LF"] as const; - -/** Catagory options (single select in schema). */ -export const CATAGORY_OPTIONS = [ - "Framing", - "Insulation", - "Drywall", - "T-Bar", - "Painting", - "Masking", - "Misc", -] as const; - -/** Sub_Catagory options (single select in schema). */ -export const SUB_CATAGORY_OPTIONS = [ - "ACT", - "Channel", - "Fasteners", - "Finishing Materials", - "Adhesives", - "Mud", - "Corner Bead", - "Sanding", - "Tape", - "Metal Studs", - "Metal Tracks", - "FRP", - "Gyp", - "Insulation", - "Paint", - "Weatherproofing", - "Misc", -] as const; diff --git a/src/lib/parse-form.ts b/src/lib/parse-form.ts index ae1f1446..f3d1f022 100644 --- a/src/lib/parse-form.ts +++ b/src/lib/parse-form.ts @@ -1,5 +1,5 @@ /** - * Parse form values. Shared by items and receipts server actions. + * Parse form values. Used by receipts server actions. */ export function parseNum(val: unknown): number | undefined { diff --git a/src/lib/types/items.ts b/src/lib/types/items.ts deleted file mode 100644 index 85878076..00000000 --- a/src/lib/types/items.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** PocketBase Stackq_Items collection record (and expanded relation). */ -export interface StackqItem { - id: string; - Item: string; - SKU: string; - Description: string; - UOM: string; - Cost: number; - Vendor: string; - Catagory: string | string[]; - Sub_Catagory: string | string[]; - Has_Parent: boolean; - Parent: string; // relation id - Stock: boolean; - Image?: string; // file filename - created: string; - updated: string; - expand?: { - Parent?: { id: string; Item?: string; SKU?: string }; - }; -} diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 14a43315..3925fbbe 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,16 +1,7 @@ import type { Actions, PageServerLoad } from "./$types"; -import type { StackqItem } from "$lib/types/items"; -const COLLECTION = "Stackq_Items"; - -export const load: PageServerLoad = async ({ locals }) => { - const list = await locals.pb - .collection(COLLECTION) - .getFullList({ 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: PageServerLoad = async () => { + return {}; }; export const actions: Actions = { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 422a6805..c9a604c9 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,55 +1,16 @@ -{#if browser} - {#await import("./HomeWithDialog.svelte")} -
-

Loading…

-
- {:then { default: HomeWithDialog }} - - {/await} -{:else} -
-

Stackq

-
-
- Scan - Coming soon -
-
- New Transaction - Coming soon -
- - - -
- New Item - Coming soon -
-
-
Go to
-
-
- Items - Coming soon -
-
- Transactions - Coming soon -
- - - -
- Accounts - Coming soon -
-
-
-{/if} +
+

Stackq

+

Receipts

+ +
diff --git a/src/routes/HomeWithDialog.svelte b/src/routes/HomeWithDialog.svelte deleted file mode 100644 index 16808db8..00000000 --- a/src/routes/HomeWithDialog.svelte +++ /dev/null @@ -1,112 +0,0 @@ - - -
-

Stackq

- -
-
- Scan - Coming soon -
-
- New transaction - Coming soon -
- -
- New Item - Coming soon -
-
- -
- -
-
- Items - Coming soon -
-
- Transactions - Coming soon -
- - - -
- Accounts - Coming soon -
-
-
- - - - - New item - Add a new Stackq item. - - - - - - - - - New receipt - Add a new receipt. Optionally attach an image. - - - - - - diff --git a/src/routes/accounts/+page.server.ts b/src/routes/accounts/+page.server.ts deleted file mode 100644 index fb3f4d51..00000000 --- a/src/routes/accounts/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { PageServerLoad } from "./$types"; - -export const load: PageServerLoad = async () => { - return { accounts: [] as { id: string }[] }; -}; diff --git a/src/routes/accounts/+page.svelte b/src/routes/accounts/+page.svelte deleted file mode 100644 index 7a0f2534..00000000 --- a/src/routes/accounts/+page.svelte +++ /dev/null @@ -1,75 +0,0 @@ - - - - Accounts – Stackq - - -
-
-
- Back -

Accounts

-
-
-
- -
- - {filteredAccounts.length}{filteredAccounts.length !== accounts.length ? ` of ${accounts.length}` : ""} accounts - - - - -
-
- - {#if filteredAccounts.length === 0} - - -

- {accounts.length === 0 ? "No accounts yet." : "No accounts match your search."} -

-

- {accounts.length === 0 ? "Create an account to get started." : "Try a different search."} -

- - - - - - -
-
- {:else} -
- {#each filteredAccounts as account (account.id)} - - - Account {account.id} - - - {/each} -
- {/if} -
diff --git a/src/routes/accounts/[id]/+page.svelte b/src/routes/accounts/[id]/+page.svelte deleted file mode 100644 index 42c6f5e2..00000000 --- a/src/routes/accounts/[id]/+page.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - - - Account – Stackq - - -
-
- Back -

Account

-
- - - -

Account {params.id}

- - - -
-
-
diff --git a/src/routes/accounts/new/+page.svelte b/src/routes/accounts/new/+page.svelte deleted file mode 100644 index 4c0c3238..00000000 --- a/src/routes/accounts/new/+page.svelte +++ /dev/null @@ -1,29 +0,0 @@ - - - - New account – Stackq - - -
-
- Back -

New account

-
- - - -

Account creation will be available here.

- -
-
-
diff --git a/src/routes/items/+page.server.ts b/src/routes/items/+page.server.ts deleted file mode 100644 index ee85f455..00000000 --- a/src/routes/items/+page.server.ts +++ /dev/null @@ -1,132 +0,0 @@ -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: PageServerLoad = async ({ locals }) => { - const list = await locals.pb - .collection(COLLECTION) - .getFullList({ - 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: Actions = { - create: async ({ request, locals }) => { - 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 = { - 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 }) => { - 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 = { - 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 }) => { - 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 }; - }, -}; diff --git a/src/routes/items/+page.svelte b/src/routes/items/+page.svelte deleted file mode 100644 index 1f4a05e5..00000000 --- a/src/routes/items/+page.svelte +++ /dev/null @@ -1,92 +0,0 @@ - - - - Items – Stackq - - -{#if browser} - {#await import("./ItemsCrud.svelte")} -
-

Loading…

-
- {:then { default: ItemsCrud }} - - {/await} -{:else} -
-
-

Stackq Items

- {items.length} items -
- {#if items.length === 0} - - -

No items.

-
-
- {:else} -
- {#each items as item (item.id)} - - -
- {#if imageUrl(item)} - - {:else} - - {/if} -
-
- {item.Item ?? "—"} - · {item.SKU ?? "—"} - {#if item.Description} - · {item.Description} - {/if} -
-
- {item.UOM ?? "—"} - {item.Cost != null ? Number(item.Cost).toLocaleString() : "—"} - {#if item.Stock}Stock{/if} -
-
-
- {/each} -
- {/if} -
-{/if} diff --git a/src/routes/items/ItemForm.svelte b/src/routes/items/ItemForm.svelte deleted file mode 100644 index f9bc4dfe..00000000 --- a/src/routes/items/ItemForm.svelte +++ /dev/null @@ -1,322 +0,0 @@ - - -
async ({ update, result }) => { - await update(); - if (result.type === "success" && result.data?.success) { - onSuccess?.(); - } - }} - class="flex flex-col gap-4" -> - {#if isEdit} - - {/if} - -
-
- - -
-
- -
- - -
-
-
- - {#if showScanner} - - {/if} - -
- - -
- -
- - {#if isEdit && item?.Image} -
- - Replace: -
- {/if} - -
- -
-
- - -
-
- - -
-
- -
- - -
- -
-
- - -
-
- - -
-
- -
- - -
- -
- - -
- - {#if error} -

{error}

- {/if} - -
- -
-
diff --git a/src/routes/items/ItemsCrud.svelte b/src/routes/items/ItemsCrud.svelte deleted file mode 100644 index 4bc2b94e..00000000 --- a/src/routes/items/ItemsCrud.svelte +++ /dev/null @@ -1,254 +0,0 @@ - - - - Items – Stackq - - -
-
-
- Back -

Stackq Items

-
-
-
- -
- - {filteredItems.length}{filteredItems.length !== items.length ? ` of ${items.length}` : ""} items - -
- - -
-
-
- - {#if filteredItems.length === 0} - - -

- {items.length === 0 - ? "No items. Create one or check PocketBase collection name and auth." - : "No items match your search."} -

-
-
- {:else} -
- {#each filteredItems as item (item.id)} - - -
- {#if imageUrl(item)} - - - - {:else} - - {/if} -
-
- {item.Item ?? "—"} - · {item.SKU ?? "—"} - {#if item.Description} - · {item.Description} - {/if} -
-
- {item.UOM ?? "—"} - {item.Cost != null ? Number(item.Cost).toLocaleString() : "—"} - {#if item.Stock}Stock{/if} -
- - - Actions - - - - goto("/items/" + item.id)}>View - openEdit(item)}>Edit - - { - if (confirm("Delete this item? This cannot be undone.")) { - document.getElementById("delete-form-" + item.id)?.requestSubmit(); - } - }} - > - Delete - - - - -
-
- {/each} -
- {/if} - - - - - {editingItem ? "Edit item" : "New item"} - - {editingItem ? "Update the item below." : "Add a new Stackq item."} - - - - - - - -
diff --git a/src/routes/items/[id]/+page.server.ts b/src/routes/items/[id]/+page.server.ts deleted file mode 100644 index 93076181..00000000 --- a/src/routes/items/[id]/+page.server.ts +++ /dev/null @@ -1,85 +0,0 @@ -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: PageServerLoad = async ({ params, locals }) => { - const id = params.id; - if (!id) throw error(404, "Item not found"); - - try { - const item = await locals.pb - .collection(COLLECTION) - .getOne(id, { expand: "Parent" }); - const list = await locals.pb - .collection(COLLECTION) - .getFullList({ 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: Actions = { - update: async ({ request, locals, params }) => { - 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 = { - 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 }) => { - 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"); - }, -}; diff --git a/src/routes/items/[id]/+page.svelte b/src/routes/items/[id]/+page.svelte deleted file mode 100644 index e5eea4a3..00000000 --- a/src/routes/items/[id]/+page.svelte +++ /dev/null @@ -1,212 +0,0 @@ - - - - {item?.Item ?? "Item"} – Stackq - - -{#if item} -
-
- Home - Back to items -

{item.Item ?? "—"}

- {#if browser} -
- -
- -
-
- {/if} -
- -
- - -

Details

-
- - {#if imageUrl(item)} -
- - - -
- {/if} -
-
-
SKU
-
{item.SKU ?? "—"}
-
-
-
Description
-
{item.Description ?? "—"}
-
-
-
UOM
-
{item.UOM ?? "—"}
-
-
-
Cost
-
{item.Cost != null ? Number(item.Cost).toLocaleString() : "—"}
-
-
-
Vendor
-
{item.Vendor ?? "—"}
-
-
-
Category
-
- {#each asList(item.Catagory) as cat} - {cat} - {/each} - {#if asList(item.Catagory).length === 0}—{/if} -
-
-
-
Sub-category
-
- {#each asList(item.Sub_Catagory) as sub} - {sub} - {/each} - {#if asList(item.Sub_Catagory).length === 0}—{/if} -
-
-
-
Has Parent
-
{item.Has_Parent ? "Yes" : "No"}
-
- {#if item.Has_Parent && item.expand?.Parent} - - {/if} -
-
Stock
-
{item.Stock ? "Yes" : "No"}
-
-
-
Created
-
{formatDate(item.created)}
-
-
-
Updated
-
{formatDate(item.updated)}
-
-
-
-
-
-
- - {#if browser} - - - - Edit item - Update the item below. - - (dialogOpen = false)} - /> - - - {/if} -{:else} -
-

Item not found.

-
-{/if} diff --git a/src/routes/transactions/+page.server.ts b/src/routes/transactions/+page.server.ts deleted file mode 100644 index 2bbcb9a6..00000000 --- a/src/routes/transactions/+page.server.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { PageServerLoad } from "./$types"; - -export const load: PageServerLoad = async () => { - return { transactions: [] as { id: string }[] }; -}; diff --git a/src/routes/transactions/+page.svelte b/src/routes/transactions/+page.svelte deleted file mode 100644 index 33b6d977..00000000 --- a/src/routes/transactions/+page.svelte +++ /dev/null @@ -1,75 +0,0 @@ - - - - Transactions – Stackq - - -
-
-
- Back -

Transactions

-
-
-
- -
- - {filteredTransactions.length}{filteredTransactions.length !== transactions.length ? ` of ${transactions.length}` : ""} transactions - - - - -
-
- - {#if filteredTransactions.length === 0} - - -

- {transactions.length === 0 ? "No transactions yet." : "No transactions match your search."} -

-

- {transactions.length === 0 ? "Create a transaction to get started." : "Try a different search."} -

- - - - - - -
-
- {:else} -
- {#each filteredTransactions as tx (tx.id)} - - - Transaction {tx.id} - - - {/each} -
- {/if} -
diff --git a/src/routes/transactions/[id]/+page.svelte b/src/routes/transactions/[id]/+page.svelte deleted file mode 100644 index ce566d9e..00000000 --- a/src/routes/transactions/[id]/+page.svelte +++ /dev/null @@ -1,26 +0,0 @@ - - - - Transaction – Stackq - - -
-
- Back -

Transaction

-
- - - -

Transaction {params.id}

- - - -
-
-
diff --git a/src/routes/transactions/new/+page.svelte b/src/routes/transactions/new/+page.svelte deleted file mode 100644 index b1da88f8..00000000 --- a/src/routes/transactions/new/+page.svelte +++ /dev/null @@ -1,29 +0,0 @@ - - - - New transaction – Stackq - - -
-
- Back -

New transaction

-
- - - -

Transaction creation will be available here.

- -
-
-