EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
page.tsx
Go to the documentation of this file.
1'use client';
2
3import { useState, useEffect } from 'react';
4import { Icon } from '@/contexts/IconContext';
5
6interface ProfileUsage {
7 id: number;
8 name: string;
9 used: number;
10}
11
12export default function CashDrawersPage() {
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 },
23 ]);
24
25 useEffect(() => {
26 loadData();
27 }, []);
28
29 const loadData = async () => {
30 // Load profile usage from API
31 // API call: /BUCK?3=retailmax.elink.lane.summary&100=profileuse
32 console.log('Loading profile usage data...');
33 };
34
35 const saveSetting = (settingName: string, value: boolean) => {
36 console.log(`Saving ${settingName} = ${value}`);
37 // API call to save setting via DATI XML
38 // <DATI><f8_s>retailmax.elink.config.basesetting.edit</f8_s>
39 // <f11_B>E</f11_B><f100_s>${settingName}</f100_s>
40 // <f101_E>${value ? 1 : 0}</f101_E><f112_E>1</f112_E></DATI>
41 };
42
43 // Reusable toggle switch component
44 const ToggleSwitch = ({ settingName, onChange }: { settingName: string; onChange?: (checked: boolean) => void }) => {
45 const [checked, setChecked] = useState(false);
46
47 const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
48 const newValue = e.target.checked;
49 setChecked(newValue);
50 saveSetting(settingName, newValue);
51 if (onChange) onChange(newValue);
52 };
53
54 return (
55 <label className="relative inline-flex items-center cursor-pointer">
56 <input
57 type="checkbox"
58 className="sr-only peer"
59 checked={checked}
60 onChange={handleChange}
61 />
62 <div className="w-11 h-6 bg-danger peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-brand rounded-full peer peer-checked:after:translate-x-full rtl:peer-checked:after:-translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:start-[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>
63 </label>
64 );
65 };
66
67 return (
68 <div className="p-6 min-h-screen bg-bg">
69 <div className="max-w-[1600px] mx-auto">
70 {/* Page Title */}
71 <div className="mb-6">
72 <h1 className="text-3xl font-bold text-text mb-2 flex items-center gap-2">
73 <Icon name="payments" size={32} />
74 Cash Drawer Options
75 </h1>
76 </div>
77
78 {/* Info Box */}
79 <div className="bg-info/10 border border-info/30 rounded-lg p-4 mb-6">
80 <p className="text-text mb-2">
81 Cash drawers are typically connected to retail printers, and those printers provide the electronic signal to open the drawer.
82 </p>
83 <p className="text-text">
84 Fieldpine drives the cash drawer directly. You should not use printer driver options to always open the cash drawer after printing
85 as this causes the drawer to open when anything is printed, which is less secure and annoying for transactions that do not need it.
86 </p>
87 </div>
88
89 {/* Profile-based Settings Table */}
90 <div className="bg-surface rounded-lg shadow-md overflow-x-auto">
91 <table className="w-full border-collapse">
92 <thead>
93 <tr className="bg-surface-2 border-b border-border">
94 <th className="px-4 py-3 text-left font-semibold text-text sticky left-0 bg-surface-2 z-10 min-w-[200px]">
95 Setting
96 </th>
97 {profileUsage.map((profile) => (
98 <th key={profile.id} className="px-3 py-3 text-center font-semibold text-text min-w-[80px]">
99 <div dangerouslySetInnerHTML={{ __html: profile.name }} />
100 <div className="text-xs font-normal text-muted mt-1">
101 {profile.id === 0 && profile.used === 0 ? '' : `${profile.used} lane${profile.used !== 1 ? 's' : ''}`}
102 </div>
103 </th>
104 ))}
105 <th className="px-3 py-3 text-right font-semibold text-text min-w-[80px]">
106 Version
107 </th>
108 </tr>
109 </thead>
110 <tbody>
111 {/* Allow Quickcode to open drawer */}
112 <tr className="border-b border-border">
113 <td className="px-4 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">
114 Allow Quickcode to open drawer
115 </td>
116 <td className="px-3 py-3 text-center">
117 <ToggleSwitch settingName="QuickCodeOpenDrawer" />
118 </td>
119 <td className="px-3 py-3 text-center">
120 <ToggleSwitch settingName="QuickCodeOpenDrawer@p1" />
121 </td>
122 <td className="px-3 py-3 text-center">
123 <ToggleSwitch settingName="QuickCodeOpenDrawer@p2" />
124 </td>
125 <td className="px-3 py-3 text-center">
126 <ToggleSwitch settingName="QuickCodeOpenDrawer@p3" />
127 </td>
128 <td className="px-3 py-3 text-center">
129 <ToggleSwitch settingName="QuickCodeOpenDrawer@p4" />
130 </td>
131 <td className="px-3 py-3 text-center">
132 <ToggleSwitch settingName="QuickCodeOpenDrawer@p5" />
133 </td>
134 <td className="px-3 py-3 text-center">
135 <ToggleSwitch settingName="QuickCodeOpenDrawer@p6" />
136 </td>
137 <td className="px-3 py-3 text-center">
138 <ToggleSwitch settingName="QuickCodeOpenDrawer@p7" />
139 </td>
140 <td className="px-3 py-3 text-center">
141 <ToggleSwitch settingName="QuickCodeOpenDrawer@p8" />
142 </td>
143 <td className="px-3 py-3 text-right text-xs text-muted">
144 P2355
145 </td>
146 </tr>
147 <tr className="bg-surface-2 border-b border-border">
148 <td colSpan={11} className="px-4 py-2 text-sm text-muted">
149 Can the user enter a quickcode to open the cash drawer without a sale requiring it to open? This is disabled by default
150 as it makes systems slightly less secure.
151 </td>
152 </tr>
153
154 {/* Display Errors to Users */}
155 <tr className="border-b border-border">
156 <td className="px-4 py-3 text-sm font-semibold text-text sticky left-0 bg-surface z-10">
157 Display Errors to Users
158 </td>
159 <td className="px-3 py-3 text-center">
160 <ToggleSwitch settingName="CashDrawer0Error" />
161 </td>
162 <td className="px-3 py-3 text-center">
163 <ToggleSwitch settingName="CashDrawer0Error@p1" />
164 </td>
165 <td className="px-3 py-3 text-center">
166 <ToggleSwitch settingName="CashDrawer0Error@p2" />
167 </td>
168 <td className="px-3 py-3 text-center">
169 <ToggleSwitch settingName="CashDrawer0Error@p3" />
170 </td>
171 <td className="px-3 py-3 text-center">
172 <ToggleSwitch settingName="CashDrawer0Error@p4" />
173 </td>
174 <td className="px-3 py-3 text-center">
175 <ToggleSwitch settingName="CashDrawer0Error@p5" />
176 </td>
177 <td className="px-3 py-3 text-center">
178 <ToggleSwitch settingName="CashDrawer0Error@p6" />
179 </td>
180 <td className="px-3 py-3 text-center">
181 <ToggleSwitch settingName="CashDrawer0Error@p7" />
182 </td>
183 <td className="px-3 py-3 text-center">
184 <ToggleSwitch settingName="CashDrawer0Error@p8" />
185 </td>
186 <td className="px-3 py-3 text-right text-xs text-muted">
187 P2015
188 </td>
189 </tr>
190 <tr className="bg-surface-2 border-b border-border">
191 <td colSpan={11} className="px-4 py-2 text-sm text-muted">
192 If a technical issue is detected while opening the cash drawer, should we tell the staff member (on) or silently fail (off).
193 </td>
194 </tr>
195 </tbody>
196 </table>
197 </div>
198
199 {/* Additional Info */}
200 <div className="mt-6 bg-surface-2 border border-border rounded-lg p-4">
201 <h3 className="text-sm font-semibold text-text mb-2">About Cash Drawer Settings</h3>
202 <ul className="text-sm text-muted space-y-1 list-disc list-inside">
203 <li>Cash drawers open automatically when a sale requires it (cash payments, change given)</li>
204 <li>Quickcode opening allows staff to manually open the drawer without a sale</li>
205 <li>Error display helps diagnose hardware connectivity issues</li>
206 <li>Settings are profile-based to allow different behavior per store or lane type</li>
207 </ul>
208 </div>
209 </div>
210 </div>
211 );
212}