From 9bbb2a15c398bc6c38a832ea867af031f36ef4b3 Mon Sep 17 00:00:00 2001 From: z0al <12673605+z0al@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:29:50 +0000 Subject: [PATCH] feat(date): allow arbitrary date range [ZEND-5700] (#1806) --- packages/date/src/DatepickerInput.tsx | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/packages/date/src/DatepickerInput.tsx b/packages/date/src/DatepickerInput.tsx index f9a4692f5..398dcd05f 100644 --- a/packages/date/src/DatepickerInput.tsx +++ b/packages/date/src/DatepickerInput.tsx @@ -1,12 +1,10 @@ -import React, { useMemo } from 'react'; +import React from 'react'; import { Datepicker } from '@contentful/f36-components'; import { css } from 'emotion'; // eslint-disable-next-line -- TODO: move to date-fns import moment from 'moment'; -const YEAR_RANGE = 100; - const styles = { root: css({ maxWidth: '270px', @@ -20,15 +18,6 @@ export type DatePickerProps = { }; export const DatepickerInput = (props: DatePickerProps) => { - const [fromDate, toDate] = useMemo(() => { - const fromDate = new Date(); - fromDate.setFullYear(fromDate.getFullYear() - YEAR_RANGE); - const toDate = new Date(); - toDate.setFullYear(toDate.getFullYear() + YEAR_RANGE); - - return [fromDate, toDate]; - }, []); - // The DatepickerInput should be time and timezone agnostic, // thats why we don't use moment().toDate() to get Date object. // moment().toDate() takes into account time and timezone and converts it @@ -47,8 +36,6 @@ export const DatepickerInput = (props: DatePickerProps) => { props.onChange(momentDay); }} inputProps={{ isDisabled: props.disabled, placeholder: '' }} - fromDate={fromDate} - toDate={toDate} /> ); };