@licklist/design 0.78.5-dev.19 → 0.78.5-dev.2
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/auth/Layout/UserNavDropDownToggle.js +0 -3
- package/dist/auth/Login/LoginComponent.js +2 -1
- package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
- package/dist/events/edit-event-modal/IntervalInput.js +5 -1
- package/dist/events/edit-event-modal/component/SaleDeadline/SaleDeadline.d.ts +2 -1
- package/dist/events/edit-event-modal/component/SaleDeadline/SaleDeadline.d.ts.map +1 -1
- package/dist/events/edit-event-modal/component/SaleDeadline/SaleDeadline.js +3 -2
- package/dist/events/edit-event-modal/component/SelectEventProductSet/component/EditEventProductSet.js +2 -1
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.d.ts.map +1 -1
- package/dist/events/edit-event-modal/utils/getDefaultProductSet.js +0 -1
- package/dist/events/edit-recurrent-event-modal/EditRecurrentEventModal.d.ts.map +1 -1
- package/dist/events/event-card/EventCard.d.ts +1 -1
- package/dist/events/event-card/EventCard.d.ts.map +1 -1
- package/dist/events/event-card/EventCard.js +1 -1
- package/dist/events/event-statistic-modal/EventStatisticModal.d.ts +2 -1
- package/dist/events/event-statistic-modal/EventStatisticModal.d.ts.map +1 -1
- package/dist/events/event-statistic-modal/EventStatisticModal.js +2 -2
- package/dist/events/event-statistic-modal/hooks/useTableData.d.ts +1 -1
- package/dist/events/event-statistic-modal/hooks/useTableData.d.ts.map +1 -1
- package/dist/events/event-statistic-modal/hooks/useTableData.js +2 -1
- package/dist/events/event-statistic-modal/utils/index.js +3 -3
- package/dist/events/event-venue-map/EventVenueMap.d.ts.map +1 -1
- package/dist/events/event-venue-map/EventVenueMap.js +1 -0
- package/dist/events/event-venue-map/hooks/useCanvasSize.d.ts.map +1 -1
- package/dist/events/event-venue-map/hooks/useCanvasSize.js +11 -4
- package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.d.ts.map +1 -1
- package/dist/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.js +4 -11
- package/dist/iframe/order-process/components/BookingSummary/utils/index.js +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +13 -0
- package/dist/iframe/payment/order-items-table/hooks/useTableData.d.ts.map +1 -1
- package/dist/iframe/payment/order-items-table/hooks/useTableData.js +80 -81
- package/dist/iframe/payment/payment-page/PaymentPage.js +8 -4
- package/dist/iframe/ryft/RyftPaymentForm.d.ts.map +1 -1
- package/dist/iframe/ryft/RyftPaymentForm.js +19 -45
- package/dist/iframe/ryft/utils/ryft-form.d.ts.map +1 -1
- package/dist/iframe/ryft/utils/ryft-form.js +4 -5
- package/dist/modals/dialog/Dialog.d.ts.map +1 -1
- package/dist/modals/dialog/Dialog.js +41 -39
- package/dist/notification/email-template/card/EmailTemplateCard.d.ts.map +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.d.ts +0 -1
- package/dist/notification/email-template/control/EmailTemplateControl.d.ts.map +1 -1
- package/dist/notification/email-template/control/EmailTemplateControl.js +8 -5
- package/dist/notification/email-template/form/EmailTemplateForm.d.ts +1 -2
- package/dist/notification/email-template/form/EmailTemplateForm.d.ts.map +1 -1
- package/dist/notification/email-template/form/EmailTemplateForm.js +1 -2
- package/dist/product-set/control/ProductSetControl.js +2 -1
- package/dist/product-set/form/ProductSetForm.d.ts +4 -1
- package/dist/product-set/form/ProductSetForm.d.ts.map +1 -1
- package/dist/product-set/form/ProductSetForm.js +1 -1
- package/dist/product-set/form/ProductsControl.js +1 -0
- package/dist/product-set/product/advanced-options/AdvancedOptions.js +1 -1
- package/dist/product-set/product/booking-management/ProductBookingManagementControl.d.ts.map +1 -1
- package/dist/product-set/product/booking-management/ProductBookingManagementControl.js +6 -0
- package/dist/product-set/product/deposit/ProductDepositControl.d.ts.map +1 -1
- package/dist/product-set/product/deposit/ProductDepositControl.js +3 -0
- package/dist/product-set/product/duration/ProductDurationControl.d.ts.map +1 -1
- package/dist/product-set/product/duration/ProductDurationControl.js +6 -0
- package/dist/product-set/product/price/ProductPriceControl.d.ts.map +1 -1
- package/dist/product-set/product/price/ProductPriceControl.js +3 -0
- package/dist/product-set/product/quantity/ProductQuantityConstantControl.d.ts.map +1 -1
- package/dist/product-set/product/quantity/ProductQuantityConstantControl.js +6 -0
- package/dist/product-set/product/quantity/ProductQuantityControl.d.ts.map +1 -1
- package/dist/product-set/product/quantity/ProductQuantityControl.js +6 -0
- package/dist/product-set/product/quantity/ProductQuantityRechargingControl.d.ts.map +1 -1
- package/dist/product-set/product/quantity/ProductQuantityRechargingControl.js +4 -1
- package/dist/product-set/product-category/ProductCategoryControl.d.ts.map +1 -1
- package/dist/product-set/product-category/ProductCategoryControl.js +12 -0
- package/dist/product-set/utils/index.d.ts +1 -1
- package/dist/recurrence-input/RecurrenceEndInput.d.ts.map +1 -1
- package/dist/recurrence-input/RecurrenceEndInput.js +3 -0
- package/dist/recurrence-input/RecurrenceInput.d.ts.map +1 -1
- package/dist/recurrence-input/RecurrenceInput.js +1 -1
- package/dist/recurring-date-picker-input/RecurrenceEndInput.d.ts.map +1 -1
- package/dist/resource/form/components/CapacityControl.d.ts.map +1 -1
- package/dist/resource/form/components/CapacityControl.js +3 -0
- package/dist/resource/form/components/SortControl.d.ts.map +1 -1
- package/dist/resource/form/components/SortControl.js +3 -0
- package/dist/sales/coupon/control/CouponFormControl.d.ts.map +1 -1
- package/dist/sales/coupon/control/CouponFormControl.js +21 -0
- package/dist/setting/dashboard/DashboardSettingForm.d.ts.map +1 -1
- package/dist/setting/dashboard/DashboardSettingForm.js +4 -1
- package/dist/setting/dashboard/payments/payments-modal/PaymentsModal.d.ts.map +1 -1
- package/dist/snippet/snippet-template/preview/Preview.d.ts.map +1 -1
- package/dist/snippet/snippet-template/preview/Preview.js +20 -14
- package/dist/static/CurrencyNumberInput.d.ts.map +1 -1
- package/dist/static/CurrencyNumberInput.js +3 -0
- package/dist/static/form-number-input/FormNumberInput.d.ts.map +1 -1
- package/dist/static/form-number-input/FormNumberInput.js +3 -0
- package/dist/static/number-input/NumberInput.d.ts.map +1 -1
- package/dist/static/number-input/NumberInput.js +3 -0
- package/dist/styles/iframe-events/Calendar.scss +1 -1
- package/dist/styles/iframe-external-modal/IframeExternalModal.scss +2 -2
- package/dist/styles/ryft-payment-form/RyftPaymentForm.scss +1 -3
- package/dist/styles/sales/BookingResults.scss +1 -1
- package/dist/zone/form/components/GameDurationControl.d.ts.map +1 -1
- package/dist/zone/form/components/GameDurationControl.js +3 -0
- package/dist/zone/form/components/SortControl.d.ts.map +1 -1
- package/dist/zone/form/components/SortControl.js +3 -0
- package/package.json +8 -8
- package/src/auth/Layout/UserNavDropDownToggle.tsx +1 -1
- package/src/auth/Login/LoginComponent.tsx +1 -1
- package/src/events/edit-event-modal/IntervalInput.tsx +4 -0
- package/src/events/edit-event-modal/component/SaleDeadline/SaleDeadline.tsx +12 -4
- package/src/events/edit-event-modal/utils/getDefaultProductSet.ts +0 -1
- package/src/events/edit-recurrent-event-modal/EditRecurrentEventModal.tsx +0 -1
- package/src/events/event-card/EventCard.tsx +10 -8
- package/src/events/event-statistic-modal/EventStatisticModal.tsx +3 -2
- package/src/events/event-statistic-modal/hooks/useTableData.tsx +2 -1
- package/src/events/event-statistic-modal/utils/index.ts +4 -4
- package/src/events/event-venue-map/EventVenueMap.tsx +1 -0
- package/src/events/event-venue-map/hooks/useCanvasSize.ts +5 -1
- package/src/iframe/ProductWithModifierModal/ModifierSetModal/controll/ModifierSetControll.tsx +1 -5
- package/src/iframe/order-process/components/BookingSummary/utils/index.ts +2 -2
- package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +9 -0
- package/src/iframe/payment/order-items-table/hooks/useTableData.tsx +109 -103
- package/src/iframe/payment/payment-page/PaymentPage.tsx +6 -6
- package/src/iframe/ryft/RyftPaymentForm.tsx +25 -58
- package/src/iframe/ryft/utils/ryft-form.ts +6 -5
- package/src/modals/dialog/Dialog.tsx +36 -35
- package/src/notification/email-template/card/EmailTemplateCard.tsx +2 -0
- package/src/notification/email-template/control/EmailTemplateControl.tsx +9 -10
- package/src/notification/email-template/form/EmailTemplateForm.tsx +0 -3
- package/src/product-set/control/ProductSetControl.tsx +1 -1
- package/src/product-set/form/ProductSetForm.tsx +6 -2
- package/src/product-set/product/booking-management/ProductBookingManagementControl.tsx +2 -0
- package/src/product-set/product/deposit/ProductDepositControl.tsx +1 -0
- package/src/product-set/product/duration/ProductDurationControl.tsx +2 -0
- package/src/product-set/product/price/ProductPriceControl.tsx +1 -0
- package/src/product-set/product/quantity/ProductQuantityConstantControl.tsx +2 -0
- package/src/product-set/product/quantity/ProductQuantityControl.tsx +2 -0
- package/src/product-set/product/quantity/ProductQuantityRechargingControl.tsx +1 -0
- package/src/product-set/product-category/ProductCategoryControl.tsx +4 -0
- package/src/recurrence-input/RecurrenceEndInput.tsx +1 -0
- package/src/recurrence-input/RecurrenceInput.tsx +3 -4
- package/src/recurring-date-picker-input/RecurrenceEndInput.tsx +1 -0
- package/src/resource/form/components/CapacityControl.tsx +1 -0
- package/src/resource/form/components/SortControl.tsx +1 -0
- package/src/sales/coupon/control/CouponFormControl.tsx +7 -0
- package/src/setting/dashboard/DashboardSettingForm.tsx +1 -0
- package/src/setting/dashboard/payments/payments-modal/PaymentsModal.tsx +0 -1
- package/src/snippet/snippet-template/preview/Preview.tsx +9 -6
- package/src/static/CurrencyNumberInput.tsx +1 -0
- package/src/static/form-number-input/FormNumberInput.tsx +1 -0
- package/src/static/number-input/NumberInput.tsx +1 -0
- package/src/styles/iframe-events/Calendar.scss +1 -1
- package/src/styles/iframe-external-modal/IframeExternalModal.scss +2 -2
- package/src/styles/ryft-payment-form/RyftPaymentForm.scss +1 -3
- package/src/styles/sales/BookingResults.scss +1 -1
- package/src/zone/form/components/GameDurationControl.tsx +1 -0
- package/src/zone/form/components/SortControl.tsx +1 -0
- package/yarn.lock +575 -528
- package/dist/CustomDatePicker/CustomDatePicker.d.ts +0 -10
- package/dist/CustomDatePicker/CustomDatePicker.d.ts.map +0 -1
- package/src/CustomDatePicker/CustomDatePicker.tsx +0 -252
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
type CustomDatePickerProps = {
|
|
2
|
-
name: string;
|
|
3
|
-
error?: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
showAge?: boolean;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export declare function CustomDatePicker({ name, error, showAge, required }: CustomDatePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
-
export {};
|
|
10
|
-
//# sourceMappingURL=CustomDatePicker.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CustomDatePicker.d.ts","sourceRoot":"","sources":["../../src/CustomDatePicker/CustomDatePicker.tsx"],"names":[],"mappings":"AAMA,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,KAAK,EACL,OAAc,EACd,QAAe,EAChB,EAAE,qBAAqB,2CAwOvB"}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { TextInput } from '@mantine/core'
|
|
2
|
-
import { useEffect, useState } from 'react'
|
|
3
|
-
import { Controller, useFormContext } from 'react-hook-form'
|
|
4
|
-
import { DateTime } from 'luxon'
|
|
5
|
-
import { useTranslation } from 'react-i18next'
|
|
6
|
-
|
|
7
|
-
type CustomDatePickerProps = {
|
|
8
|
-
name: string
|
|
9
|
-
error?: string
|
|
10
|
-
label?: string
|
|
11
|
-
showAge?: boolean
|
|
12
|
-
required?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function CustomDatePicker({
|
|
16
|
-
name,
|
|
17
|
-
error,
|
|
18
|
-
showAge = true,
|
|
19
|
-
required = true
|
|
20
|
-
}: CustomDatePickerProps) {
|
|
21
|
-
const { t } = useTranslation()
|
|
22
|
-
const { control, setValue, watch, getValues, trigger, formState } = useFormContext()
|
|
23
|
-
const [age, setAge] = useState<number | null>(null)
|
|
24
|
-
const [localError, setLocalError] = useState<string | null>(null)
|
|
25
|
-
|
|
26
|
-
// Get current field values
|
|
27
|
-
const day = watch(`${name}_day`) || ''
|
|
28
|
-
const month = watch(`${name}_month`) || ''
|
|
29
|
-
const year = watch(`${name}_year`) || ''
|
|
30
|
-
|
|
31
|
-
// Initialize values from existing date
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
const existingDate = getValues(name)
|
|
34
|
-
|
|
35
|
-
if (existingDate instanceof Date && !day && !month && !year) {
|
|
36
|
-
const dateTime = DateTime.fromJSDate(existingDate)
|
|
37
|
-
if (dateTime.isValid) {
|
|
38
|
-
setValue(`${name}_day`, dateTime.day.toString().padStart(2, '0'))
|
|
39
|
-
setValue(`${name}_month`, dateTime.month.toString().padStart(2, '0'))
|
|
40
|
-
setValue(`${name}_year`, dateTime.year.toString())
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}, [name, setValue, getValues, day, month, year])
|
|
44
|
-
|
|
45
|
-
// Check for empty fields after submit attempt
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (formState.isSubmitted && required) {
|
|
48
|
-
const hasEmptyFields = !day || !month || !year
|
|
49
|
-
|
|
50
|
-
if (hasEmptyFields) {
|
|
51
|
-
setLocalError(t('Validation:fieldRequired', { attribute: t('App:dateOfBirth') }))
|
|
52
|
-
// Set the main field to null to trigger form validation
|
|
53
|
-
setValue(name, null, { shouldValidate: true })
|
|
54
|
-
} else {
|
|
55
|
-
setLocalError(null)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, [formState.isSubmitted, day, month, year, required, name, setValue, t])
|
|
59
|
-
|
|
60
|
-
// Calculate age and validate date when all fields are filled
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (day && month && year) {
|
|
63
|
-
try {
|
|
64
|
-
// Create a date object
|
|
65
|
-
const dateObj = DateTime.fromObject({
|
|
66
|
-
day: parseInt(day, 10),
|
|
67
|
-
month: parseInt(month, 10),
|
|
68
|
-
year: parseInt(year, 10)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
// Only proceed if date is valid
|
|
72
|
-
if (dateObj.isValid) {
|
|
73
|
-
// Set the main field value
|
|
74
|
-
setValue(name, dateObj.toJSDate(), { shouldValidate: true })
|
|
75
|
-
setLocalError(null)
|
|
76
|
-
|
|
77
|
-
// Calculate age
|
|
78
|
-
if (showAge) {
|
|
79
|
-
const now = DateTime.now()
|
|
80
|
-
const diff = now.diff(dateObj, 'years')
|
|
81
|
-
setAge(Math.floor(diff.years))
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
setLocalError(t('Validation:fieldInvalid', { attribute: t('App:dateOfBirth') }))
|
|
85
|
-
setValue(name, null, { shouldValidate: true })
|
|
86
|
-
setAge(null)
|
|
87
|
-
}
|
|
88
|
-
} catch (err) {
|
|
89
|
-
// If any parsing fails, just reset the age display
|
|
90
|
-
setLocalError(t('Validation:fieldInvalid', { attribute: t('App:dateOfBirth') }))
|
|
91
|
-
setValue(name, null, { shouldValidate: true })
|
|
92
|
-
setAge(null)
|
|
93
|
-
}
|
|
94
|
-
} else if (formState.isSubmitted && required) {
|
|
95
|
-
// If form was submitted and fields are required but not all filled
|
|
96
|
-
setLocalError(t('Validation:fieldRequired', { attribute: t('App:dateOfBirth') }))
|
|
97
|
-
setValue(name, null, { shouldValidate: true })
|
|
98
|
-
setAge(null)
|
|
99
|
-
} else {
|
|
100
|
-
// Reset if not all fields are filled but not submitted yet
|
|
101
|
-
setValue(name, null, { shouldValidate: false })
|
|
102
|
-
setAge(null)
|
|
103
|
-
}
|
|
104
|
-
}, [day, month, year, name, setValue, showAge, formState.isSubmitted, required, t])
|
|
105
|
-
|
|
106
|
-
// After user completes all fields, validate the form
|
|
107
|
-
useEffect(() => {
|
|
108
|
-
if (day && month && year) {
|
|
109
|
-
trigger(name)
|
|
110
|
-
}
|
|
111
|
-
}, [day, month, year, name, trigger])
|
|
112
|
-
|
|
113
|
-
// Display either the form error or our local error
|
|
114
|
-
const displayError = error || localError
|
|
115
|
-
|
|
116
|
-
return (
|
|
117
|
-
<div className="tw-w-full">
|
|
118
|
-
<div className="tw-flex tw-flex-col">
|
|
119
|
-
<div className="tw-mb-2 tw-flex tw-items-center tw-justify-between">
|
|
120
|
-
<label className="tw-font-semibold">
|
|
121
|
-
{t('App:dateOfBirth')}
|
|
122
|
-
{required && <span className="tw-ml-1 tw-text-red-500"></span>}
|
|
123
|
-
</label>
|
|
124
|
-
{age !== null && (
|
|
125
|
-
<span className="tw-text-sm tw-text-gray-600">
|
|
126
|
-
{t('App:Age')}: {age}
|
|
127
|
-
</span>
|
|
128
|
-
)}
|
|
129
|
-
</div>
|
|
130
|
-
|
|
131
|
-
<div className="tw-flex tw-flex-row tw-gap-4">
|
|
132
|
-
<div className="tw-w-1/3">
|
|
133
|
-
<label className="tw-mb-1 tw-block tw-text-sm">{t('App:Day')}</label>
|
|
134
|
-
<Controller
|
|
135
|
-
control={control}
|
|
136
|
-
name={`${name}_day`}
|
|
137
|
-
defaultValue=""
|
|
138
|
-
render={({ field }) => (
|
|
139
|
-
<TextInput
|
|
140
|
-
{...field}
|
|
141
|
-
value={field.value || ''}
|
|
142
|
-
placeholder="DD"
|
|
143
|
-
maxLength={2}
|
|
144
|
-
error={!!displayError}
|
|
145
|
-
onChange={(e) => {
|
|
146
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
147
|
-
field.onChange(value)
|
|
148
|
-
}}
|
|
149
|
-
onBlur={(e) => {
|
|
150
|
-
// Validate and format on blur
|
|
151
|
-
let value = e.target.value.replace(/[^0-9]/g, '')
|
|
152
|
-
if (value) {
|
|
153
|
-
const num = parseInt(value, 10)
|
|
154
|
-
if (num < 1) value = '01'
|
|
155
|
-
else if (num > 31) value = '31'
|
|
156
|
-
else value = num.toString().padStart(2, '0')
|
|
157
|
-
}
|
|
158
|
-
field.onChange(value)
|
|
159
|
-
}}
|
|
160
|
-
/>
|
|
161
|
-
)}
|
|
162
|
-
/>
|
|
163
|
-
</div>
|
|
164
|
-
|
|
165
|
-
<div className="tw-w-1/3">
|
|
166
|
-
<label className="tw-mb-1 tw-block tw-text-sm">{t('App:Month')}</label>
|
|
167
|
-
<Controller
|
|
168
|
-
control={control}
|
|
169
|
-
name={`${name}_month`}
|
|
170
|
-
defaultValue=""
|
|
171
|
-
render={({ field }) => (
|
|
172
|
-
<TextInput
|
|
173
|
-
{...field}
|
|
174
|
-
value={field.value || ''}
|
|
175
|
-
placeholder="MM"
|
|
176
|
-
maxLength={2}
|
|
177
|
-
error={!!displayError}
|
|
178
|
-
onChange={(e) => {
|
|
179
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
180
|
-
field.onChange(value)
|
|
181
|
-
}}
|
|
182
|
-
onBlur={(e) => {
|
|
183
|
-
// Validate and format on blur
|
|
184
|
-
let value = e.target.value.replace(/[^0-9]/g, '')
|
|
185
|
-
if (value) {
|
|
186
|
-
const num = parseInt(value, 10)
|
|
187
|
-
if (num < 1) value = '01'
|
|
188
|
-
else if (num > 12) value = '12'
|
|
189
|
-
else value = num.toString().padStart(2, '0')
|
|
190
|
-
}
|
|
191
|
-
field.onChange(value)
|
|
192
|
-
}}
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
195
|
-
/>
|
|
196
|
-
</div>
|
|
197
|
-
|
|
198
|
-
<div className="tw-w-1/3">
|
|
199
|
-
<label className="tw-mb-1 tw-block tw-text-sm">{t('App:Year')}</label>
|
|
200
|
-
<Controller
|
|
201
|
-
control={control}
|
|
202
|
-
name={`${name}_year`}
|
|
203
|
-
defaultValue=""
|
|
204
|
-
render={({ field }) => (
|
|
205
|
-
<TextInput
|
|
206
|
-
{...field}
|
|
207
|
-
value={field.value || ''}
|
|
208
|
-
placeholder="YYYY"
|
|
209
|
-
maxLength={4}
|
|
210
|
-
error={!!displayError}
|
|
211
|
-
onChange={(e) => {
|
|
212
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
213
|
-
field.onChange(value)
|
|
214
|
-
}}
|
|
215
|
-
onBlur={(e) => {
|
|
216
|
-
// Validate on blur
|
|
217
|
-
const value = e.target.value.replace(/[^0-9]/g, '')
|
|
218
|
-
if (value) {
|
|
219
|
-
const num = parseInt(value, 10)
|
|
220
|
-
const currentYear = new Date().getFullYear()
|
|
221
|
-
if (num > currentYear) {
|
|
222
|
-
field.onChange(currentYear.toString())
|
|
223
|
-
} else if (num < 1900) {
|
|
224
|
-
field.onChange('1900')
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}}
|
|
228
|
-
/>
|
|
229
|
-
)}
|
|
230
|
-
/>
|
|
231
|
-
</div>
|
|
232
|
-
</div>
|
|
233
|
-
</div>
|
|
234
|
-
|
|
235
|
-
{/* Hidden field to store the actual date value */}
|
|
236
|
-
<Controller
|
|
237
|
-
control={control}
|
|
238
|
-
name={name}
|
|
239
|
-
defaultValue={null}
|
|
240
|
-
rules={{
|
|
241
|
-
validate: value => {
|
|
242
|
-
if (required && !value) {
|
|
243
|
-
return t('Validation:fieldRequired', { attribute: t('App:dateOfBirth') })
|
|
244
|
-
}
|
|
245
|
-
return true
|
|
246
|
-
}
|
|
247
|
-
}}
|
|
248
|
-
render={() => <input type="hidden" />}
|
|
249
|
-
/>
|
|
250
|
-
</div>
|
|
251
|
-
)
|
|
252
|
-
}
|