Skip to content

Commit eabd4b9

Browse files
committed
Add custom range date selector
1 parent 49ed385 commit eabd4b9

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

clients/admin-ui/src/pages/consent/reporting/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getCoreRowModel, useReactTable } from "@tanstack/react-table";
33
import dayjs, { Dayjs } from "dayjs";
44
import {
55
AntButton as Button,
6-
AntDatePicker as DatePicker,
6+
AntDateRangePicker as DateRangePicker,
77
AntDropdown as Dropdown,
88
AntEmpty as Empty,
99
AntFlex as Flex,
@@ -80,7 +80,7 @@ const ConsentReportingPage = () => {
8080
) : (
8181
<>
8282
<TableActionBar>
83-
<DatePicker.RangePicker
83+
<DateRangePicker
8484
placeholder={["From", "To"]}
8585
maxDate={today}
8686
data-testid="input-date-range"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ArrowRight, Calendar } from "@carbon/icons-react";
2+
import { RangePickerProps } from "antd/es/date-picker";
3+
import { DatePicker } from "antd/lib";
4+
import React from "react";
5+
6+
const withCustomProps = (WrappedComponent: typeof DatePicker.RangePicker) => {
7+
const WrappedSelect = ({
8+
suffixIcon = <Calendar />,
9+
separator = (
10+
<ArrowRight style={{ color: "var(--ant-color-text-disabled)" }} />
11+
),
12+
...props
13+
}: RangePickerProps) => {
14+
const customProps = {
15+
suffixIcon,
16+
separator,
17+
...props,
18+
};
19+
return <WrappedComponent {...customProps} />;
20+
};
21+
return WrappedSelect;
22+
};
23+
24+
export const CustomDateRangePicker = withCustomProps(DatePicker.RangePicker);

clients/fidesui/src/hoc/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
export * from "./CustomDateRangePicker";
12
export * from "./CustomSelect";
23
export * from "./CustomTag";

clients/fidesui/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export {
3030
Card as AntCard,
3131
Checkbox as AntCheckbox,
3232
Col as AntCol,
33-
DatePicker as AntDatePicker,
3433
Divider as AntDivider,
3534
Dropdown as AntDropdown,
3635
Empty as AntEmpty,
@@ -62,6 +61,7 @@ export type {
6261

6362
// Higher-order components
6463
export { CustomSelect as AntSelect } from "./hoc";
64+
export { CustomDateRangePicker as AntDateRangePicker } from "./hoc";
6565

6666
/**
6767
* Custom Re-exports

0 commit comments

Comments
 (0)