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