@licklist/design 0.78.5-dev.54 → 0.78.5-dev.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -7
- package/dist/v2/components/ActionMenu/ActionMenu.d.ts +1 -0
- package/dist/v2/components/ActionMenu/ActionMenu.d.ts.map +1 -1
- package/dist/v2/components/ActionMenu/ActionMenu.js +10 -3
- package/dist/v2/components/ActionMenu/ActionMenu.scss.js +1 -1
- package/dist/v2/components/Button/Button.d.ts +3 -2
- package/dist/v2/components/Button/Button.d.ts.map +1 -1
- package/dist/v2/components/Button/Button.js +12 -6
- package/dist/v2/components/Button/Button.scss.js +1 -1
- package/dist/v2/components/NewPageHeader/NewPageHeader.d.ts +2 -1
- package/dist/v2/components/NewPageHeader/NewPageHeader.d.ts.map +1 -1
- package/dist/v2/components/NewPageHeader/NewPageHeader.js +2 -2
- package/dist/v2/components/NewTable/NewTable.d.ts +1 -0
- package/dist/v2/components/NewTable/NewTable.d.ts.map +1 -1
- package/dist/v2/components/NewTable/NewTable.js +5 -0
- package/dist/v2/components/Pagination/Pagination.scss.js +1 -1
- package/dist/v2/components/index.d.ts +3 -10
- package/dist/v2/components/index.d.ts.map +1 -1
- package/dist/v2/icons/index.d.ts +18 -3
- package/dist/v2/icons/index.d.ts.map +1 -1
- package/dist/v2/icons/index.js +150 -7
- package/dist/v2/pages/Settings/components/SidebarCustomisation.js +7 -11
- package/dist/v2/pages/Settings/components/SidebarNavItem.js +6 -11
- package/dist/v2/styles/components/Button.scss +34 -2
- package/package.json +1 -1
- package/src/v2/components/ActionMenu/ActionMenu.scss +16 -5
- package/src/v2/components/ActionMenu/ActionMenu.tsx +6 -3
- package/src/v2/components/Button/Button.tsx +6 -3
- package/src/v2/components/Customer/{CustomerDetail/CustomerDetail.scss → CustomerDetail.scss} +7 -3
- package/src/v2/components/Customer/CustomersList.scss +308 -36
- package/src/v2/components/NewPageHeader/NewPageHeader.tsx +6 -4
- package/src/v2/components/NewTable/NewTable.tsx +6 -0
- package/src/v2/components/Pagination/Pagination.scss +24 -24
- package/src/v2/components/index.ts +19 -13
- package/src/v2/icons/index.tsx +35 -6
- package/src/v2/styles/components/Button.scss +34 -2
- package/dist/v2/components/Customer/CustomerCreate/CustomerCreate.d.ts +0 -11
- package/dist/v2/components/Customer/CustomerCreate/CustomerCreate.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerCreate/CustomerCreate.js +0 -32
- package/dist/v2/components/Customer/CustomerCreate/index.d.ts +0 -2
- package/dist/v2/components/Customer/CustomerCreate/index.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerDetail/CustomerDetail.d.ts +0 -35
- package/dist/v2/components/Customer/CustomerDetail/CustomerDetail.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerDetail/CustomerDetail.js +0 -235
- package/dist/v2/components/Customer/CustomerDetail/CustomerDetail.scss.js +0 -6
- package/dist/v2/components/Customer/CustomerDetail/index.d.ts +0 -2
- package/dist/v2/components/Customer/CustomerDetail/index.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerEdit/CustomerEdit.d.ts +0 -11
- package/dist/v2/components/Customer/CustomerEdit/CustomerEdit.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerEdit/CustomerEdit.js +0 -32
- package/dist/v2/components/Customer/CustomerEdit/index.d.ts +0 -2
- package/dist/v2/components/Customer/CustomerEdit/index.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerForm/CustomerForm.d.ts +0 -22
- package/dist/v2/components/Customer/CustomerForm/CustomerForm.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomerForm/CustomerForm.js +0 -535
- package/dist/v2/components/Customer/CustomerForm/index.d.ts +0 -2
- package/dist/v2/components/Customer/CustomerForm/index.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomersList.d.ts +0 -37
- package/dist/v2/components/Customer/CustomersList.d.ts.map +0 -1
- package/dist/v2/components/Customer/CustomersList.js +0 -204
- package/dist/v2/components/Customer/CustomersList.scss.js +0 -6
- package/dist/v2/components/Customer/index.d.ts +0 -6
- package/dist/v2/components/Customer/index.d.ts.map +0 -1
- package/src/v2/components/Customer/CustomerCreate/CustomerCreate.tsx +0 -36
- package/src/v2/components/Customer/CustomerCreate/index.ts +0 -1
- package/src/v2/components/Customer/CustomerDetail/CustomerDetail.tsx +0 -161
- package/src/v2/components/Customer/CustomerDetail/index.ts +0 -1
- package/src/v2/components/Customer/CustomerEdit/CustomerEdit.tsx +0 -37
- package/src/v2/components/Customer/CustomerEdit/index.ts +0 -1
- package/src/v2/components/Customer/CustomerForm/CustomerForm.tsx +0 -434
- package/src/v2/components/Customer/CustomerForm/index.ts +0 -1
- package/src/v2/components/Customer/CustomersList.tsx +0 -193
- package/src/v2/components/Customer/index.ts +0 -5
|
@@ -1,535 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import { showAlert } from '@licklist/plugins/dist/context/app/AlertContext';
|
|
4
|
-
import { NewInput } from '../../NewInput/NewInput.js';
|
|
5
|
-
import { Select } from '../../Select/Select.js';
|
|
6
|
-
import { Checkbox } from '../../Checkbox/Checkbox.js';
|
|
7
|
-
import { Button } from '../../Button/Button.js';
|
|
8
|
-
import { useTranslation } from 'react-i18next';
|
|
9
|
-
|
|
10
|
-
function _array_like_to_array(arr, len) {
|
|
11
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
12
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
13
|
-
return arr2;
|
|
14
|
-
}
|
|
15
|
-
function _array_with_holes(arr) {
|
|
16
|
-
if (Array.isArray(arr)) return arr;
|
|
17
|
-
}
|
|
18
|
-
function _define_property(obj, key, value) {
|
|
19
|
-
if (key in obj) {
|
|
20
|
-
Object.defineProperty(obj, key, {
|
|
21
|
-
value: value,
|
|
22
|
-
enumerable: true,
|
|
23
|
-
configurable: true,
|
|
24
|
-
writable: true
|
|
25
|
-
});
|
|
26
|
-
} else {
|
|
27
|
-
obj[key] = value;
|
|
28
|
-
}
|
|
29
|
-
return obj;
|
|
30
|
-
}
|
|
31
|
-
function _iterable_to_array_limit(arr, i) {
|
|
32
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
33
|
-
if (_i == null) return;
|
|
34
|
-
var _arr = [];
|
|
35
|
-
var _n = true;
|
|
36
|
-
var _d = false;
|
|
37
|
-
var _s, _e;
|
|
38
|
-
try {
|
|
39
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
40
|
-
_arr.push(_s.value);
|
|
41
|
-
if (i && _arr.length === i) break;
|
|
42
|
-
}
|
|
43
|
-
} catch (err) {
|
|
44
|
-
_d = true;
|
|
45
|
-
_e = err;
|
|
46
|
-
} finally{
|
|
47
|
-
try {
|
|
48
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
49
|
-
} finally{
|
|
50
|
-
if (_d) throw _e;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return _arr;
|
|
54
|
-
}
|
|
55
|
-
function _non_iterable_rest() {
|
|
56
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
57
|
-
}
|
|
58
|
-
function _object_spread(target) {
|
|
59
|
-
for(var i = 1; i < arguments.length; i++){
|
|
60
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
61
|
-
var ownKeys = Object.keys(source);
|
|
62
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
63
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
64
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
ownKeys.forEach(function(key) {
|
|
68
|
-
_define_property(target, key, source[key]);
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return target;
|
|
72
|
-
}
|
|
73
|
-
function ownKeys(object, enumerableOnly) {
|
|
74
|
-
var keys = Object.keys(object);
|
|
75
|
-
if (Object.getOwnPropertySymbols) {
|
|
76
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
77
|
-
if (enumerableOnly) {
|
|
78
|
-
symbols = symbols.filter(function(sym) {
|
|
79
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
keys.push.apply(keys, symbols);
|
|
83
|
-
}
|
|
84
|
-
return keys;
|
|
85
|
-
}
|
|
86
|
-
function _object_spread_props(target, source) {
|
|
87
|
-
source = source != null ? source : {};
|
|
88
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
89
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
90
|
-
} else {
|
|
91
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
92
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
return target;
|
|
96
|
-
}
|
|
97
|
-
function _sliced_to_array(arr, i) {
|
|
98
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
99
|
-
}
|
|
100
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
101
|
-
if (!o) return;
|
|
102
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
103
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
104
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
105
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
106
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
107
|
-
}
|
|
108
|
-
var CustomerForm = function(param) {
|
|
109
|
-
var onSave = param.onSave, initialData = param.initialData, isLoading = param.isLoading, _param_submitButtonLabel = param.submitButtonLabel, submitButtonLabel = _param_submitButtonLabel === void 0 ? 'Save Changes' : _param_submitButtonLabel, _param_isEditing = param.isEditing, isEditing = _param_isEditing === void 0 ? false : _param_isEditing;
|
|
110
|
-
var STORAGE_KEY = 'customer_form_draft';
|
|
111
|
-
var _useState = _sliced_to_array(useState(function() {
|
|
112
|
-
// Try to restore from sessionStorage first
|
|
113
|
-
try {
|
|
114
|
-
var savedData = sessionStorage.getItem(STORAGE_KEY);
|
|
115
|
-
if (savedData) {
|
|
116
|
-
var parsed = JSON.parse(savedData);
|
|
117
|
-
// If we have initialData (editing), prefer that over saved draft
|
|
118
|
-
if (initialData === null || initialData === void 0 ? void 0 : initialData.email) {
|
|
119
|
-
sessionStorage.removeItem(STORAGE_KEY) // Clear draft when editing
|
|
120
|
-
;
|
|
121
|
-
return _object_spread({
|
|
122
|
-
firstName: '',
|
|
123
|
-
lastName: '',
|
|
124
|
-
email: '',
|
|
125
|
-
dobDay: '',
|
|
126
|
-
dobMonth: '',
|
|
127
|
-
dobYear: '',
|
|
128
|
-
phone: '',
|
|
129
|
-
optIn: false,
|
|
130
|
-
postcode: '',
|
|
131
|
-
gender: ''
|
|
132
|
-
}, initialData);
|
|
133
|
-
}
|
|
134
|
-
return parsed;
|
|
135
|
-
}
|
|
136
|
-
} catch (error) {
|
|
137
|
-
console.error('Failed to restore form data:', error);
|
|
138
|
-
}
|
|
139
|
-
return _object_spread({
|
|
140
|
-
firstName: '',
|
|
141
|
-
lastName: '',
|
|
142
|
-
email: '',
|
|
143
|
-
dobDay: '',
|
|
144
|
-
dobMonth: '',
|
|
145
|
-
dobYear: '',
|
|
146
|
-
phone: '',
|
|
147
|
-
optIn: false,
|
|
148
|
-
postcode: '',
|
|
149
|
-
gender: ''
|
|
150
|
-
}, initialData);
|
|
151
|
-
}), 2), formData = _useState[0], setFormData = _useState[1];
|
|
152
|
-
var _useState1 = _sliced_to_array(useState({}), 2), errors = _useState1[0], setErrors = _useState1[1];
|
|
153
|
-
var t = useTranslation([
|
|
154
|
-
'App'
|
|
155
|
-
]).t;
|
|
156
|
-
// Save to sessionStorage whenever form data changes (but not when editing)
|
|
157
|
-
useEffect(function() {
|
|
158
|
-
if (!(initialData === null || initialData === void 0 ? void 0 : initialData.email)) {
|
|
159
|
-
try {
|
|
160
|
-
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(formData));
|
|
161
|
-
} catch (error) {
|
|
162
|
-
console.error('Failed to save form data:', error);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}, [
|
|
166
|
-
formData,
|
|
167
|
-
initialData
|
|
168
|
-
]);
|
|
169
|
-
useEffect(function() {
|
|
170
|
-
if (initialData) {
|
|
171
|
-
setFormData(function(prev) {
|
|
172
|
-
return _object_spread({}, prev, initialData);
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
}, [
|
|
176
|
-
initialData
|
|
177
|
-
]);
|
|
178
|
-
// Clear sessionStorage when component unmounts successfully (form submitted)
|
|
179
|
-
useEffect(function() {
|
|
180
|
-
return function() {
|
|
181
|
-
// Only clear if we're not in the middle of validation error
|
|
182
|
-
if (Object.keys(errors).length === 0) {
|
|
183
|
-
sessionStorage.removeItem(STORAGE_KEY);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
}, [
|
|
187
|
-
errors
|
|
188
|
-
]);
|
|
189
|
-
var handleChange = function(e) {
|
|
190
|
-
var _e_target = e.target, name = _e_target.name, value = _e_target.value, type = _e_target.type;
|
|
191
|
-
var checked = e.target.checked;
|
|
192
|
-
setFormData(function(prev) {
|
|
193
|
-
return _object_spread_props(_object_spread({}, prev), _define_property({}, name, type === 'checkbox' ? checked : value));
|
|
194
|
-
});
|
|
195
|
-
// Clear error when user types
|
|
196
|
-
if (errors[name]) {
|
|
197
|
-
setErrors(function(prev) {
|
|
198
|
-
var newErrors = _object_spread({}, prev);
|
|
199
|
-
delete newErrors[name];
|
|
200
|
-
return newErrors;
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
var handleSelectChange = function(e) {
|
|
205
|
-
var _e_currentTarget = e.currentTarget, name = _e_currentTarget.name, value = _e_currentTarget.value;
|
|
206
|
-
setFormData(function(prev) {
|
|
207
|
-
return _object_spread_props(_object_spread({}, prev), _define_property({}, name, value));
|
|
208
|
-
});
|
|
209
|
-
// Clear error when user selects
|
|
210
|
-
if (errors[name]) {
|
|
211
|
-
setErrors(function(prev) {
|
|
212
|
-
var newErrors = _object_spread({}, prev);
|
|
213
|
-
delete newErrors[name];
|
|
214
|
-
return newErrors;
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
};
|
|
218
|
-
var validate = function() {
|
|
219
|
-
var _formData_dobDay, _formData_dobMonth, _formData_dobYear, _formData_phone;
|
|
220
|
-
var fieldErrors = {};
|
|
221
|
-
var messages = [];
|
|
222
|
-
if (!formData.firstName.trim()) {
|
|
223
|
-
fieldErrors.firstName = ' ';
|
|
224
|
-
//messages.push('First Name is required')
|
|
225
|
-
messages.push(t('Validation:fieldRequired', {
|
|
226
|
-
attribute: t('App:firstName')
|
|
227
|
-
}));
|
|
228
|
-
}
|
|
229
|
-
if (!formData.lastName.trim()) {
|
|
230
|
-
fieldErrors.lastName = ' ';
|
|
231
|
-
messages.push(t('Validation:fieldRequired', {
|
|
232
|
-
attribute: t('App:lastName')
|
|
233
|
-
}));
|
|
234
|
-
}
|
|
235
|
-
// Skip email validation when editing (field is readonly)
|
|
236
|
-
if (!isEditing) {
|
|
237
|
-
if (!formData.email.trim()) {
|
|
238
|
-
fieldErrors.email = ' ';
|
|
239
|
-
messages.push(t('Validation:fieldRequired', {
|
|
240
|
-
attribute: t('App:emailAddress')
|
|
241
|
-
}));
|
|
242
|
-
} else {
|
|
243
|
-
// Basic email format check
|
|
244
|
-
var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
245
|
-
if (!emailRegex.test(formData.email)) {
|
|
246
|
-
fieldErrors.email = ' ';
|
|
247
|
-
messages.push(t('App:emailAddressInvalid'));
|
|
248
|
-
} else {
|
|
249
|
-
// Additional validation for domain quality
|
|
250
|
-
var parts = formData.email.split('@');
|
|
251
|
-
if (parts.length === 2) {
|
|
252
|
-
var domain = parts[1];
|
|
253
|
-
// Check for valid TLD (at least 2 characters after last dot - allows .it, .co, etc.)
|
|
254
|
-
var domainParts = domain.split('.');
|
|
255
|
-
var tld = domainParts[domainParts.length - 1];
|
|
256
|
-
// TLD must be at least 2 characters (allows .it, .co) but rejects single char like .c
|
|
257
|
-
if (tld.length < 2 || !/^[a-zA-Z]+$/.test(tld)) {
|
|
258
|
-
fieldErrors.email = ' ';
|
|
259
|
-
messages.push(t('App:emailAddressInvalid'));
|
|
260
|
-
}
|
|
261
|
-
// Check for consecutive dots or dots at wrong positions
|
|
262
|
-
if (domain.includes('..') || domain.startsWith('.') || domain.endsWith('.')) {
|
|
263
|
-
fieldErrors.email = ' ';
|
|
264
|
-
messages.push(t('App:emailAddressInvalid'));
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
// Optional Date of Birth validation
|
|
271
|
-
var day = (_formData_dobDay = formData.dobDay) === null || _formData_dobDay === void 0 ? void 0 : _formData_dobDay.trim();
|
|
272
|
-
var month = (_formData_dobMonth = formData.dobMonth) === null || _formData_dobMonth === void 0 ? void 0 : _formData_dobMonth.trim();
|
|
273
|
-
var year = (_formData_dobYear = formData.dobYear) === null || _formData_dobYear === void 0 ? void 0 : _formData_dobYear.trim();
|
|
274
|
-
var anyDobPart = !!(day || month || year);
|
|
275
|
-
if (anyDobPart) {
|
|
276
|
-
t('App:dateOfBirth', 'Date of Birth');
|
|
277
|
-
var dayLabel = t('App:day', 'Day');
|
|
278
|
-
var monthLabel = t('App:month', 'Month');
|
|
279
|
-
var yearLabel = t('App:year', 'Year');
|
|
280
|
-
// Require all three parts if any is provided
|
|
281
|
-
if (!day) {
|
|
282
|
-
fieldErrors.dobDay = ' ';
|
|
283
|
-
}
|
|
284
|
-
if (!month) {
|
|
285
|
-
fieldErrors.dobMonth = ' ';
|
|
286
|
-
}
|
|
287
|
-
if (!year) {
|
|
288
|
-
fieldErrors.dobYear = ' ';
|
|
289
|
-
}
|
|
290
|
-
if (!day || !month || !year) {
|
|
291
|
-
messages.push(t('Validation:fieldValidDate'));
|
|
292
|
-
} else {
|
|
293
|
-
// Numeric only checks
|
|
294
|
-
var numOnly = /^\d+$/;
|
|
295
|
-
if (!numOnly.test(day)) {
|
|
296
|
-
fieldErrors.dobDay = ' ';
|
|
297
|
-
messages.push(t('Validation:fieldOnlyNumbers', {
|
|
298
|
-
attribute: dayLabel
|
|
299
|
-
}));
|
|
300
|
-
}
|
|
301
|
-
if (!numOnly.test(month)) {
|
|
302
|
-
fieldErrors.dobMonth = ' ';
|
|
303
|
-
messages.push(t('Validation:fieldOnlyNumbers', {
|
|
304
|
-
attribute: monthLabel
|
|
305
|
-
}));
|
|
306
|
-
}
|
|
307
|
-
if (!/^\d{4}$/.test(year)) {
|
|
308
|
-
fieldErrors.dobYear = ' ';
|
|
309
|
-
// Prefer explicit invalid year formatting over generic numbers message to enforce 4 digits
|
|
310
|
-
messages.push(t('Validation:fieldInvalid', {
|
|
311
|
-
attribute: yearLabel
|
|
312
|
-
}));
|
|
313
|
-
} else if (!numOnly.test(year)) {
|
|
314
|
-
fieldErrors.dobYear = ' ';
|
|
315
|
-
messages.push(t('Validation:fieldOnlyNumbers', {
|
|
316
|
-
attribute: yearLabel
|
|
317
|
-
}));
|
|
318
|
-
}
|
|
319
|
-
// Range checks if numeric
|
|
320
|
-
var d = parseInt(day, 10);
|
|
321
|
-
var m = parseInt(month, 10);
|
|
322
|
-
var y = parseInt(year, 10);
|
|
323
|
-
if (numOnly.test(day) && (d < 1 || d > 31)) {
|
|
324
|
-
fieldErrors.dobDay = ' ';
|
|
325
|
-
messages.push(t('Validation:fieldValidDay', {
|
|
326
|
-
attribute: dayLabel
|
|
327
|
-
}));
|
|
328
|
-
}
|
|
329
|
-
if (numOnly.test(month) && (m < 1 || m > 12)) {
|
|
330
|
-
fieldErrors.dobMonth = ' ';
|
|
331
|
-
messages.push(t('Validation:fieldValidMonth', {
|
|
332
|
-
attribute: monthLabel
|
|
333
|
-
}));
|
|
334
|
-
}
|
|
335
|
-
// Validate actual calendar date and future constraint
|
|
336
|
-
if (numOnly.test(day) && numOnly.test(month) && /^\d{4}$/.test(year)) {
|
|
337
|
-
var date = new Date(y, m - 1, d);
|
|
338
|
-
var isValidDate = date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
|
|
339
|
-
if (!isValidDate) {
|
|
340
|
-
fieldErrors.dobDay = ' ';
|
|
341
|
-
fieldErrors.dobMonth = ' ';
|
|
342
|
-
fieldErrors.dobYear = ' ';
|
|
343
|
-
messages.push(t('Validation:fieldValidDate'));
|
|
344
|
-
} else {
|
|
345
|
-
var today = new Date();
|
|
346
|
-
var todayOnly = new Date(today.getFullYear(), today.getMonth(), today.getDate());
|
|
347
|
-
if (date > todayOnly) {
|
|
348
|
-
fieldErrors.dobDay = ' ';
|
|
349
|
-
fieldErrors.dobMonth = ' ';
|
|
350
|
-
fieldErrors.dobYear = ' ';
|
|
351
|
-
messages.push(t('Validation:birthdayInFuture'));
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
// Phone validation (Optional field, but must match format if provided)
|
|
358
|
-
if ((_formData_phone = formData.phone) === null || _formData_phone === void 0 ? void 0 : _formData_phone.trim()) {
|
|
359
|
-
var phoneRegex = /^[+\-()\d\s]*$/;
|
|
360
|
-
if (!phoneRegex.test(formData.phone)) {
|
|
361
|
-
fieldErrors.phone = ' ';
|
|
362
|
-
messages.push(t('Validation:fieldValidPhone', {
|
|
363
|
-
attribute: t('App:phone')
|
|
364
|
-
}));
|
|
365
|
-
} else {
|
|
366
|
-
// Enforce max of 15 numeric digits in total (ignoring spaces and symbols)
|
|
367
|
-
var digitsCount = formData.phone.replace(/\D/g, '').length;
|
|
368
|
-
if (digitsCount > 15) {
|
|
369
|
-
fieldErrors.phone = ' ';
|
|
370
|
-
messages.push(t('Validation:fieldMaxLength', {
|
|
371
|
-
attribute: t('App:phone'),
|
|
372
|
-
max: 15
|
|
373
|
-
}));
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
setErrors(fieldErrors);
|
|
378
|
-
return {
|
|
379
|
-
isValid: messages.length === 0,
|
|
380
|
-
messages: messages
|
|
381
|
-
};
|
|
382
|
-
};
|
|
383
|
-
var handleSubmit = function(e) {
|
|
384
|
-
e.preventDefault();
|
|
385
|
-
var _validate = validate(), isValid = _validate.isValid, messages = _validate.messages;
|
|
386
|
-
if (isValid) {
|
|
387
|
-
// Clear draft from storage on successful validation
|
|
388
|
-
try {
|
|
389
|
-
sessionStorage.removeItem(STORAGE_KEY);
|
|
390
|
-
} catch (error) {
|
|
391
|
-
console.error('Failed to clear form data:', error);
|
|
392
|
-
}
|
|
393
|
-
onSave(formData);
|
|
394
|
-
} else {
|
|
395
|
-
showAlert({
|
|
396
|
-
type: 'error',
|
|
397
|
-
title: 'Form Error',
|
|
398
|
-
message: messages
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
};
|
|
402
|
-
return /*#__PURE__*/ jsxs("form", {
|
|
403
|
-
onSubmit: handleSubmit,
|
|
404
|
-
noValidate: true,
|
|
405
|
-
className: "tw-flex tw-flex-col tw-gap-6",
|
|
406
|
-
children: [
|
|
407
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
408
|
-
label: t('App:firstName', "First"),
|
|
409
|
-
name: "firstName",
|
|
410
|
-
value: formData.firstName,
|
|
411
|
-
onChange: handleChange,
|
|
412
|
-
error: errors.firstName,
|
|
413
|
-
required: true
|
|
414
|
-
}),
|
|
415
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
416
|
-
label: t('App:lastName', "Last Name"),
|
|
417
|
-
name: "lastName",
|
|
418
|
-
value: formData.lastName,
|
|
419
|
-
onChange: handleChange,
|
|
420
|
-
error: errors.lastName,
|
|
421
|
-
required: true
|
|
422
|
-
}),
|
|
423
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
424
|
-
label: t('App:emailAddress', "Email Address"),
|
|
425
|
-
name: "email",
|
|
426
|
-
type: "text",
|
|
427
|
-
value: formData.email,
|
|
428
|
-
onChange: handleChange,
|
|
429
|
-
error: errors.email,
|
|
430
|
-
required: true,
|
|
431
|
-
readOnly: isEditing,
|
|
432
|
-
disabled: isEditing,
|
|
433
|
-
helperText: isEditing ? t('App:emailCannotBeEdited') : undefined
|
|
434
|
-
}),
|
|
435
|
-
/*#__PURE__*/ jsxs("div", {
|
|
436
|
-
className: "tw-flex tw-flex-col tw-gap-2",
|
|
437
|
-
children: [
|
|
438
|
-
/*#__PURE__*/ jsx("div", {
|
|
439
|
-
className: "tw-flex tw-items-center tw-gap-1",
|
|
440
|
-
children: /*#__PURE__*/ jsx("label", {
|
|
441
|
-
className: "tw-text-[15px] tw-font-semibold tw-text-[#121E52] tw-leading-5",
|
|
442
|
-
children: "Date of Birth (Optional)"
|
|
443
|
-
})
|
|
444
|
-
}),
|
|
445
|
-
/*#__PURE__*/ jsxs("div", {
|
|
446
|
-
className: "tw-grid tw-grid-cols-3 tw-gap-4",
|
|
447
|
-
children: [
|
|
448
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
449
|
-
label: t("App:day", "Day"),
|
|
450
|
-
name: "dobDay",
|
|
451
|
-
value: formData.dobDay,
|
|
452
|
-
onChange: handleChange,
|
|
453
|
-
error: errors.dobDay,
|
|
454
|
-
className: "dob-input"
|
|
455
|
-
}),
|
|
456
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
457
|
-
label: t("App:month", "Month"),
|
|
458
|
-
name: "dobMonth",
|
|
459
|
-
value: formData.dobMonth,
|
|
460
|
-
onChange: handleChange,
|
|
461
|
-
error: errors.dobMonth,
|
|
462
|
-
className: "dob-input"
|
|
463
|
-
}),
|
|
464
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
465
|
-
label: t("App:year", "Year"),
|
|
466
|
-
name: "dobYear",
|
|
467
|
-
value: formData.dobYear,
|
|
468
|
-
onChange: handleChange,
|
|
469
|
-
error: errors.dobYear,
|
|
470
|
-
className: "dob-input"
|
|
471
|
-
})
|
|
472
|
-
]
|
|
473
|
-
})
|
|
474
|
-
]
|
|
475
|
-
}),
|
|
476
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
477
|
-
label: t('App:phone', "Phone Number"),
|
|
478
|
-
name: "phone",
|
|
479
|
-
value: formData.phone,
|
|
480
|
-
onChange: handleChange,
|
|
481
|
-
error: errors.phone,
|
|
482
|
-
optional: true
|
|
483
|
-
}),
|
|
484
|
-
/*#__PURE__*/ jsx(Checkbox, {
|
|
485
|
-
label: "Opt-in to marketing communications",
|
|
486
|
-
name: "optIn",
|
|
487
|
-
checked: formData.optIn,
|
|
488
|
-
onChange: handleChange
|
|
489
|
-
}),
|
|
490
|
-
/*#__PURE__*/ jsx(NewInput, {
|
|
491
|
-
label: t('App:postcode', "Postcode"),
|
|
492
|
-
name: "postcode",
|
|
493
|
-
value: formData.postcode,
|
|
494
|
-
onChange: handleChange,
|
|
495
|
-
optional: true
|
|
496
|
-
}),
|
|
497
|
-
/*#__PURE__*/ jsxs(Select, {
|
|
498
|
-
label: t('App:gender', "Gender"),
|
|
499
|
-
name: "gender",
|
|
500
|
-
value: formData.gender,
|
|
501
|
-
onChange: handleSelectChange,
|
|
502
|
-
optional: true,
|
|
503
|
-
children: [
|
|
504
|
-
/*#__PURE__*/ jsx("option", {
|
|
505
|
-
value: "",
|
|
506
|
-
children: t('App:selectGender', "Select gender")
|
|
507
|
-
}),
|
|
508
|
-
/*#__PURE__*/ jsx("option", {
|
|
509
|
-
value: "female",
|
|
510
|
-
children: t('App:female', "Female")
|
|
511
|
-
}),
|
|
512
|
-
/*#__PURE__*/ jsx("option", {
|
|
513
|
-
value: "male",
|
|
514
|
-
children: t('App:male', "Male")
|
|
515
|
-
}),
|
|
516
|
-
/*#__PURE__*/ jsx("option", {
|
|
517
|
-
value: "prefer_not_to_say",
|
|
518
|
-
children: t('App:preferNotToSay', "Prefer not to say")
|
|
519
|
-
})
|
|
520
|
-
]
|
|
521
|
-
}),
|
|
522
|
-
/*#__PURE__*/ jsx("div", {
|
|
523
|
-
className: "tw-pt-4",
|
|
524
|
-
children: /*#__PURE__*/ jsx(Button, {
|
|
525
|
-
type: "submit",
|
|
526
|
-
disabled: isLoading,
|
|
527
|
-
className: "tw-px-8",
|
|
528
|
-
children: isLoading ? 'Saving...' : submitButtonLabel
|
|
529
|
-
})
|
|
530
|
-
})
|
|
531
|
-
]
|
|
532
|
-
});
|
|
533
|
-
};
|
|
534
|
-
|
|
535
|
-
export { CustomerForm };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/v2/components/Customer/CustomerForm/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { NewTableColumn } from '../NewTable';
|
|
3
|
-
import './CustomersList.scss';
|
|
4
|
-
export interface CustomersListProps {
|
|
5
|
-
t: (key: string, options?: any) => string;
|
|
6
|
-
customers: any[];
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
kioskLink?: string;
|
|
9
|
-
waiversEnabled?: boolean;
|
|
10
|
-
search: string;
|
|
11
|
-
onSearchChange: (value: string) => void;
|
|
12
|
-
onSearchIconClick?: () => void;
|
|
13
|
-
onClearSearch?: () => void;
|
|
14
|
-
quickFilters: string[];
|
|
15
|
-
onQuickFiltersChange: (values: string[]) => void;
|
|
16
|
-
onRefresh: () => void;
|
|
17
|
-
onExport: () => void;
|
|
18
|
-
onSendWaiverRequest: () => void;
|
|
19
|
-
onAddCustomer?: () => void;
|
|
20
|
-
onTabChange?: (tabId: string) => void;
|
|
21
|
-
activeTab?: string;
|
|
22
|
-
tabs?: {
|
|
23
|
-
id: string;
|
|
24
|
-
label: string;
|
|
25
|
-
path: string;
|
|
26
|
-
}[];
|
|
27
|
-
columns: NewTableColumn<any>[];
|
|
28
|
-
pagination?: {
|
|
29
|
-
currentPage: number;
|
|
30
|
-
totalPages: number;
|
|
31
|
-
onPageChange: (page: number) => void;
|
|
32
|
-
totalItems?: number;
|
|
33
|
-
itemsPerPage?: number;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export declare const CustomersList: React.FC<CustomersListProps>;
|
|
37
|
-
//# sourceMappingURL=CustomersList.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomersList.d.ts","sourceRoot":"","sources":["../../../../src/v2/components/Customer/CustomersList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAY,cAAc,EAAE,MAAM,aAAa,CAAA;AAItD,OAAO,sBAAsB,CAAA;AAE7B,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,KAAK,MAAM,CAAA;IACzC,SAAS,EAAE,GAAG,EAAE,CAAA;IAChB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACvC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC9B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,oBAAoB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAChD,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,mBAAmB,EAAE,MAAM,IAAI,CAAA;IAC/B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;IAC1B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACpD,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAA;IAC9B,UAAU,CAAC,EAAE;QACX,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,MAAM,CAAA;QAClB,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;QACpC,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;CACF;AAGD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA0JtD,CAAA"}
|