PageSourceSearch

https://goneat.co.uk/assets/edit-sQrF2oIq.js

js goneat.co.uk collected 2026-09-24 15:14:57 UTC 4,563 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-D1Mshrk-.js";import{d as T,u as I,r as a,L as B}from"./vendor-react-BfQMi0FG.js";import{e as o,B as h,q as H,j as W,L as t,I as m,r as F,t as i}from"./index-D3kn74s7.js";import{C as D,d as y,a as K,b as R,c as q}from"./card-C6DfUXn8.js";import{S as U}from"./switch-vuioQ0-X.js";import{S as V,a as O,b as z,c as G,d as p}from"./select-Da-jnnzS.js";import{A as J,a as M,b as Q,c as X,d as Y,e as Z,f as _,g as $}from"./alert-dialog-D07W3RYy.js";import{u as ee,b as se,c as re}from"./use-printers-DJv_hCJ4.js";import{P as ae}from"./page-header-C7x1KRLA.js";import"./vendor-ui-nQy3bJlE.js";import"./check-CXo9hMCb.js";function xe(){const{id:n}=T(),w=I(),{data:A,isLoading:b}=ee(),l=se(),u=re(),r=A?.find(s=>s.id===n)??null,[c,x]=a.useState(""),[j,g]=a.useState("KITCHEN"),[d,v]=a.useState(""),[f,C]=a.useState("48"),[N,P]=a.useState(!0),[L,S]=a.useState(!1);a.useEffect(()=>{r&&(x(r.name),g(r.type),v(r.paperWidth?String(r.paperWidth):""),C(String(r.charactersPerLine??48)),P(r.isActive))},[r]);const E=()=>{if(!c.trim()){i.error("Name is required");return}l.mutate({id:n,data:{name:c.trim(),type:j,...d?{paperWidth:Number(d)}:{},charactersPerLine:Number(f)||48,isActive:N}},{onSuccess:()=>i.success("Printer updated"),onError:s=>{i.error(s?.response?.data?.error?.message||"Failed to update printer")}})},k=()=>{u.mutate(n,{onSuccess:()=>{i.success("Printer deleted"),w("/dashboard/printers")},onError:()=>i.error("Failed to delete printer")})};return b?e.jsxs("div",{className:"space-y-6",children:[e.jsx(o,{className:"h-8 w-64"}),e.jsx(D,{children:e.jsxs(y,{className:"space-y-4 pt-6",children:[e.jsx(o,{className:"h-10 w-full"}),e.jsx(o,{className:"h-10 w-full"})]})})]}):r?e.jsxs("div",{className:"space-y-6",children:[e.jsx(ae,{title:"Edit Printer",action:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{variant:"outline",asChild:!0,children:e.jsxs(B,{to:"/dashboard/printers",children:[e.jsx(H,{className:"mr-2 h-4 w-4"}),"Back"]})}),e.jsxs(h,{variant:"destructive",onClick:()=>S(!0),children:[e.jsx(W,{className:"mr-2 h-4 w-4"}),"Delete"]})]})}),e.jsxs(D,{children:[e.jsxs(K,{children:[e.jsx(R,{children:"Printer Details"}),e.jsx(q,{children:"Define the printer's identity and paper settings. Connection details (IP, USB path) are configured per workstation."})]}),e.jsxs(y,{className:"space-y-4",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{children:"Name *"}),e.jsx(m,{value:c,onChange:s=>x(s.target.value),placeholder:"e.g. Hot Kitchen, Bar Printer"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{children:"Type"}),e.jsxs(V,{value:j,onValueChange:s=>g(s),children:[e.jsx(O,{children:e.jsx(z,{})}),e.jsxs(G,{children:[e.jsx(p,{value:"RECEIPT",children:"Receipt"}),e.jsx(p,{value:"KITCHEN",children:"Kitchen"}),e.jsx(p,{value:"LABEL",children:"Label"})]})]})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{children:"Paper Width (mm)"}),e.jsx(m,{type:"number",value:d,onChange:s=>v(s.target.value),placeholder:"e.g. 80"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{children:"Characters Per Line"}),e.jsx(m,{type:"number",value:f,onChange:s=>C(s.target.value),placeholder:"e.g. 48 (80mm), 42, 32 (58mm)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Set so the receipt's dashed line spans the paper without wrapping — 80mm is usually 48, narrower thermal printers often need 42."})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx(U,{checked:N,onCheckedChange:P}),e.jsx(t,{children:"Active"})]})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(h,{onClick:E,disabled:l.isPending,children:l.isPending?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})}),e.jsx(J,{open:L,onOpenChange:S,children:e.jsxs(M,{children:[e.jsxs(Q,{children:[e.jsx(X,{children:"Delete Printer"}),e.jsxs(Y,{children:["Are you sure you want to delete ",e.jsx("strong",{children:r.name}),"? This will remove it from all workstation assignments and clear printer assignments from categories/products."]})]}),e.jsxs(Z,{children:[e.jsx(_,{children:"Cancel"}),e.jsx($,{onClick:k,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:u.isPending?"Deleting...":"Delete"})]})]})})]}):e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Printer not found."})}
1export{xe as PrinterEditPage};

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.