From 6f6d60746bca6c5cd27825024fc61e0a6c4e7920 Mon Sep 17 00:00:00 2001 From: "av.maiorov" Date: Thu, 22 Dec 2022 14:56:29 +0500 Subject: [PATCH] =?UTF-8?q?=20=D0=A3=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B?= =?UTF-8?q?=D0=BC=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC?= =?UTF-8?q?=20=D1=81=D0=B5=D0=BB=D0=B5=D0=BA=D1=82=D0=BE=D1=80=D0=B0=20?= =?UTF-8?q?=D0=B4=D0=B0=D1=82=20=D0=BF=D1=80=D0=B5=D0=B4=D1=8B=D0=B4=D1=83?= =?UTF-8?q?=D1=89=D0=B8=D0=B5=20=D1=81=D1=83=D1=82=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Table/DateRangeWrapper.tsx | 35 +++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/components/Table/DateRangeWrapper.tsx b/src/components/Table/DateRangeWrapper.tsx index c9246c5..79d1f9c 100755 --- a/src/components/Table/DateRangeWrapper.tsx +++ b/src/components/Table/DateRangeWrapper.tsx @@ -1,4 +1,4 @@ -import { memo } from 'react' +import { memo, useMemo } from 'react' import { DatePicker, } from 'antd' import moment, { Moment } from 'moment' import { RangeValue } from 'rc-picker/lib/interface' @@ -20,7 +20,7 @@ export type DateRangeWrapperProps = RangePickerSharedProps & { /** * Подготавливает значения к передаче в селектор * - * @param value Массиз из 2 дат + * @param value Массив из 2 дат * @param isUTC Конвертировать ли значения в UTC * @returns Подготовленные даты */ @@ -32,18 +32,23 @@ const normalizeDates = (value?: RangeValue, isUTC?: boolean): RangeValue ] } -export const DateRangeWrapper = memo(({ value, isUTC, allowClear, ...other }) => ( - -)) +export const DateRangeWrapper = memo(({ value, isUTC, allowClear, ...other }) => { + const normalizeValue: RangeValue = useMemo(() => normalizeDates(value, isUTC), [value, isUTC]) + + const defaultValue: RangeValue = useMemo(() => normalizeDates([ + moment().subtract(1, 'days').startOf('day'), + moment().startOf('day'), + ], isUTC), [value, isUTC]) + + return ( + + ) +}) export default DateRangeWrapper