TP-42454 | fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { View } from 'react-native';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import Text from '../../../../RN-UI-LIB/src/components/Text';
|
||||
import { GenericStyles } from '../../../../RN-UI-LIB/src/styles';
|
||||
import { useAppSelector } from '../../../hooks';
|
||||
@@ -12,7 +12,6 @@ import { CLICKSTREAM_EVENT_NAMES } from '../../../common/Constants';
|
||||
import { AnswerType } from '../interface';
|
||||
import WebBasedDatePicker from '../../../../RN-UI-LIB/src/components/WebBasedDatePicker';
|
||||
import {
|
||||
BUSINESS_DATE_FORMAT,
|
||||
CUSTOM_ISO_DATE_FORMAT,
|
||||
DefaultPickerModeVisibleFormatMapping,
|
||||
IDateTimePickerMode,
|
||||
@@ -68,6 +67,16 @@ const DateInput: React.FC<IDateInput> = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const maxDate = useMemo(() => {
|
||||
if (question.metadata.validators?.[Validators.MAX_DATE]?.value === DateValue.END_OF_MONTH) {
|
||||
return new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).toString();
|
||||
}
|
||||
if (question.metadata.validators?.[Validators.MAX_TODAY]?.value) {
|
||||
return new Date().toString();
|
||||
}
|
||||
return '';
|
||||
}, [question]);
|
||||
|
||||
return (
|
||||
<View style={[GenericStyles.mt12]}>
|
||||
<Text dark bold>
|
||||
@@ -114,14 +123,7 @@ const DateInput: React.FC<IDateInput> = (props) => {
|
||||
type="date"
|
||||
onChange={(text) => handleChange(text, onChange)}
|
||||
outputFormat="DD-MM-YYYY"
|
||||
max={
|
||||
question.metadata.validators?.[Validators.MAX_DATE]?.value ===
|
||||
DateValue.END_OF_MONTH
|
||||
? new Date(new Date().getFullYear(), new Date().getMonth() + 1, 0).toString()
|
||||
: question.metadata.validators?.[Validators.MAX_TODAY]?.value
|
||||
? new Date().toString()
|
||||
: ''
|
||||
}
|
||||
max={maxDate}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user