Unverified Commit b5108b4f authored by MuLingQwQ's avatar MuLingQwQ Committed by GitHub

fix(web): calendar navigation should use current page path (#5605)

parent b623162d
import { useCallback } from "react";
import { useNavigate } from "react-router-dom";
import { useLocation, useNavigate } from "react-router-dom";
import { stringifyFilters } from "@/contexts/MemoFilterContext";
export const useDateFilterNavigation = () => {
export const useDateFilterNavigation = (targetPath?: string) => {
const navigate = useNavigate();
const location = useLocation();
const navigateToDateFilter = useCallback(
(date: string) => {
const filterQuery = stringifyFilters([{ factor: "displayTime", value: date }]);
navigate(`/?filter=${filterQuery}`);
const basePath = targetPath ?? location.pathname;
navigate(`${basePath}?filter=${filterQuery}`);
},
[navigate],
[navigate, location.pathname, targetPath],
);
return navigateToDateFilter;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment