goobs-frontend 0.7.66 → 0.7.67
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/package.json +2 -2
- package/src/app/_app.tsx +8 -8
- package/src/components/Button/hook/useHelperFooter.tsx +65 -75
- package/src/components/Button/index.tsx +4 -9
- package/src/components/StyledComponent/hooks/useDropdown.tsx +31 -27
- package/src/components/StyledComponent/hooks/useInputHelperFooter.tsx +133 -176
- package/src/components/StyledComponent/hooks/usePhoneNumber.tsx +9 -6
- package/src/components/StyledComponent/hooks/useRequiredFieldsValidator.tsx +130 -77
- package/src/components/StyledComponent/hooks/useSearchbar.tsx +2 -0
- package/src/components/StyledComponent/hooks/useSplitButton.tsx +15 -11
- package/src/components/StyledComponent/index.tsx +212 -165
- package/src/components/StyledComponent/{useEffects → useCallbacks}/index.tsx +17 -20
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useCallback, useMemo
|
|
3
|
+
import { useCallback, useMemo } from 'react'
|
|
4
4
|
import { debounce } from 'lodash'
|
|
5
5
|
import { session } from 'goobs-cache'
|
|
6
|
+
import { ClientLogger } from 'goobs-testing'
|
|
6
7
|
|
|
7
8
|
const isValidEmailFormat = (email: string): boolean => {
|
|
8
|
-
|
|
9
|
+
ClientLogger.debug('Validating email format:', { email })
|
|
9
10
|
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
|
|
10
11
|
const isValid = emailRegex.test(email)
|
|
11
|
-
|
|
12
|
+
ClientLogger.debug('Email format is valid:', { isValid })
|
|
12
13
|
return isValid
|
|
13
14
|
}
|
|
14
15
|
|
|
@@ -21,14 +22,18 @@ export interface HelperFooterMessage {
|
|
|
21
22
|
hasInput?: boolean
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
export const useInputHelperFooter = (
|
|
25
|
-
|
|
25
|
+
export const useInputHelperFooter = (
|
|
26
|
+
helperFooterAtom: ReturnType<
|
|
27
|
+
typeof session.atom<Record<string, HelperFooterMessage>>
|
|
28
|
+
>
|
|
29
|
+
) => {
|
|
30
|
+
ClientLogger.debug('useInputHelperFooter hook called')
|
|
26
31
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
+
const validateAtom = useMemo(() => session.atom(''), [])
|
|
33
|
+
|
|
34
|
+
const [helperFooterValue, setHelperFooters] =
|
|
35
|
+
session.useAtom(helperFooterAtom)
|
|
36
|
+
const [validateValue, setValidateValue] = session.useAtom(validateAtom)
|
|
32
37
|
|
|
33
38
|
const handleGenericErrorCreation = useCallback(
|
|
34
39
|
async (
|
|
@@ -38,16 +43,16 @@ export const useInputHelperFooter = () => {
|
|
|
38
43
|
formname: string,
|
|
39
44
|
priority?: number
|
|
40
45
|
): Promise<HelperFooterMessage | undefined> => {
|
|
41
|
-
|
|
46
|
+
ClientLogger.debug('handleGenericErrorCreation called:', {
|
|
42
47
|
name,
|
|
43
48
|
label,
|
|
44
49
|
formname,
|
|
45
50
|
priority,
|
|
46
51
|
})
|
|
47
52
|
const value = formData.get(name) as string
|
|
48
|
-
|
|
53
|
+
ClientLogger.debug('Form data value:', { value })
|
|
49
54
|
if (!value || !value.trim()) {
|
|
50
|
-
|
|
55
|
+
ClientLogger.debug('Value is empty or whitespace')
|
|
51
56
|
const message: HelperFooterMessage = {
|
|
52
57
|
status: 'error',
|
|
53
58
|
statusMessage: `${label} is required. Please enter a ${label.toLowerCase()}.`,
|
|
@@ -55,31 +60,23 @@ export const useInputHelperFooter = () => {
|
|
|
55
60
|
spreadMessagePriority: priority ?? 1,
|
|
56
61
|
required: true,
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
setHelperFooter(prev => {
|
|
61
|
-
if (prev instanceof Promise) {
|
|
62
|
-
return prev
|
|
63
|
-
}
|
|
64
|
-
return { ...prev, [name]: message }
|
|
65
|
-
})
|
|
63
|
+
ClientLogger.debug('Created error message:', { message })
|
|
64
|
+
setHelperFooters(prev => ({ ...prev, [name]: message }))
|
|
66
65
|
return message
|
|
67
66
|
} else {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return prev
|
|
73
|
-
}
|
|
67
|
+
ClientLogger.debug(
|
|
68
|
+
'Value is not empty, removing helper footer from cache'
|
|
69
|
+
)
|
|
70
|
+
setHelperFooters(prev => {
|
|
74
71
|
const newState = { ...prev }
|
|
75
72
|
delete newState[name]
|
|
76
73
|
return newState
|
|
77
74
|
})
|
|
78
75
|
}
|
|
79
|
-
|
|
76
|
+
ClientLogger.debug('Returning undefined (no error)')
|
|
80
77
|
return undefined
|
|
81
78
|
},
|
|
82
|
-
[
|
|
79
|
+
[setHelperFooters]
|
|
83
80
|
)
|
|
84
81
|
|
|
85
82
|
const handleEmailErrorCreation = useCallback(
|
|
@@ -87,13 +84,13 @@ export const useInputHelperFooter = () => {
|
|
|
87
84
|
formData: FormData,
|
|
88
85
|
formname: string
|
|
89
86
|
): Promise<HelperFooterMessage | undefined> => {
|
|
90
|
-
|
|
87
|
+
ClientLogger.debug('handleEmailErrorCreation called:', { formname })
|
|
91
88
|
const email = formData.get('email') as string
|
|
92
|
-
|
|
89
|
+
ClientLogger.debug('Email value:', { email })
|
|
93
90
|
let message: HelperFooterMessage | undefined
|
|
94
91
|
|
|
95
92
|
if (!email || !email.trim()) {
|
|
96
|
-
|
|
93
|
+
ClientLogger.debug('Email is empty or whitespace')
|
|
97
94
|
message = {
|
|
98
95
|
status: 'error',
|
|
99
96
|
statusMessage: 'Please enter an email address.',
|
|
@@ -102,7 +99,7 @@ export const useInputHelperFooter = () => {
|
|
|
102
99
|
required: true,
|
|
103
100
|
}
|
|
104
101
|
} else if (!isValidEmailFormat(email)) {
|
|
105
|
-
|
|
102
|
+
ClientLogger.debug('Email format is invalid')
|
|
106
103
|
message = {
|
|
107
104
|
status: 'error',
|
|
108
105
|
statusMessage: 'Please enter a valid email address.',
|
|
@@ -111,7 +108,7 @@ export const useInputHelperFooter = () => {
|
|
|
111
108
|
required: true,
|
|
112
109
|
}
|
|
113
110
|
} else {
|
|
114
|
-
|
|
111
|
+
ClientLogger.debug('Email is valid')
|
|
115
112
|
message = {
|
|
116
113
|
status: 'success',
|
|
117
114
|
statusMessage: 'Email is valid.',
|
|
@@ -122,32 +119,23 @@ export const useInputHelperFooter = () => {
|
|
|
122
119
|
}
|
|
123
120
|
|
|
124
121
|
if (message) {
|
|
125
|
-
|
|
126
|
-
const [, setHelperFooter] = session.useAtom(helperFooterAtom)
|
|
122
|
+
ClientLogger.debug('Message created:', { message })
|
|
127
123
|
if (message.status === 'success') {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (prev instanceof Promise) {
|
|
131
|
-
return prev
|
|
132
|
-
}
|
|
124
|
+
ClientLogger.debug('Removing helper footer from cache')
|
|
125
|
+
setHelperFooters(prev => {
|
|
133
126
|
const newState = { ...prev }
|
|
134
127
|
delete newState['email']
|
|
135
128
|
return newState
|
|
136
129
|
})
|
|
137
130
|
} else {
|
|
138
|
-
|
|
139
|
-
if (prev instanceof Promise) {
|
|
140
|
-
return prev
|
|
141
|
-
}
|
|
142
|
-
return { ...prev, email: message! }
|
|
143
|
-
})
|
|
131
|
+
setHelperFooters(prev => ({ ...prev, email: message }))
|
|
144
132
|
}
|
|
145
133
|
}
|
|
146
134
|
|
|
147
|
-
|
|
135
|
+
ClientLogger.debug('Returning message:', { message })
|
|
148
136
|
return message
|
|
149
137
|
},
|
|
150
|
-
[
|
|
138
|
+
[setHelperFooters]
|
|
151
139
|
)
|
|
152
140
|
|
|
153
141
|
const handlePasswordErrorCreation = useCallback(
|
|
@@ -155,15 +143,14 @@ export const useInputHelperFooter = () => {
|
|
|
155
143
|
formData: FormData,
|
|
156
144
|
formname: string
|
|
157
145
|
): Promise<HelperFooterMessage | undefined> => {
|
|
158
|
-
|
|
146
|
+
ClientLogger.debug('handlePasswordErrorCreation called:', { formname })
|
|
159
147
|
const password = formData.get('verifyPassword') as string
|
|
160
|
-
|
|
148
|
+
ClientLogger.debug('Password value:', { passwordProvided: !!password })
|
|
161
149
|
|
|
162
|
-
const [, setValidate] = session.useAtom(validateAtom)
|
|
163
150
|
const debouncedPasswordStorage = debounce(() => {
|
|
164
151
|
if (password) {
|
|
165
|
-
|
|
166
|
-
|
|
152
|
+
ClientLogger.debug('Storing password in cache (debounced)')
|
|
153
|
+
setValidateValue(password)
|
|
167
154
|
}
|
|
168
155
|
}, 2000)
|
|
169
156
|
|
|
@@ -172,7 +159,7 @@ export const useInputHelperFooter = () => {
|
|
|
172
159
|
let message: HelperFooterMessage | undefined
|
|
173
160
|
|
|
174
161
|
if (!password || !password.trim()) {
|
|
175
|
-
|
|
162
|
+
ClientLogger.debug('Password is empty or whitespace')
|
|
176
163
|
message = {
|
|
177
164
|
status: 'error',
|
|
178
165
|
statusMessage: 'Password is required.',
|
|
@@ -185,7 +172,9 @@ export const useInputHelperFooter = () => {
|
|
|
185
172
|
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/
|
|
186
173
|
const passwordComplexityStatus: 'error' | 'success' =
|
|
187
174
|
passwordRegex.test(password) ? 'success' : 'error'
|
|
188
|
-
|
|
175
|
+
ClientLogger.debug('Password complexity status:', {
|
|
176
|
+
passwordComplexityStatus,
|
|
177
|
+
})
|
|
189
178
|
|
|
190
179
|
if (passwordComplexityStatus === 'error') {
|
|
191
180
|
message = {
|
|
@@ -208,32 +197,23 @@ export const useInputHelperFooter = () => {
|
|
|
208
197
|
}
|
|
209
198
|
|
|
210
199
|
if (message) {
|
|
211
|
-
|
|
212
|
-
const [, setHelperFooter] = session.useAtom(helperFooterAtom)
|
|
200
|
+
ClientLogger.debug('Message created:', { message })
|
|
213
201
|
if (message.status === 'success') {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
if (prev instanceof Promise) {
|
|
217
|
-
return prev
|
|
218
|
-
}
|
|
202
|
+
ClientLogger.debug('Removing helper footer from cache')
|
|
203
|
+
setHelperFooters(prev => {
|
|
219
204
|
const newState = { ...prev }
|
|
220
205
|
delete newState['verifyPassword']
|
|
221
206
|
return newState
|
|
222
207
|
})
|
|
223
208
|
} else {
|
|
224
|
-
|
|
225
|
-
if (prev instanceof Promise) {
|
|
226
|
-
return prev
|
|
227
|
-
}
|
|
228
|
-
return { ...prev, verifyPassword: message }
|
|
229
|
-
})
|
|
209
|
+
setHelperFooters(prev => ({ ...prev, verifyPassword: message }))
|
|
230
210
|
}
|
|
231
211
|
}
|
|
232
212
|
|
|
233
|
-
|
|
213
|
+
ClientLogger.debug('Returning message:', { message })
|
|
234
214
|
return message
|
|
235
215
|
},
|
|
236
|
-
[
|
|
216
|
+
[setHelperFooters, setValidateValue]
|
|
237
217
|
)
|
|
238
218
|
|
|
239
219
|
const handleConfirmPasswordErrorCreation = useCallback(
|
|
@@ -241,17 +221,18 @@ export const useInputHelperFooter = () => {
|
|
|
241
221
|
formData: FormData,
|
|
242
222
|
formname: string
|
|
243
223
|
): Promise<HelperFooterMessage | undefined> => {
|
|
244
|
-
|
|
224
|
+
ClientLogger.debug('handleConfirmPasswordErrorCreation called:', {
|
|
225
|
+
formname,
|
|
226
|
+
})
|
|
245
227
|
const confirmPassword = formData.get('confirmPassword') as string
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
)
|
|
228
|
+
ClientLogger.debug('Confirm password value:', {
|
|
229
|
+
passwordProvided: !!confirmPassword,
|
|
230
|
+
})
|
|
250
231
|
|
|
251
232
|
let message: HelperFooterMessage | undefined
|
|
252
233
|
|
|
253
234
|
if (!confirmPassword || !confirmPassword.trim()) {
|
|
254
|
-
|
|
235
|
+
ClientLogger.debug('Confirm password is empty or whitespace')
|
|
255
236
|
message = {
|
|
256
237
|
status: 'error',
|
|
257
238
|
statusMessage: 'Please confirm your password.',
|
|
@@ -260,11 +241,10 @@ export const useInputHelperFooter = () => {
|
|
|
260
241
|
required: true,
|
|
261
242
|
}
|
|
262
243
|
} else {
|
|
263
|
-
|
|
264
|
-
console.log('Fetched verify password from session atom')
|
|
244
|
+
ClientLogger.debug('Fetched verify password from session atom')
|
|
265
245
|
|
|
266
|
-
if (!
|
|
267
|
-
|
|
246
|
+
if (!validateValue) {
|
|
247
|
+
ClientLogger.debug('Verify password not found')
|
|
268
248
|
message = {
|
|
269
249
|
status: 'error',
|
|
270
250
|
statusMessage: 'Please enter your password first.',
|
|
@@ -272,8 +252,8 @@ export const useInputHelperFooter = () => {
|
|
|
272
252
|
spreadMessagePriority: 3,
|
|
273
253
|
required: true,
|
|
274
254
|
}
|
|
275
|
-
} else if (confirmPassword !==
|
|
276
|
-
|
|
255
|
+
} else if (confirmPassword !== validateValue) {
|
|
256
|
+
ClientLogger.debug('Passwords do not match')
|
|
277
257
|
message = {
|
|
278
258
|
status: 'error',
|
|
279
259
|
statusMessage: 'Passwords do not match.',
|
|
@@ -282,7 +262,7 @@ export const useInputHelperFooter = () => {
|
|
|
282
262
|
required: true,
|
|
283
263
|
}
|
|
284
264
|
} else {
|
|
285
|
-
|
|
265
|
+
ClientLogger.debug('Passwords match')
|
|
286
266
|
message = {
|
|
287
267
|
status: 'success',
|
|
288
268
|
statusMessage: 'Passwords match.',
|
|
@@ -294,32 +274,23 @@ export const useInputHelperFooter = () => {
|
|
|
294
274
|
}
|
|
295
275
|
|
|
296
276
|
if (message) {
|
|
297
|
-
|
|
298
|
-
const [, setHelperFooter] = session.useAtom(helperFooterAtom)
|
|
277
|
+
ClientLogger.debug('Message created:', { message })
|
|
299
278
|
if (message.status === 'success') {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
if (prev instanceof Promise) {
|
|
303
|
-
return prev
|
|
304
|
-
}
|
|
279
|
+
ClientLogger.debug('Removing helper footer from cache')
|
|
280
|
+
setHelperFooters(prev => {
|
|
305
281
|
const newState = { ...prev }
|
|
306
282
|
delete newState['confirmPassword']
|
|
307
283
|
return newState
|
|
308
284
|
})
|
|
309
285
|
} else {
|
|
310
|
-
|
|
311
|
-
if (prev instanceof Promise) {
|
|
312
|
-
return prev
|
|
313
|
-
}
|
|
314
|
-
return { ...prev, confirmPassword: message }
|
|
315
|
-
})
|
|
286
|
+
setHelperFooters(prev => ({ ...prev, confirmPassword: message }))
|
|
316
287
|
}
|
|
317
288
|
}
|
|
318
289
|
|
|
319
|
-
|
|
290
|
+
ClientLogger.debug('Returning message:', { message })
|
|
320
291
|
return message
|
|
321
292
|
},
|
|
322
|
-
[
|
|
293
|
+
[setHelperFooters, validateValue]
|
|
323
294
|
)
|
|
324
295
|
|
|
325
296
|
const handlePhoneNumberErrorCreation = useCallback(
|
|
@@ -327,13 +298,13 @@ export const useInputHelperFooter = () => {
|
|
|
327
298
|
formData: FormData,
|
|
328
299
|
formname: string
|
|
329
300
|
): Promise<HelperFooterMessage | undefined> => {
|
|
330
|
-
|
|
301
|
+
ClientLogger.debug('handlePhoneNumberErrorCreation called:', { formname })
|
|
331
302
|
const phoneNumber = formData.get('phoneNumber') as string
|
|
332
|
-
|
|
303
|
+
ClientLogger.debug('Phone number value:', { phoneNumber })
|
|
333
304
|
let message: HelperFooterMessage | undefined
|
|
334
305
|
|
|
335
306
|
if (!phoneNumber || !phoneNumber.trim()) {
|
|
336
|
-
|
|
307
|
+
ClientLogger.debug('Phone number is empty or whitespace')
|
|
337
308
|
message = {
|
|
338
309
|
status: 'error',
|
|
339
310
|
statusMessage:
|
|
@@ -345,12 +316,12 @@ export const useInputHelperFooter = () => {
|
|
|
345
316
|
} else {
|
|
346
317
|
const digitsOnly = phoneNumber.replace(/[^\d]/g, '')
|
|
347
318
|
const length = digitsOnly.length
|
|
348
|
-
|
|
319
|
+
ClientLogger.debug('Phone number length (digits only):', { length })
|
|
349
320
|
if (
|
|
350
321
|
(length === 10 && !digitsOnly.startsWith('1')) ||
|
|
351
322
|
(length === 11 && digitsOnly.startsWith('1'))
|
|
352
323
|
) {
|
|
353
|
-
|
|
324
|
+
ClientLogger.debug('Phone number is valid')
|
|
354
325
|
message = {
|
|
355
326
|
status: 'success',
|
|
356
327
|
statusMessage: 'Phone number is valid.',
|
|
@@ -359,7 +330,7 @@ export const useInputHelperFooter = () => {
|
|
|
359
330
|
required: true,
|
|
360
331
|
}
|
|
361
332
|
} else {
|
|
362
|
-
|
|
333
|
+
ClientLogger.debug('Phone number is invalid')
|
|
363
334
|
message = {
|
|
364
335
|
status: 'error',
|
|
365
336
|
statusMessage:
|
|
@@ -372,61 +343,46 @@ export const useInputHelperFooter = () => {
|
|
|
372
343
|
}
|
|
373
344
|
|
|
374
345
|
if (message) {
|
|
375
|
-
|
|
376
|
-
const [, setHelperFooter] = session.useAtom(helperFooterAtom)
|
|
346
|
+
ClientLogger.debug('Message created:', { message })
|
|
377
347
|
if (message.status === 'success') {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if (prev instanceof Promise) {
|
|
381
|
-
return prev
|
|
382
|
-
}
|
|
348
|
+
ClientLogger.debug('Removing helper footer from cache')
|
|
349
|
+
setHelperFooters(prev => {
|
|
383
350
|
const newState = { ...prev }
|
|
384
351
|
delete newState['phoneNumber']
|
|
385
352
|
return newState
|
|
386
353
|
})
|
|
387
354
|
} else {
|
|
388
|
-
|
|
389
|
-
if (prev instanceof Promise) {
|
|
390
|
-
return prev
|
|
391
|
-
}
|
|
392
|
-
return { ...prev, phoneNumber: message }
|
|
393
|
-
})
|
|
355
|
+
setHelperFooters(prev => ({ ...prev, phoneNumber: message }))
|
|
394
356
|
}
|
|
395
357
|
}
|
|
396
358
|
|
|
397
|
-
|
|
359
|
+
ClientLogger.debug('Returning message:', { message })
|
|
398
360
|
return message
|
|
399
361
|
},
|
|
400
|
-
[
|
|
362
|
+
[setHelperFooters]
|
|
401
363
|
)
|
|
402
364
|
|
|
403
365
|
const updateHelperFooter = useCallback(
|
|
404
366
|
(name: string, validationResult: HelperFooterMessage | undefined): void => {
|
|
405
|
-
|
|
406
|
-
|
|
367
|
+
ClientLogger.debug('updateHelperFooter called:', {
|
|
368
|
+
name,
|
|
369
|
+
validationResult,
|
|
370
|
+
})
|
|
407
371
|
if (validationResult) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (prev instanceof Promise) {
|
|
411
|
-
return prev
|
|
412
|
-
}
|
|
413
|
-
return { ...prev, [name]: validationResult }
|
|
414
|
-
})
|
|
372
|
+
ClientLogger.debug('Updating helper footer with new validation result')
|
|
373
|
+
setHelperFooters(prev => ({ ...prev, [name]: validationResult }))
|
|
415
374
|
} else {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (prev instanceof Promise) {
|
|
419
|
-
return prev
|
|
420
|
-
}
|
|
375
|
+
ClientLogger.debug('Removing field from helper footer')
|
|
376
|
+
setHelperFooters(prev => {
|
|
421
377
|
const newState = { ...prev }
|
|
422
378
|
delete newState[name]
|
|
423
379
|
return newState
|
|
424
380
|
})
|
|
425
381
|
}
|
|
426
382
|
|
|
427
|
-
|
|
383
|
+
ClientLogger.debug('Helper footer updated')
|
|
428
384
|
},
|
|
429
|
-
[
|
|
385
|
+
[setHelperFooters]
|
|
430
386
|
)
|
|
431
387
|
|
|
432
388
|
const validateField = useCallback(
|
|
@@ -437,37 +393,42 @@ export const useInputHelperFooter = () => {
|
|
|
437
393
|
formname: string,
|
|
438
394
|
priority?: number
|
|
439
395
|
) => {
|
|
440
|
-
|
|
396
|
+
ClientLogger.debug('validateField called:', {
|
|
397
|
+
name,
|
|
398
|
+
label,
|
|
399
|
+
formname,
|
|
400
|
+
priority,
|
|
401
|
+
})
|
|
441
402
|
let validationResult: HelperFooterMessage | undefined
|
|
442
403
|
|
|
443
404
|
switch (name) {
|
|
444
405
|
case 'email':
|
|
445
|
-
|
|
406
|
+
ClientLogger.debug('Validating email field')
|
|
446
407
|
validationResult = await handleEmailErrorCreation(formData, formname)
|
|
447
408
|
break
|
|
448
409
|
case 'verifyPassword':
|
|
449
|
-
|
|
410
|
+
ClientLogger.debug('Validating password field')
|
|
450
411
|
validationResult = await handlePasswordErrorCreation(
|
|
451
412
|
formData,
|
|
452
413
|
formname
|
|
453
414
|
)
|
|
454
415
|
break
|
|
455
416
|
case 'confirmPassword':
|
|
456
|
-
|
|
417
|
+
ClientLogger.debug('Validating confirm password field')
|
|
457
418
|
validationResult = await handleConfirmPasswordErrorCreation(
|
|
458
419
|
formData,
|
|
459
420
|
formname
|
|
460
421
|
)
|
|
461
422
|
break
|
|
462
423
|
case 'phoneNumber':
|
|
463
|
-
|
|
424
|
+
ClientLogger.debug('Validating phone number field')
|
|
464
425
|
validationResult = await handlePhoneNumberErrorCreation(
|
|
465
426
|
formData,
|
|
466
427
|
formname
|
|
467
428
|
)
|
|
468
429
|
break
|
|
469
430
|
default:
|
|
470
|
-
|
|
431
|
+
ClientLogger.debug('Validating generic field')
|
|
471
432
|
validationResult = await handleGenericErrorCreation(
|
|
472
433
|
formData,
|
|
473
434
|
name,
|
|
@@ -477,7 +438,7 @@ export const useInputHelperFooter = () => {
|
|
|
477
438
|
)
|
|
478
439
|
}
|
|
479
440
|
|
|
480
|
-
|
|
441
|
+
ClientLogger.debug('Validation result:', { validationResult })
|
|
481
442
|
updateHelperFooter(name, validationResult)
|
|
482
443
|
},
|
|
483
444
|
[
|
|
@@ -490,45 +451,40 @@ export const useInputHelperFooter = () => {
|
|
|
490
451
|
]
|
|
491
452
|
)
|
|
492
453
|
|
|
493
|
-
const useShowErrorEffect = (
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
useEffect(() => {
|
|
454
|
+
const useShowErrorEffect = useCallback(
|
|
455
|
+
(
|
|
456
|
+
formSubmitted: boolean,
|
|
457
|
+
hasInput: boolean,
|
|
458
|
+
isFocused: boolean
|
|
459
|
+
): boolean => {
|
|
460
|
+
ClientLogger.debug('useShowErrorEffect called:', {
|
|
461
|
+
formSubmitted,
|
|
462
|
+
hasInput,
|
|
463
|
+
isFocused,
|
|
464
|
+
})
|
|
465
|
+
|
|
507
466
|
const shouldShowError = formSubmitted || (hasInput && !isFocused)
|
|
508
|
-
|
|
467
|
+
ClientLogger.debug('Calculating shouldShowError:', {
|
|
509
468
|
shouldShowError,
|
|
510
469
|
formSubmitted,
|
|
511
470
|
hasInput,
|
|
512
471
|
isFocused,
|
|
513
472
|
})
|
|
514
|
-
setShowError(shouldShowError)
|
|
515
|
-
}, [formSubmitted, hasInput, isFocused, setShowError])
|
|
516
473
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
474
|
+
ClientLogger.debug('Returning showError:', { shouldShowError })
|
|
475
|
+
return shouldShowError
|
|
476
|
+
},
|
|
477
|
+
[]
|
|
478
|
+
)
|
|
520
479
|
|
|
521
480
|
const fetchHelperFooters = useCallback(
|
|
522
481
|
async (formname: string): Promise<HelperFooterMessage[]> => {
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (helperFooters instanceof Promise) {
|
|
528
|
-
return []
|
|
529
|
-
}
|
|
482
|
+
ClientLogger.debug('fetchHelperFooters called:', { formname })
|
|
483
|
+
ClientLogger.debug('Fetched helper footers from session atom:', {
|
|
484
|
+
helperFooterValue,
|
|
485
|
+
})
|
|
530
486
|
|
|
531
|
-
const filteredHelperFooters = Object.values(
|
|
487
|
+
const filteredHelperFooters = Object.values(helperFooterValue).filter(
|
|
532
488
|
(item): item is HelperFooterMessage => {
|
|
533
489
|
const isValidHelperFooter =
|
|
534
490
|
typeof item === 'object' &&
|
|
@@ -538,17 +494,17 @@ export const useInputHelperFooter = () => {
|
|
|
538
494
|
'spreadMessage' in item &&
|
|
539
495
|
'spreadMessagePriority' in item &&
|
|
540
496
|
'required' in item
|
|
541
|
-
|
|
497
|
+
ClientLogger.debug('Checking if item is valid HelperFooterMessage:', {
|
|
542
498
|
item,
|
|
543
499
|
isValid: isValidHelperFooter,
|
|
544
500
|
})
|
|
545
501
|
return isValidHelperFooter
|
|
546
502
|
}
|
|
547
503
|
)
|
|
548
|
-
|
|
504
|
+
ClientLogger.debug('Filtered helper footers:', { filteredHelperFooters })
|
|
549
505
|
return filteredHelperFooters
|
|
550
506
|
},
|
|
551
|
-
[
|
|
507
|
+
[helperFooterValue]
|
|
552
508
|
)
|
|
553
509
|
|
|
554
510
|
const result = useMemo(
|
|
@@ -556,11 +512,12 @@ export const useInputHelperFooter = () => {
|
|
|
556
512
|
validateField,
|
|
557
513
|
useShowErrorEffect,
|
|
558
514
|
fetchHelperFooters,
|
|
515
|
+
helperFooterValue,
|
|
559
516
|
}),
|
|
560
|
-
[validateField, fetchHelperFooters]
|
|
517
|
+
[validateField, useShowErrorEffect, fetchHelperFooters, helperFooterValue]
|
|
561
518
|
)
|
|
562
519
|
|
|
563
|
-
|
|
520
|
+
ClientLogger.debug('useInputHelperFooter returning result:', { result })
|
|
564
521
|
return result
|
|
565
522
|
}
|
|
566
523
|
|