Skip to content

Commit bb16541

Browse files
Armaan GuptaArmaan Gupta
authored andcommitted
code refactoring
1 parent c4c99c4 commit bb16541

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

packages/react-vanilla-components/src/components/DateInput.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,9 @@ import { PROPS } from '../utils/type';
2323
import FieldWrapper from './common/FieldWrapper';
2424
import { syncAriaDescribedBy } from '../utils/utils';
2525

26-
// Helper function to convert date to ISO format (YYYY-MM-DD)
27-
const toISODateString = (dateValue: string | number | undefined): string | undefined => {
28-
if (dateValue === undefined || dateValue === null) {return undefined;}
29-
try {
30-
const date = new Date(dateValue);
31-
if (isNaN(date.getTime())) {return undefined;}
32-
return date.toISOString().split('T')[0];
33-
} catch {
34-
return undefined;
35-
}
36-
};
37-
3826
const DateInput = (props: PROPS) => {
3927
const { id, label, value, required, name, readOnly, placeholder, visible, enabled, appliedCssClassNames, valid, minimum, maximum } = props;
4028
const finalValue = value === undefined ? '' : value;
41-
const minDate = toISODateString(minimum);
42-
const maxDate = toISODateString(maximum);
4329

4430
const changeHandler = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
4531
const val = e.target.value;
@@ -78,8 +64,8 @@ const DateInput = (props: PROPS) => {
7864
value={finalValue}
7965
name={name}
8066
required={required}
81-
min={minDate}
82-
max={maxDate}
67+
min={minimum}
68+
max={maximum}
8369
onChange={changeHandler}
8470
className={'cmp-adaptiveform-datepicker__widget'}
8571
title={props.tooltipText || ''}

0 commit comments

Comments
 (0)