import { Gridicon, Button } from '@automattic/components'; import { useTranslate } from 'i18n-calypso'; import { FunctionComponent } from 'react'; interface Props { customTitle?: string; startDate: Date | null; endDate: Date | null; resetDates: () => void; } const DateRangeHeader: FunctionComponent< Props > = ( { customTitle, startDate, endDate, resetDates, } ) => { const translate = useTranslate(); // Add this check at the beginning of the component if ( startDate === undefined || endDate === undefined || resetDates === undefined ) { return null; // or return a loading state } const renderDateHelp = () => { return (
{ ! startDate && ! endDate && translate( '{{icon/}} Please select the {{em}}first{{/em}} day.', { components: { icon:
); }; return (
{ customTitle ? (
{ customTitle }
) : ( renderDateHelp() ) }
); }; export default DateRangeHeader;