3import React, { useState, useEffect } from 'react';
4import { Icon } from '@/contexts/IconContext';
6interface ProfileUsage {
12export default function ReceiptPrintersPage() {
13 const [profileUsage, setProfileUsage] = useState<ProfileUsage[]>([
14 { id: 0, name: 'No Profile', used: 0 },
15 { id: 1, name: 'Profile 1', used: 0 },
16 { id: 2, name: 'Profile 2', used: 0 },
17 { id: 3, name: 'Profile 3', used: 0 },
18 { id: 4, name: 'Profile 4', used: 0 },
19 { id: 5, name: 'Profile 5', used: 0 },
20 { id: 6, name: 'Profile 6', used: 0 },
21 { id: 7, name: 'Profile 7', used: 0 },
22 { id: 8, name: 'Profile 8', used: 0 },
29 const loadData = async () => {
31 // Load profile usage and settings
32 console.log('Loading receipt printer settings...');
33 // Mock data would go here
35 console.error('Error loading receipt printer settings:', error);
39 const saveSetting = (settingName: string, value: boolean | string) => {
40 console.log('Saving setting:', settingName, '=', value);
42 // API call to save setting
43 // DATI XML format with f100_s for setting name, f101_E or f101_s for value, f112_E for layer
46 const handleToggle = (settingName: string, checked: boolean) => {
47 saveSetting(settingName, checked);
50 const handleTextChange = (settingName: string, value: string) => {
51 saveSetting(settingName, value);
54 const ToggleSwitch = ({ settingName, onChange }: { settingName: string; onChange?: (checked: boolean) => void }) => {
55 const [checked, setChecked] = useState(false);
58 <label className="relative inline-flex items-center cursor-pointer">
61 className="sr-only peer"
64 setChecked(e.target.checked);
65 if (onChange) onChange(e.target.checked);
66 else handleToggle(settingName, e.target.checked);
69 <div className="w-11 h-6 bg-surface-2 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-brand/20 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-border after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-brand"></div>
74 const TextInput = ({ settingName, size = 8 }: { settingName: string; size?: number }) => {
75 const [value, setValue] = useState('');
82 onChange={(e) => setValue(e.target.value)}
83 onBlur={(e) => handleTextChange(settingName, e.target.value)}
84 className="w-full border border-border rounded px-2 py-1 text-sm focus:ring-2 focus:ring-brand focus:border-transparent"
90 <div className="p-6 min-h-screen bg-bg">
92 <div className="mb-6">
93 <h1 className="text-3xl font-bold text-text mb-2 flex items-center gap-3">
94 <Icon name="print" size={32} />
97 <p className="text-muted">
98 Configure receipt printing operation across lane profiles
100 {profileUsage[0].used > 0 && (
101 <p className="text-sm text-brand mt-2">
102 There are {profileUsage[0].used} lanes not assigned to a profile. They use default settings.
107 <div className="max-w-[1600px] mx-auto"> {/* Settings Table */}
108 <div className="bg-surface rounded-lg shadow-md overflow-x-auto">
109 <table className="min-w-full border-collapse">
111 <tr className="bg-surface-2 border-b-2 border-border">
112 <th className="px-3 py-3 text-left text-sm font-semibold text-text sticky left-0 bg-surface-2 z-10">Setting</th>
113 {profileUsage.map((profile) => (
114 <th key={profile.id} className="px-3 py-3 text-center text-xs font-semibold text-text min-w-[80px]">
115 {profile.id === 0 ? 'No Profile' : profile.name}
117 <small className="font-normal text-muted">
118 {profile.used} {profile.used === 1 ? 'lane' : 'lanes'}
122 <th className="px-3 py-3 text-center text-xs font-semibold text-text min-w-[80px]" title="Controls web pages used for sale picking">
125 <th className="px-3 py-3 text-right text-xs font-semibold text-text">Version</th>
129 {/* Print Receipts for All Sales */}
130 <tr className="border-b border-border">
131 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Print Receipts for All Sales</td>
132 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales" /></td>
133 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p1" /></td>
134 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p2" /></td>
135 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p3" /></td>
136 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p4" /></td>
137 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p5" /></td>
138 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p6" /></td>
139 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p7" /></td>
140 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintAllSales@p8" /></td>
141 <td className="px-3 py-3 text-center"></td>
142 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
144 <tr className="border-b border-border">
145 <td colSpan={12} className="px-3 py-2 text-xs text-muted">If enabled a receipt is printed for all sales.</td>
148 {/* Print Sales above value */}
149 <tr className="border-b border-border bg-surface-2">
150 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface-2 z-10">Print Sales above value</td>
151 <td className="px-3 py-3"><TextInput settingName="PrintThreshold" size={4} /></td>
152 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p1" size={4} /></td>
153 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p2" size={4} /></td>
154 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p3" size={4} /></td>
155 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p4" size={4} /></td>
156 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p5" size={4} /></td>
157 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p6" size={4} /></td>
158 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p7" size={4} /></td>
159 <td className="px-3 py-3"><TextInput settingName="PrintThreshold@p8" size={4} /></td>
160 <td className="px-3 py-3"></td>
161 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
164 {/* Print Sales below value */}
165 <tr className="border-b border-border bg-surface-2">
166 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface-2 z-10">Print Sales below value</td>
167 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg" size={4} /></td>
168 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p1" size={4} /></td>
169 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p2" size={4} /></td>
170 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p3" size={4} /></td>
171 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p4" size={4} /></td>
172 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p5" size={4} /></td>
173 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p6" size={4} /></td>
174 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p7" size={4} /></td>
175 <td className="px-3 py-3"><TextInput settingName="PrintThresholdNeg@p8" size={4} /></td>
176 <td className="px-3 py-3"></td>
177 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
179 <tr className="border-b border-border bg-surface-2">
180 <td colSpan={12} className="px-3 py-2 text-xs text-muted">If a sale is equal or above/below the threshold value a receipt will be printed. A value of zero, or blank, disables this check</td>
183 {/* Print Office Copies */}
184 <tr className="border-b border-border">
185 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Print Office Copies for All Sales</td>
186 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy" /></td>
187 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p1" /></td>
188 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p2" /></td>
189 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p3" /></td>
190 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p4" /></td>
191 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p5" /></td>
192 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p6" /></td>
193 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p7" /></td>
194 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintOfficeCopy@p8" /></td>
195 <td className="px-3 py-3 text-center"></td>
196 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
198 <tr className="border-b border-border">
199 <td colSpan={12} className="px-3 py-2 text-xs text-muted">If enabled an office copy of the receipt for all sales. Office copies can be slightly different to customer receipts.</td>
202 {/* Print Serial Number */}
203 <tr className="border-b border-border">
204 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Print Serial Number if present</td>
205 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo" /></td>
206 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p1" /></td>
207 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p2" /></td>
208 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p3" /></td>
209 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p4" /></td>
210 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p5" /></td>
211 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p6" /></td>
212 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p7" /></td>
213 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="SalePrintAutoSerialNo@p8" /></td>
214 <td className="px-3 py-3 text-center"></td>
215 <td className="px-3 py-3 text-right text-xs text-muted">P2170</td>
217 <tr className="border-b border-border">
218 <td colSpan={12} className="px-3 py-2 text-xs text-muted">If a serial number has been captured for a saleline automatically print it on the receipt.</td>
221 {/* Prompt before Printing */}
222 <tr className="border-b border-border">
223 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Prompt before Printing</td>
224 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt" /></td>
225 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p1" /></td>
226 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p2" /></td>
227 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p3" /></td>
228 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p4" /></td>
229 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p5" /></td>
230 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p6" /></td>
231 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p7" /></td>
232 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@p8" /></td>
233 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintPrompt@e0" /></td>
234 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
236 <tr className="border-b border-border">
237 <td colSpan={12} className="px-3 py-2 text-xs text-muted">Prompt for approval to print if all the other checks allow printing.</td>
241 <tr className="border-b border-border bg-surface-2">
242 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface-2 z-10">Never Print</td>
243 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever" /></td>
244 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p1" /></td>
245 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p2" /></td>
246 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p3" /></td>
247 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p4" /></td>
248 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p5" /></td>
249 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p6" /></td>
250 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p7" /></td>
251 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintNever@p8" /></td>
252 <td className="px-3 py-3 text-center"></td>
253 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
255 <tr className="border-b border-border bg-surface-2">
256 <td colSpan={12} className="px-3 py-2 text-xs text-muted">The system will never print a receipt during sale operation, unless explicitly instructed.</td>
259 {/* Enable Extra Email */}
260 <tr className="border-b border-border">
261 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Enable Extra Email for Receipts</td>
262 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy" /></td>
263 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p1" /></td>
264 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p2" /></td>
265 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p3" /></td>
266 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p4" /></td>
267 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p5" /></td>
268 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p6" /></td>
269 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p7" /></td>
270 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintEmailCopy@p8" /></td>
271 <td className="px-3 py-3 text-center"></td>
272 <td className="px-3 py-3 text-right text-xs text-muted">P1782</td>
274 <tr className="border-b border-border">
275 <td colSpan={12} className="px-3 py-2 text-xs text-muted">When enabled, the POS will check for emailing of receipts rather than printing them.</td>
278 {/* Continue with remaining settings... */}
279 {/* For brevity, I'll add a few more key ones */}
281 {/* Email Subject Line */}
282 <tr className="border-b border-border bg-surface-2">
283 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface-2 z-10">Email Subject Line</td>
284 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject" /></td>
285 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p1" /></td>
286 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p2" /></td>
287 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p3" /></td>
288 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p4" /></td>
289 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p5" /></td>
290 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p6" /></td>
291 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p7" /></td>
292 <td className="px-3 py-3"><TextInput settingName="SaleEmailSubject@p8" /></td>
293 <td className="px-3 py-3"></td>
294 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
296 <tr className="border-b border-border bg-surface-2">
297 <td colSpan={12} className="px-3 py-2 text-xs text-muted">Set the subject line for email receipts. If left blank the POS will insert "Sale Receipt"</td>
300 {/* Auto include Customer Details */}
301 <tr className="border-b border-border">
302 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Automatically include Customer Details</td>
303 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer" /></td>
304 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p1" /></td>
305 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p2" /></td>
306 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p3" /></td>
307 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p4" /></td>
308 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p5" /></td>
309 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p6" /></td>
310 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p7" /></td>
311 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrintHeaderAutoCustomer@p8" /></td>
312 <td className="px-3 py-3 text-center"></td>
313 <td className="px-3 py-3 text-right text-xs text-muted">P2209</td>
315 <tr className="border-b border-border">
316 <td colSpan={12} className="px-3 py-2 text-xs text-muted">Include customer details on the receipt (default receipt format only) if a customer is detected.</td>
319 {/* Auto Revector Bad Printers */}
320 <tr className="border-b border-border">
321 <td className="px-3 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">Auto Revector Bad Printers</td>
322 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad" /></td>
323 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p1" /></td>
324 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p2" /></td>
325 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p3" /></td>
326 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p4" /></td>
327 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p5" /></td>
328 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p6" /></td>
329 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p7" /></td>
330 <td className="px-3 py-3 text-center"><ToggleSwitch settingName="PrinterRevectorBad@p8" /></td>
331 <td className="px-3 py-3 text-center"></td>
332 <td className="px-3 py-3 text-right text-xs text-muted">P2072</td>
334 <tr className="border-b border-border">
335 <td colSpan={12} className="px-3 py-2 text-xs text-muted">If the printer that the receipt format is assigned to use is not available, the POS will automatically substitute a replacement printer.</td>