@adyen/adyen-platform-experience-web
Version:

26 lines (25 loc) • 1.19 kB
JavaScript
import { useState as m, useRef as f, useCallback as u, useEffect as l } from "../external/preact/hooks/dist/hooks.module.js";
import { FilterParam as e } from "../components/types.js";
import { getTimeRangeSelectionDefaultPresetOptions as T } from "../components/internal/DatePicker/components/TimeRangeSelector/useTimeRangeSelection.js";
import { DEFAULT_TRANSACTIONS_OVERVIEW_MULTI_SELECTION_FILTER_PARAMS as c } from "../components/external/TransactionsOverview/components/MultiSelectionFilter/useMultiSelectionFilter/constants.js";
const A = (r) => {
const t = T(), a = "rangePreset.last30Days", { from: s, to: n } = t[a];
return { defaultFilterParams: {
...r === "transactions" && {
...c,
[e.MIN_AMOUNT]: void 0,
[e.MAX_AMOUNT]: void 0
},
[e.BALANCE_ACCOUNT]: void 0,
[e.CREATED_SINCE]: new Date(s).toISOString(),
[e.CREATED_UNTIL]: new Date(n).toISOString()
}, defaultTimeRange: a, timeRangeOptions: t };
}, D = (r, t) => {
const [a, s] = m(Date.now()), n = A(r), i = f(n), o = u(() => s(Date.now()), [s]);
return l(() => {
o();
}, [t, o]), { defaultParams: i, nowTimestamp: a, refreshNowTimestamp: o };
};
export {
D as default
};