Skip to content

Commit

Permalink
fix(backoffice-v2): reverted default logic for from and to (#2973)
Browse files Browse the repository at this point in the history
  • Loading branch information
Omri-Levy authored Jan 19, 2025
1 parent 703eda6 commit f82535c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ import {
import { useLocation } from 'react-router-dom';
import { MERCHANT_MONITORING_QUERY_PARAMS_KEY } from '@/pages/MerchantMonitoring/constants';

const useDefaultDateRange = () => {
const [{ from, to }, setSearchParams] = useZodSearchParams(MerchantMonitoringSearchSchema);

useEffect(() => {
if (from || to) {
return;
}

setSearchParams({
from: dayjs().subtract(30, 'day').format('YYYY-MM-DD'),
to: dayjs().format('YYYY-MM-DD'),
});
}, []);
};

export const useMerchantMonitoringLogic = () => {
const locale = useLocale();
const { data: customer } = useCustomerQuery();
Expand Down Expand Up @@ -164,6 +179,8 @@ export const useMerchantMonitoringLogic = () => {
[findingsOptions],
);

useDefaultDateRange();

return {
totalPages: data?.totalPages || 0,
totalItems: Intl.NumberFormat(locale).format(data?.totalItems || 0),
Expand Down
4 changes: 2 additions & 2 deletions apps/backoffice-v2/src/pages/MerchantMonitoring/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,6 @@ export const MerchantMonitoringSearchSchema = BaseSearchSchema.extend({
],
)
.catch('All'),
from: z.string().date().catch(dayjs().subtract(30, 'day').format('YYYY-MM-DD')),
to: z.string().date().catch(dayjs().format('YYYY-MM-DD')),
from: z.string().date().optional(),
to: z.string().date().optional(),
});

0 comments on commit f82535c

Please sign in to comment.