- fixed issue with sending poper date of birth during registration;
This commit is contained in:
@@ -21,10 +21,12 @@ import { Button } from 'primereact/button';
|
||||
import { Messages } from 'primereact/messages';
|
||||
import { Panel } from 'primereact/panel';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import getDateFromISOstring from '../../helpers/getDateFromISOstring';
|
||||
|
||||
const Registration = () => {
|
||||
const token = useStore().main.token();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [originalDateOfBirth, setOriginalDateOfBirth] = useState('')
|
||||
const [visibleTerms, setVisibleTerms] = useState(false);
|
||||
const errorMsgs = useRef(null);
|
||||
let [searchParams] = useSearchParams();
|
||||
@@ -43,8 +45,12 @@ const Registration = () => {
|
||||
errorMsgs.current.clear();
|
||||
const temp_token = searchParams.get('temp_token');
|
||||
setLoading(true);
|
||||
const newFormData = {
|
||||
...formData,
|
||||
dateOfBirth: originalDateOfBirth
|
||||
}
|
||||
|
||||
AuthenticationService.registerUser(formData, regCallback, regError, [
|
||||
AuthenticationService.registerUser(newFormData, regCallback, regError, [
|
||||
['tempToken', temp_token]
|
||||
]);
|
||||
};
|
||||
@@ -59,7 +65,7 @@ const Registration = () => {
|
||||
errorMsgs.current.show([
|
||||
{
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: data.data.join(', '),
|
||||
detail: data.data.message,
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
@@ -81,11 +87,11 @@ const Registration = () => {
|
||||
const validateCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const { codiceFiscale, firstName, lastName, dateOfBirth } = data.data;
|
||||
const dateOfBirthObj = new Date(dateOfBirth);
|
||||
setOriginalDateOfBirth(dateOfBirth);
|
||||
setValue('codiceFiscale', codiceFiscale);
|
||||
setValue('firstName', firstName);
|
||||
setValue('lastName', lastName);
|
||||
setValue('birthDate', dateOfBirthObj);
|
||||
setValue('dateOfBirth', getDateFromISOstring(dateOfBirth));
|
||||
} else {
|
||||
errorMsgs.current.show([
|
||||
{
|
||||
@@ -102,7 +108,7 @@ const Registration = () => {
|
||||
errorMsgs.current.show([
|
||||
{
|
||||
sticky: true, severity: 'error', summary: '',
|
||||
detail: sprintf(__('%s', 'gepafin'), err),
|
||||
detail: sprintf(__('%s', 'gepafin'), err.message),
|
||||
closable: true
|
||||
}
|
||||
]);
|
||||
@@ -197,9 +203,9 @@ const Registration = () => {
|
||||
/>
|
||||
|
||||
<FormField
|
||||
type="datepicker"
|
||||
type="textinput"
|
||||
disabled={true}
|
||||
fieldName="birthDate"
|
||||
fieldName="dateOfBirth"
|
||||
label={__('Data di nascita', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
@@ -232,7 +238,7 @@ const Registration = () => {
|
||||
errors={errors}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
positive: v => parseInt(v) > 0
|
||||
pattern: /^[\d]{5,12}$/
|
||||
}}
|
||||
placeholder=""
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user