168 lines
8.6 KiB
JavaScript
168 lines
8.6 KiB
JavaScript
import { x as head, t as escape_html, o as attributes, B as clsx, d as bind_props, q as attr, y as ensure_array_like, z as stringify } from './index2-C1QMSCIx.js';
|
||
import './button-rjWrqfIB.js';
|
||
import { C as Card, a as Card_content } from './card-content-kqme4GTP.js';
|
||
import 'clsx';
|
||
import { c as cn } from './utils-B05Dmz_H.js';
|
||
import './root-DLMkITFa.js';
|
||
import './state.svelte-BAMO-hRC.js';
|
||
import PocketBase from 'pocketbase';
|
||
import './index-CoNVFdnx.js';
|
||
import 'tailwind-merge';
|
||
|
||
function Card_header($$renderer, $$props) {
|
||
$$renderer.component(($$renderer2) => {
|
||
let {
|
||
ref = null,
|
||
class: className,
|
||
children,
|
||
$$slots,
|
||
$$events,
|
||
...restProps
|
||
} = $$props;
|
||
$$renderer2.push(`<div${attributes({
|
||
"data-slot": "card-header",
|
||
class: clsx(cn("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6", className)),
|
||
...restProps
|
||
})}>`);
|
||
children?.($$renderer2);
|
||
$$renderer2.push(`<!----></div>`);
|
||
bind_props($$props, { ref });
|
||
});
|
||
}
|
||
const POCKETBASE_URL = "https://pocketbase.ccllc.pro";
|
||
const POCKETBASE_BASE_URL = POCKETBASE_URL;
|
||
let _pb = null;
|
||
function getPb() {
|
||
if (typeof window === "undefined") {
|
||
throw new Error("PocketBase client is only available in the browser. Use load/actions for server data.");
|
||
}
|
||
if (!_pb) _pb = new PocketBase(POCKETBASE_URL);
|
||
return _pb;
|
||
}
|
||
new Proxy({}, {
|
||
get(_, prop) {
|
||
if (prop === "baseUrl") return POCKETBASE_BASE_URL;
|
||
return getPb()[prop];
|
||
}
|
||
});
|
||
function _page($$renderer, $$props) {
|
||
$$renderer.component(($$renderer2) => {
|
||
let { data } = $$props;
|
||
const item = data?.item;
|
||
data?.itemsForParent ?? [];
|
||
const PB_BASE = "https://pocketbase.ccllc.pro";
|
||
const COLLECTION = "Stackq_Items";
|
||
function imageUrl(i) {
|
||
if (!i?.Image) return null;
|
||
return `${PB_BASE}/api/files/${COLLECTION}/${i.id}/${i.Image}`;
|
||
}
|
||
function asList(val) {
|
||
if (val == null) return [];
|
||
return Array.isArray(val) ? val : [val];
|
||
}
|
||
function formatDate(iso) {
|
||
if (!iso) return "—";
|
||
try {
|
||
return new Date(iso).toLocaleDateString(void 0, { dateStyle: "short", timeStyle: "short" });
|
||
} catch {
|
||
return iso;
|
||
}
|
||
}
|
||
data?.form === "update" ? data?.error ?? null : null;
|
||
let $$settled = true;
|
||
let $$inner_renderer;
|
||
function $$render_inner($$renderer3) {
|
||
head("1r2vy7b", $$renderer3, ($$renderer4) => {
|
||
$$renderer4.title(($$renderer5) => {
|
||
$$renderer5.push(`<title>${escape_html(item?.Item ?? "Item")} – Stackq</title>`);
|
||
});
|
||
});
|
||
if (item) {
|
||
$$renderer3.push("<!--[-->");
|
||
$$renderer3.push(`<main class="container mx-auto flex flex-col gap-4 px-4 py-6 sm:gap-6 sm:px-6 sm:py-8"><div class="flex flex-wrap items-center gap-2 sm:gap-4 min-w-0"><a href="/" class="text-muted-foreground hover:text-foreground shrink-0 text-sm" title="Back to main">Home</a> <a href="/items" class="text-muted-foreground hover:text-foreground shrink-0 text-sm" title="Back to items">Back to items</a> <h1 class="text-xl font-semibold truncate min-w-0 flex-1 sm:text-2xl">${escape_html(item.Item ?? "—")}</h1> `);
|
||
{
|
||
$$renderer3.push("<!--[!-->");
|
||
}
|
||
$$renderer3.push(`<!--]--></div> <div class="grid gap-6 md:grid-cols-2">`);
|
||
Card($$renderer3, {
|
||
children: ($$renderer4) => {
|
||
Card_header($$renderer4, {
|
||
children: ($$renderer5) => {
|
||
$$renderer5.push(`<h2 class="text-lg font-medium">Details</h2>`);
|
||
},
|
||
$$slots: { default: true }
|
||
});
|
||
$$renderer4.push(`<!----> `);
|
||
Card_content($$renderer4, {
|
||
class: "space-y-4",
|
||
children: ($$renderer5) => {
|
||
if (imageUrl(item)) {
|
||
$$renderer5.push("<!--[-->");
|
||
$$renderer5.push(`<div><a${attr("href", imageUrl(item))} target="_blank" rel="noopener noreferrer" class="block overflow-hidden rounded-lg border"><img${attr("src", imageUrl(item))} alt="" class="max-h-64 w-full object-contain"/></a></div>`);
|
||
} else {
|
||
$$renderer5.push("<!--[!-->");
|
||
}
|
||
$$renderer5.push(`<!--]--> <dl class="grid gap-2 text-sm"><div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">SKU</dt> <dd class="font-mono">${escape_html(item.SKU ?? "—")}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Description</dt> <dd>${escape_html(item.Description ?? "—")}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">UOM</dt> <dd>${escape_html(item.UOM ?? "—")}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Cost</dt> <dd>${escape_html(item.Cost != null ? Number(item.Cost).toLocaleString() : "—")}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Vendor</dt> <dd>${escape_html(item.Vendor ?? "—")}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Category</dt> <dd><!--[-->`);
|
||
const each_array = ensure_array_like(asList(item.Catagory));
|
||
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
||
let cat = each_array[$$index];
|
||
$$renderer5.push(`<span class="mr-1 rounded bg-muted px-1.5 py-0.5 text-xs">${escape_html(cat)}</span>`);
|
||
}
|
||
$$renderer5.push(`<!--]--> `);
|
||
if (asList(item.Catagory).length === 0) {
|
||
$$renderer5.push("<!--[-->");
|
||
$$renderer5.push(`—`);
|
||
} else {
|
||
$$renderer5.push("<!--[!-->");
|
||
}
|
||
$$renderer5.push(`<!--]--></dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Sub-category</dt> <dd><!--[-->`);
|
||
const each_array_1 = ensure_array_like(asList(item.Sub_Catagory));
|
||
for (let $$index_1 = 0, $$length = each_array_1.length; $$index_1 < $$length; $$index_1++) {
|
||
let sub = each_array_1[$$index_1];
|
||
$$renderer5.push(`<span class="mr-1 rounded border px-1.5 py-0.5 text-xs">${escape_html(sub)}</span>`);
|
||
}
|
||
$$renderer5.push(`<!--]--> `);
|
||
if (asList(item.Sub_Catagory).length === 0) {
|
||
$$renderer5.push("<!--[-->");
|
||
$$renderer5.push(`—`);
|
||
} else {
|
||
$$renderer5.push("<!--[!-->");
|
||
}
|
||
$$renderer5.push(`<!--]--></dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Has Parent</dt> <dd>${escape_html(item.Has_Parent ? "Yes" : "No")}</dd></div> `);
|
||
if (item.Has_Parent && item.expand?.Parent) {
|
||
$$renderer5.push("<!--[-->");
|
||
$$renderer5.push(`<div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Parent</dt> <dd><a${attr("href", `/items/${stringify(item.Parent)}`)} class="text-primary hover:underline">${escape_html(item.expand.Parent.Item ?? item.expand.Parent.SKU ?? item.Parent)}</a></dd></div>`);
|
||
} else {
|
||
$$renderer5.push("<!--[!-->");
|
||
}
|
||
$$renderer5.push(`<!--]--> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Stock</dt> <dd>${escape_html(item.Stock ? "Yes" : "No")}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Created</dt> <dd>${escape_html(formatDate(item.created))}</dd></div> <div class="flex gap-2"><dt class="text-muted-foreground w-24 shrink-0">Updated</dt> <dd>${escape_html(formatDate(item.updated))}</dd></div></dl>`);
|
||
},
|
||
$$slots: { default: true }
|
||
});
|
||
$$renderer4.push(`<!---->`);
|
||
},
|
||
$$slots: { default: true }
|
||
});
|
||
$$renderer3.push(`<!----></div></main> `);
|
||
{
|
||
$$renderer3.push("<!--[!-->");
|
||
}
|
||
$$renderer3.push(`<!--]-->`);
|
||
} else {
|
||
$$renderer3.push("<!--[!-->");
|
||
$$renderer3.push(`<main class="container mx-auto py-8"><p class="text-muted-foreground">Item not found.</p></main>`);
|
||
}
|
||
$$renderer3.push(`<!--]-->`);
|
||
}
|
||
do {
|
||
$$settled = true;
|
||
$$inner_renderer = $$renderer2.copy();
|
||
$$render_inner($$inner_renderer);
|
||
} while (!$$settled);
|
||
$$renderer2.subsume($$inner_renderer);
|
||
});
|
||
}
|
||
|
||
export { _page as default };
|
||
//# sourceMappingURL=_page.svelte-DHelfZB3.js.map
|