PageSourceSearch

https://shrewsburytown.com/assets/index-D4RNg6GW.js

js shrewsburytown.com collected 2026-09-24 23:52:29 UTC 6,238 bytes, 1 lines download raw bytes

1import{N as y,a7 as f,kM as b,r as x,kN as v,j as e,L as C,kO as w}from"./index-Cz_StzOF.js";import{u as L}from"./useSuspenseQuery-C53WRaHC.js";import{u as P}from"./useMutation-RM-FUt2U.js";import{B as u}from"./button-DLLlTj8W.js";import{f as N}from"./formatters-qSkgBxja.js";function k({keyword:r,page:p}){const i=y({from:"/admin/commercial/partners"}),h=f(),{data:c}=L(b({keyword:r,page:p})),[d,g]=x.useState(r??""),[m,o]=x.useState(!1),[t,s]=x.useState({name:"",contactName:"",contactEmail:"",contactPhone:"",website:"",notes:"",addressLine1:"",addressLine2:"",city:"",county:"",postcode:""});function j(){s({name:"",contactName:"",contactEmail:"",contactPhone:"",website:"",notes:"",addressLine1:"",addressLine2:"",city:"",county:"",postcode:""})}const l=P({mutationFn:()=>v({data:{name:t.name.trim(),contactName:t.contactName.trim()||null,contactEmail:t.contactEmail.trim()||null,contactPhone:t.contactPhone.trim()||null,website:t.website.trim()||null,notes:t.notes.trim()||null,addressLine1:t.addressLine1.trim()||null,addressLine2:t.addressLine2.trim()||null,city:t.city.trim()||null,county:t.county.trim()||null,postcode:t.postcode.trim()||null}}),onSuccess:async a=>{await h.invalidateQueries({queryKey:["commercial","partners"]}),o(!1),j(),i({to:"/admin/commercial/partners/$partnerId",params:{partnerId:a.id}})}});return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsx("div",{className:"flex gap-2 text-sm",children:e.jsx("input",{className:"rounded border bg-background px-2 py-1",onBlur:()=>i({search:{keyword:d.trim()||void 0}}),onChange:a=>g(a.target.value),placeholder:"Starts with…",value:d})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{onClick:()=>o(!0),children:"+ Add partner"}),e.jsx("a",{className:"text-muted-foreground text-sm underline",href:"/api/admin/commercial/export?type=partners",children:"Export CSV"})]})]}),m?e.jsxs("form",{className:"space-y-3 rounded-md border bg-card p-4 text-sm",onSubmit:a=>{a.preventDefault(),t.name.trim()&&!l.isPending&&l.mutate()},children:[e.jsx("h2",{className:"font-medium",children:"New partner"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3 lg:grid-cols-2",children:[e.jsx(n,{autoFocus:!0,label:"Partner name *",onChange:a=>s({...t,name:a}),required:!0,value:t.name}),e.jsx(n,{label:"Website",onChange:a=>s({...t,website:a}),placeholder:"https://…",value:t.website}),e.jsx(n,{label:"Contact name",onChange:a=>s({...t,contactName:a}),value:t.contactName}),e.jsx(n,{label:"Contact email",onChange:a=>s({...t,contactEmail:a}),type:"email",value:t.contactEmail}),e.jsx(n,{label:"Contact phone",onChange:a=>s({...t,contactPhone:a}),type:"tel",value:t.contactPhone}),e.jsx(n,{className:"lg:col-span-2",label:"Address line 1",onChange:a=>s({...t,addressLine1:a}),value:t.addressLine1}),e.jsx(n,{className:"lg:col-span-2",label:"Address line 2",onChange:a=>s({...t,addressLine2:a}),value:t.addressLine2}),e.jsx(n,{label:"City",onChange:a=>s({...t,city:a}),value:t.city}),e.jsx(n,{label:"County",onChange:a=>s({...t,county:a}),value:t.county}),e.jsx(n,{label:"Postcode",onChange:a=>s({...t,postcode:a}),value:t.postcode})]}),e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Notes"}),e.jsx("textarea",{className:"min-h-16 rounded border bg-background px-2 py-1",onChange:a=>s({...t,notes:a.target.value}),value:t.notes})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{disabled:!t.name.trim()||l.isPending,type:"submit",children:l.isPending?"Creating…":"Create partner"}),e.jsx(u,{onClick:()=>{o(!1),j()},type:"button",variant:"outline",children:"Cancel"})]}),l.isError?e.jsx("p",{className:"text-destructive text-xs",children:l.error instanceof Error?l.error.message:"Failed to create partner."}):null]}):null,e.jsx("div",{className:"overflow-x-auto rounded-md border bg-card",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/40 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-2 py-2",children:"Name"}),e.jsx("th",{className:"px-2 py-2",children:"Contact"}),e.jsx("th",{className:"px-2 py-2",children:"Opportunities"}),e.jsx("th",{className:"px-2 py-2",children:"Total value"}),e.jsx("th",{className:"px-2 py-2",children:"Outstanding"})]})}),e.jsx("tbody",{children:c.rows.length===0?e.jsx("tr",{children:e.jsxs("td",{className:"px-3 py-8 text-center text-muted-foreground",colSpan:5,children:["No partners yet."," ",m?null:e.jsx(u,{onClick:()=>o(!0),size:"sm",variant:"link",children:"+ Add the first one"})]})}):c.rows.map(a=>e.jsxs("tr",{className:"border-t hover:bg-muted/30",children:[e.jsx("td",{className:"px-2 py-1",children:e.jsx(C,{className:"text-primary hover:underline",params:{partnerId:a.id},to:"/admin/commercial/partners/$partnerId",children:a.name})}),e.jsxs("td",{className:"px-2 py-1 text-muted-foreground",children:[a.contactName??"—",a.contactEmail?e.jsxs("span",{className:"ml-1 text-xs",children:["· ",a.contactEmail]}):null]}),e.jsx("td",{className:"px-2 py-1 tabular-nums",children:a.dealCount}),e.jsx("td",{className:"px-2 py-1 tabular-nums",children:N(a.totalValuePence)}),e.jsx("td",{className:"px-2 py-1 tabular-nums",children:a.outstandingPence>0?e.jsx("strong",{children:N(a.outstandingPence)}):"—"})]},a.id))})]})}),e.jsxs("div",{className:"text-muted-foreground text-sm",children:[c.total.toLocaleStr
1ing()," partners · page ",c.page]})]})}function n({label:r,value:p,onChange:i,placeholder:h,type:c="text",required:d,autoFocus:g,className:m=""}){return e.jsxs("label",{className:`flex flex-col gap-1 ${m}`,children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:r}),e.jsx("input",{autoFocus:g,className:"rounded border bg-background px-2 py-1",onChange:o=>i(o.target.value),placeholder:h,required:d,type:c,value:p})]})}function I(){const r=w.useSearch();return e.jsxs("div",{className:"px-4 py-6",children:[e.jsx("h1",{className:"mb-4 font-semibold text-2xl",children:"Partners"}),e.jsx(x.Suspense,{fallback:e.jsx("p",{className:"text-muted-foreground",children:"Loading…"}),children:e.jsx(k,{keyword:r.keyword,page:r.page})})]})}export{I 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.