3import React, { useState, useEffect } from 'react';
4import { Icon } from '@/contexts/IconContext';
6interface BusinessDetails {
11 companyAddress0: string;
12 companyAddress1: string;
13 companyAddress2: string;
14 catchAllReceiptMessage: string;
15 catchAllReceiptMessageAccount: string;
17 internalGdsWeb: string;
20 locationDefaultRegion: string;
23export default function YourDetailsPage() {
24 const [details, setDetails] = useState<BusinessDetails>({
32 catchAllReceiptMessage: '',
33 catchAllReceiptMessageAccount: '',
38 locationDefaultRegion: '',
41 const [showCountryNotes, setShowCountryNotes] = useState(false);
42 const [showRegionCanada, setShowRegionCanada] = useState(false);
48 const loadData = async () => {
50 // Load business details from API
51 // Mock data for demonstration
52 console.log('Loading business details...');
54 console.error('Error loading business details:', error);
58 const saveSetting = (settingName: string, value: string) => {
59 console.log('Saving setting:', settingName, '=', value);
61 // API call to save setting
64 // <f8_s>retailmax.elink.config.basesetting.edit</f8_s>
66 // <f100_s>{settingName}</f100_s>
67 // <f101_s>{value}</f101_s>
72 const handleChange = (field: keyof BusinessDetails, value: string) => {
73 setDetails(prev => ({ ...prev, [field]: value }));
76 const handleBlur = (settingName: string, value: string) => {
77 saveSetting(settingName, value);
80 const handleCountryChange = (value: string) => {
81 setDetails(prev => ({ ...prev, countryCode: value }));
83 // Show notes for Canada
84 if (value === '9001') {
85 setShowCountryNotes(true);
86 setShowRegionCanada(true);
88 setShowCountryNotes(false);
89 setShowRegionCanada(false);
92 saveSetting('CountryCode', value);
96 <div className="min-h-screen bg-bg">
98 <div className="bg-brand text-white px-6 py-4 shadow-lg">
99 <div className="flex items-center gap-4">
100 <div className="text-sm">
101 <a href="/pages/settings" className="hover:underline">Settings</a>
102 <span className="mx-2">›</span>
103 <span>Your Business Details</span>
108 <div className="max-w-[1400px] mx-auto p-6">
110 <div className="mb-6">
111 <h1 className="text-3xl font-bold text-text mb-2 flex items-center gap-3">
112 <Icon name="business" size={32} />
113 Your Business Details
118 <div className="bg-surface rounded-lg shadow-md p-6">
119 <h2 className="text-xl font-bold text-text mb-4">Common Information</h2>
121 <p className="text-text mb-4">
122 Supply the broad details about your business. This information is used in a number of customer facing areas,
123 so only enter information that is intended to be publically visible. For example, many of the details below
124 may be printed on your receipts.
127 <p className="text-sm text-muted mb-6 italic">
128 Information entered below applies to ALL stores, unless specifically overridden by a store.
131 <div className="space-y-8">
132 {/* Business Name */}
134 <label className="block text-sm font-semibold text-text mb-2">
140 value={details.companyName}
141 onChange={(e) => handleChange('companyName', e.target.value)}
142 onBlur={(e) => handleBlur('StoreSetup.CompanyName', e.target.value)}
143 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
149 <label className="block text-sm font-semibold text-text mb-2">
150 Tax Number (GST, MwST, VAT etc)
155 value={details.taxId}
156 onChange={(e) => handleChange('taxId', e.target.value)}
157 onBlur={(e) => handleBlur('StoreSetup.TaxId.0', e.target.value)}
158 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
162 {/* Company Phone */}
164 <label className="block text-sm font-semibold text-text mb-2">
170 value={details.companyPhone}
171 onChange={(e) => handleChange('companyPhone', e.target.value)}
172 onBlur={(e) => handleBlur('StoreSetup.CompanyPhone', e.target.value)}
173 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
177 {/* Company Email */}
179 <label className="block text-sm font-semibold text-text mb-2">
185 value={details.companyEmail}
186 onChange={(e) => handleChange('companyEmail', e.target.value)}
187 onBlur={(e) => handleBlur('StoreSetup.CompanyEmail', e.target.value)}
188 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
192 {/* Company Address */}
194 <label className="block text-sm font-semibold text-text mb-2">
197 <div className="space-y-2">
201 value={details.companyAddress0}
202 onChange={(e) => handleChange('companyAddress0', e.target.value)}
203 onBlur={(e) => handleBlur('StoreSetup.CompanyAddress0', e.target.value)}
204 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
205 placeholder="Address Line 1"
210 value={details.companyAddress1}
211 onChange={(e) => handleChange('companyAddress1', e.target.value)}
212 onBlur={(e) => handleBlur('StoreSetup.CompanyAddress1', e.target.value)}
213 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
214 placeholder="Address Line 2"
219 value={details.companyAddress2}
220 onChange={(e) => handleChange('companyAddress2', e.target.value)}
221 onBlur={(e) => handleBlur('StoreSetup.CompanyAddress2', e.target.value)}
222 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
223 placeholder="Address Line 3"
228 {/* Invoice/Receipt Message */}
230 <label className="block text-sm font-semibold text-text mb-2">
231 Invoice/Receipt Message
233 <p className="text-xs text-muted mb-2">For all sales, unless specifically overridden for individual customer/account.</p>
237 value={details.catchAllReceiptMessage}
238 onChange={(e) => handleChange('catchAllReceiptMessage', e.target.value)}
239 onBlur={(e) => handleBlur('CatchAllReceiptMessage', e.target.value)}
240 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
244 {/* Account Invoice/Receipt Message */}
246 <label className="block text-sm font-semibold text-text mb-2">
247 Account Invoice/Receipt Message
249 <p className="text-xs text-muted mb-2">For all sales that have an account</p>
253 value={details.catchAllReceiptMessageAccount}
254 onChange={(e) => handleChange('catchAllReceiptMessageAccount', e.target.value)}
255 onBlur={(e) => handleBlur('CatchAllReceiptMessageAccount', e.target.value)}
256 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
260 {/* Company Website */}
262 <label className="block text-sm font-semibold text-text mb-2">
265 <p className="text-xs text-muted mb-2">Potentially given to customers</p>
269 value={details.companyWeb}
270 onChange={(e) => handleChange('companyWeb', e.target.value)}
271 onBlur={(e) => handleBlur('StoreSetup.CompanyWeb', e.target.value)}
272 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
273 placeholder="https://www.example.com"
277 {/* Internal Website */}
279 <label className="block text-sm font-semibold text-text mb-2">
282 <p className="text-xs text-muted mb-2">For internal use - what is the NAME this Fieldpine System can be reached on</p>
286 value={details.internalGdsWeb}
287 onChange={(e) => handleChange('internalGdsWeb', e.target.value)}
288 onBlur={(e) => handleBlur('StoreSetup.InternalGdsWeb', e.target.value)}
289 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
295 <label className="block text-sm font-semibold text-text mb-2">
298 <div className="flex gap-4 items-start">
299 <div className="flex-1 max-w-2xl">
304 onChange={(e) => handleChange('logo', e.target.value)}
305 onBlur={(e) => handleBlur('StoreSetup.Logo', e.target.value)}
306 className="w-full border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
307 placeholder="https://example.com/logo.png"
309 <p className="text-xs text-muted mt-2">Enter the URL of your logo. This will be used on receipts and similar places.</p>
311 <div className="border border-dashed border-border rounded p-4 min-w-[200px] min-h-[100px] flex items-center justify-center">
313 <img src={details.logo} alt="Company Logo" className="max-w-full max-h-[150px]" onError={(e) => {
314 (e.target as HTMLImageElement).style.display = 'none';
315 (e.target as HTMLImageElement).parentElement!.innerHTML = '<div class="text-sm text-muted">Invalid logo URL</div>';
318 <div className="text-sm text-muted">Current Logo<br />None</div>
326 <label className="block text-sm font-semibold text-text mb-2">
330 value={details.countryCode}
331 onChange={(e) => handleCountryChange(e.target.value)}
332 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
334 <option value="">Based on Windows Regional settings</option>
335 <option value="61">Australia</option>
336 <option value="9001">Canada</option>
337 <option value="972">Israel</option>
338 <option value="64">New Zealand</option>
339 <option value="27">South Africa</option>
340 <option value="44">United Kingdom</option>
341 <option value="263">Zimbabwe</option>
344 {showCountryNotes && (
345 <div className="mt-3 p-4 border-2 border-danger rounded bg-danger/10 text-danger">
346 Canada has regional taxes. You need to edit each store and select the region it belongs too for these regional taxes to apply.
347 You can also specify a default region below if you only operate in one region.
351 <p className="text-xs text-muted mt-2">
352 What country are you operating in? If left blank the Pos will detect and use whatever is configured on the PC.
353 However, we recommend explicitly setting this value as it is quite common for computers to be configured under
354 Windows Regional settings for the wrong country.
358 {/* Default Region (Canada) */}
359 {showRegionCanada && (
361 <label className="block text-sm font-semibold text-text mb-2">
365 value={details.locationDefaultRegion}
367 handleChange('locationDefaultRegion', e.target.value);
368 saveSetting('LocationDefaultRegion', e.target.value);
370 className="w-full max-w-2xl border border-border rounded px-3 py-2 focus:ring-2 focus:ring-brand focus:border-transparent"
372 <option value="">Unknown</option>
373 <option value="90010001">Ontario</option>
374 <option value="90010002">British Columbia</option>
375 <option value="90010003">Nova Scotia</option>
376 <option value="90010004">Brunswick</option>
377 <option value="90010005">Newfoundland</option>
378 <option value="90010006">Quebec</option>