Passed
Pull Request — main (#350)
by Alejandro
21:55
created

src/utils/dates/DateRangeRow.tsx   A

Complexity

Total Complexity 4
Complexity/F 0

Size

Lines of Code 40
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 35
mnd 4
bc 4
fnc 0
dl 0
loc 40
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
import moment from 'moment';
2
import DateInput from '../DateInput';
3
import { DateRange } from './types';
4
5
interface DateRangeRowProps extends DateRange {
6
  onStartDateChange: (date: moment.Moment | null) => void;
7
  onEndDateChange: (date: moment.Moment | null) => void;
8
  disabled?: boolean;
9
}
10
11
const DateRangeRow = (
12
  { startDate = null, endDate = null, disabled = false, onStartDateChange, onEndDateChange }: DateRangeRowProps,
13
) => (
14
  <div className="row">
15
    <div className="col-md-6">
16
      <DateInput
17
        selected={startDate}
18
        placeholderText="Since..."
19
        isClearable
20
        maxDate={endDate ?? undefined}
21
        disabled={disabled}
22
        onChange={onStartDateChange}
23
      />
24
    </div>
25
    <div className="col-md-6">
26
      <DateInput
27
        className="mt-2 mt-md-0"
28
        selected={endDate}
29
        placeholderText="Until..."
30
        isClearable
31
        minDate={startDate ?? undefined}
32
        disabled={disabled}
33
        onChange={onEndDateChange}
34
      />
35
    </div>
36
  </div>
37
);
38
39
export default DateRangeRow;
40