mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-01 21:26:46 +00:00
Created component for DateTimeInputs
This commit is contained in:
@@ -9,7 +9,7 @@ import './DateInput.scss';
|
||||
export type DateInputProps = ReactDatePickerProps;
|
||||
|
||||
export const DateInput = (props: DateInputProps) => {
|
||||
const { className, isClearable, selected } = props;
|
||||
const { className, isClearable, selected, dateFormat } = props;
|
||||
const showCalendarIcon = !isClearable || isNil(selected);
|
||||
const ref = useRef<{ input: HTMLInputElement }>();
|
||||
|
||||
@@ -23,7 +23,7 @@ export const DateInput = (props: DateInputProps) => {
|
||||
options: { padding: 24 }, // This prevents the arrow to be placed on the very edge, which looks ugly
|
||||
},
|
||||
]}
|
||||
dateFormat="yyyy-MM-dd"
|
||||
dateFormat={dateFormat ?? 'yyyy-MM-dd'}
|
||||
className={classNames('date-input-container__input form-control', className)}
|
||||
// @ts-expect-error The DatePicker type definition is wrong. It has a ref prop
|
||||
ref={ref}
|
||||
|
||||
14
src/utils/dates/DateTimeInput.tsx
Normal file
14
src/utils/dates/DateTimeInput.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { ReactDatePickerProps } from 'react-datepicker';
|
||||
import { FC } from 'react';
|
||||
import { DateInput } from '../DateInput';
|
||||
|
||||
export type DateTimeInputProps = Omit<ReactDatePickerProps, 'showTimeSelect' | 'dateFormat' | 'timeIntervals'>;
|
||||
|
||||
export const DateTimeInput: FC<DateTimeInputProps> = (props) => (
|
||||
<DateInput
|
||||
{...props}
|
||||
dateFormat="yyyy-MM-dd HH:mm"
|
||||
showTimeSelect
|
||||
timeIntervals={5}
|
||||
/>
|
||||
);
|
||||
Reference in New Issue
Block a user