PageSourceSearch

https://splashiq.ai/assets/branding-WP6URE2C.js

js splashiq.ai collected 2026-10-05 12:43:23 UTC 10,130 bytes, 1 lines download raw bytes

1import{j as e,r as s,s as d,ar as R,B as y,as as L,I as _,X as U,t as c,at as E}from"./index-CzAkNt2W.js";import{L as p}from"./label-BwWVuV93.js";import{T as F}from"./textarea-CMw1Ny2O.js";import{P as I,g as q}from"./PdfPreviewDialog-CYGxYJM5.js";import{Q as B}from"./QuickBooksCard-DWwbuiWe.js";import{R as O}from"./RequireRole-DhUlFC_T.js";import{U as T}from"./upload-C3gfurJP.js";import"./dialog-DFazxlVc.js";import"./jspdf.es.min-DlZwYFgk.js";import"./loader-circle-B0UeYsVT.js";import"./printer-C3BfX3tt.js";import"./download-C5tX2Uho.js";import"./useServerFn-7MfwXlwR.js";import"./quickbooks.functions-BN4UC_sd.js";import"./circle-check-gM2QolJ6.js";import"./refresh-cw-DeA5DQmv.js";const D=["#0ea5e9","#0284c7","#0d9488","#16a34a","#ea580c","#dc2626","#7c3aed","#1e293b"];function A(){const[l,u]=s.useState(null),[o,t]=s.useState({name:"",logo_url:null,brand_color:"#0ea5e9",report_footer:"",report_cover_enabled:!0,report_include_photos:!0,report_include_notes:!0,chat_route_to:"technician",labor_rate_cents:12500}),[w,m]=s.useState(!0),[x,b]=s.useState(!1),[h,f]=s.useState(!1),[N,j]=s.useState(!1);s.useEffect(()=>{(async()=>{const r=await d.auth.getUser();if(!r.data.user){m(!1);return}const{data:n}=await d.from("profiles").select("company_id").eq("id",r.data.user.id).single(),i=n?.company_id??null;if(u(i),!i){m(!1);return}const{data:a}=await d.from("companies").select("id, name, logo_url, brand_color, report_footer, report_cover_enabled, report_include_photos, report_include_notes, chat_route_to, labor_rate_cents").eq("id",i).single();a&&t({name:a.name,logo_url:a.logo_url??null,brand_color:a.brand_color??"#0ea5e9",report_footer:a.report_footer??"",report_cover_enabled:a.report_cover_enabled??!0,report_include_photos:a.report_include_photos??!0,report_include_notes:a.report_include_notes??!0,chat_route_to:a.chat_route_to??"technician",labor_rate_cents:a.labor_rate_cents??12500}),m(!1)})()},[]);async function v(r){if(l){f(!0);try{const n=r.name.split(".").pop()?.toLowerCase()||"png",i=`branding/${l}/logo-${Date.now()}.${n}`,{error:a}=await d.storage.from("visit-photos").upload(i,r,{upsert:!0,contentType:r.type});if(a)throw a;const{data:S}=d.storage.from("visit-photos").getPublicUrl(i);t(P=>({...P,logo_url:S.publicUrl})),c.success("Logo uploaded")}catch(n){c.error(n instanceof Error?n.message:"Upload failed")}finally{f(!1)}}}async function C(){if(!l)return;b(!0);const{error:r}=await d.from("companies").update({name:o.name,logo_url:o.logo_url,brand_color:o.brand_color,report_footer:o.report_footer||null,report_cover_enabled:o.report_cover_enabled,report_include_photos:o.report_include_photos,report_include_notes:o.report_include_notes,chat_route_to:o.chat_route_to,labor_rate_cents:o.labor_rate_cents}).eq("id",l);if(b(!1),r)return c.error(r.message);c.success("Branding saved")}async function k(){return q({address:"123 Sample Lane",city:"Sunnyvale",state:"CA",zip:"94086",customer_name:"Jane Sample"},[{kind:"Pump",brand:"Pentair",model_number:"IntelliFlo VSF",installed_on:"2023-03-12",warranty_until:"2026-03-12",condition:"good",notes:"Qu
1iet operation, serviced last quarter.",photo_url:o.logo_url,photo_taken_at:new Date().toISOString(),photo_notes:"Photo of equipment in good condition during routine inspection."},{kind:"Filter",brand:"Hayward",model_number:"C4030",installed_on:"2022-06-01",warranty_until:null,condition:"fair",notes:"Cartridges due for replacement next visit.",photo_url:null,photo_taken_at:null,photo_notes:null}],{company_name:o.name||"Your Company",logo_url:o.logo_url,brand_color:o.brand_color,report_footer:o.report_footer,report_cover_enabled:o.report_cover_enabled,report_include_photos:o.report_include_photos,report_include_notes:o.report_include_notes})}return w?e.jsx("div",{className:"p-8 text-muted-foreground",children:"Loading…"}):e.jsxs("div",{className:"p-6 md:p-8 max-w-4xl",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"font-display text-3xl font-bold flex items-center gap-2",children:[e.jsx(R,{className:"h-7 w-7 text-primary"})," Branding & Report Template"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Customize how your exported property PDF reports look."})]}),e.jsxs(y,{variant:"outline",className:"gap-2",onClick:()=>j(!0),children:[e.jsx(L,{className:"h-4 w-4"})," Preview PDF"]})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsxs("section",{className:"rounded-xl border border-border bg-card p-5 space-y-4",children:[e.jsx("h2",{className:"font-display text-lg font-semibold",children:"Brand"}),e.jsxs("div",{children:[e.jsx(p,{children:"Company name"}),e.jsx(_,{value:o.name,onChange:r=>t({...o,name:r.target.value})})]}),e.jsxs("div",{children:[e.jsx(p,{children:"Logo"}),o.logo_url?e.jsxs("div",{className:"mt-1 flex items-center gap-3",children:[e.jsxs("div",{className:"relative h-20 w-20 rounded-lg border border-border bg-secondary grid place-items-center overflow-hidden",children:[e.jsx("img",{src:o.logo_url,alt:"Logo",className:"max-h-full max-w-full object-contain"}),e.jsx("button",{type:"button",onClick:()=>t({...o,logo_url:null}),className:"absolute top-1 right-1 h-5 w-5 rounded-full bg-background/90 grid place-items-center hover:bg-background","aria-label":"Remove",children:e.jsx(U,{className:"h-3 w-3"})})]}),e.jsxs("label",{className:"text-sm text-primary hover:underline cursor-pointer",children:["Replace",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:h,onChange:r=>{const n=r.target.files?.[0];n&&v(n),r.target.value=""}})]})]}):e.jsxs("label",{className:"mt-1 flex items-center justify-center gap-2 h-20 rounded-lg border border-dashed border-border cursor-pointer hover:bg-muted/40 text-sm text-muted-foreground",children:[h?"Uploading…":e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"h-4 w-4"})," Upload logo (PNG, JPG)"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:h,onChange:r=>{const n=r.target.files?.[0];n&&v(n),r.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(p,{children:"Accent color"}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx("input",{type:"color",value:o.brand_color??"#0ea5e9",onChange:r=>t({...o,brand_color:r.target.value}),className:"h-9 w-12 rounded border border-input bg-transparent cursor-pointer"}),e.jsx(_,{value:o.brand_color??"",onChange:r=>t({...o,brand_color:r.target.value}),className:"font-mono w-32"}),e.jsx("div",{className:"flex gap-1 flex-wrap",children:D.map(r=>e.jsx("button",{type:"button",onClick:()=>t({...o,brand_color:r}),className:"h-7 w-7 rounded-full border-2 border-border hover:scale-110 transition-transform",style:{background:r,borderColor:o.brand_color===r?"currentColor":void 0},"aria-label":r},r))})]})]})]}),e.jsxs("section",{className:"rounded-xl border border-border bg-card p-5 space-y-4",children:[e.jsx("h2",{className:"font-display text-lg font-semibold",children:"Report Template"}),e.jsx(g,{label:"Include cover page",desc:"Adds a branded first page with logo and property info.",checked:o.report_cover_enabled,onChange:r=>t({...o,report_cover_enabled:r})}),e.jsx(g,{label:"Include equipment photos",desc:"Embed each item's photo in the report.",checked:o.report_include_photos,onChange:r=>t({...o,report_include_photos:r})}),e.jsx(g,{label:"Include technician notes",desc:"Show photo notes and item notes.",checked:o.report_include_notes,onChange:r=>t({...o,report_include_notes:r})}),e.jsxs("div",{children:[e.jsx(p,{children:"Footer text"}),e.jsx(F,{rows:2,value:o.report_footer??"",onChange:r=>t({...o,report_footer:r.target.value}),placeholder:"e.g. Confidential — prepared for client use only."})]})]})]}),e.jsxs("section",{className:"mt-6 rounded-xl border border-border bg-card p-5 space-y-4",children:[e.jsx("h2",{className:"font-display text-lg font-semibold",children:"Homeowner chat routing"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Decide where homeowner messages from the portal land by default."}),e.jsx("div",{className:"grid grid-cols-2 gap-3 max-w-md",children:["technician","office"].map(r=>e.jsxs("button",{type:"button",onClick:()=>t({...o,chat_route_to:r}),className:`text-left rounded-xl border p-4 transition-colors ${o.chat_route_to===r?"border-primary bg-sky":"border-border hover:bg-muted"}`,children:[e.jsx("div",{className:"font-medium capitalize",children:r==="technician"?"Assigned technician":"Office seat"}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:r==="technician"?"Routes directly to the tech assigned to the property.":"All chats go to owner/office staff."})]},r))})]}),e.jsxs("section",{className:"mt-6 rounded-xl border border-border bg-card p-5 space-y-3",children:[e.jsx("h2",{className:"font-display text-lg font-semibold",children:"Labor rate"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Used by the estimate builder when adding labor lines for catalog items."}),e.jsxs("div",{className:"flex items-center gap-2 max-w-xs",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"$"}),e.jsx(_,{type:"number",min:0,step:"0.01",value:(o.labor_rate_cents/100).toFixed(2),onChange:r=>t({...o,labor_rate_cents:Math.round(parseFloat(r.target.value||"0")*100)}),className:"w-32"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"/ hour"})]})]}),e.jsx(B,{}),e.jsx("div",{className:"mt-6 flex justify-end gap-2",children:e.jsx(y,{onClick:C,disabled:x,className:"min-w-32",children:x?"Saving…":"Save changes"})}),e.jsx(I,{open:N,onOpenChange:j,title:"Report preview",filename:"branding-preview.pdf",build:k})]})}function g({label:l,desc:u,checked:o,onChange:t}){return e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-medium",children:l}),e.jsx("div",{className:"text-xs text-muted-foreground",children:u})]}),e.jsx(E,{checked:o,onCheckedChange:t})]})}const te=()=>e.jsx(O,{allowed:["owner","company_marketing"],children:e.jsx(A,{})});
1export{te as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.