diff --git a/src/components/albums/potential-albums/PotentialAlbumsDates.tsx b/src/components/albums/potential-albums/PotentialAlbumsDates.tsx index 03a428c..31c537e 100644 --- a/src/components/albums/potential-albums/PotentialAlbumsDates.tsx +++ b/src/components/albums/potential-albums/PotentialAlbumsDates.tsx @@ -5,8 +5,10 @@ import { import React, { use, useEffect, useState } from "react"; import PotentialDateItem from "./PotentialDateItem"; import { usePotentialAlbumContext } from "@/contexts/PotentialAlbumContext"; +import { useRouter } from "next/router"; export default function PotentialAlbumsDates() { + const router = useRouter(); const { updateContext } = usePotentialAlbumContext(); const [dateRecords, setDateRecords] = React.useState< IPotentialAlbumsDatesResponse[] @@ -25,6 +27,11 @@ export default function PotentialAlbumsDates() { const handleSelect = (date: string) => { updateContext({ startDate: date }); + router.push({ + pathname: router.pathname, + query: { startDate: date }, + }) + }; useEffect(() => { diff --git a/src/components/assets/missing-location/MissingLocationDates.tsx b/src/components/assets/missing-location/MissingLocationDates.tsx index 8af86ec..41f6216 100644 --- a/src/components/assets/missing-location/MissingLocationDates.tsx +++ b/src/components/assets/missing-location/MissingLocationDates.tsx @@ -3,13 +3,14 @@ import { usePotentialAlbumContext } from "@/contexts/PotentialAlbumContext"; import { IMissingLocationDatesResponse, listMissingLocationDates } from "@/handlers/api/asset.handler"; import MissingLocationDateItem from "./MissingLocationDateItem"; import { useMissingLocationContext } from "@/contexts/MissingLocationContext"; +import { useRouter } from "next/router"; export default function MissingLocationDates() { const { updateContext } = useMissingLocationContext(); + const router = useRouter(); const [dateRecords, setDateRecords] = React.useState< IMissingLocationDatesResponse[] >([]); - const [loading, setLoading] = useState(false); const [errorMessage, setErrorMessage] = useState(null); @@ -23,6 +24,10 @@ export default function MissingLocationDates() { const handleSelect = (date: string) => { updateContext({ startDate: date }); + router.push({ + pathname: router.pathname, + query: { startDate: date }, + }); }; useEffect(() => { diff --git a/src/pages/albums/potential-albums.tsx b/src/pages/albums/potential-albums.tsx index 8e5ef26..b7aa580 100644 --- a/src/pages/albums/potential-albums.tsx +++ b/src/pages/albums/potential-albums.tsx @@ -13,14 +13,17 @@ import PotentialAlbumContext, { } from "@/contexts/PotentialAlbumContext"; import { addAssetToAlbum, createAlbum } from "@/handlers/api/album.handler"; import { IAlbum, IAlbumCreate } from "@/types/album"; +import { useRouter } from "next/router"; import React from "react"; export default function PotentialAlbums() { const { toast } = useToast(); const { id } = useCurrentUser(); + const { query } = useRouter(); + const { startDate } = query as { startDate: string }; const [config, setConfig] = React.useState({ - startDate: undefined, + startDate: startDate || undefined, selectedIds: [], assets: [], }); @@ -62,6 +65,7 @@ export default function PotentialAlbums() { }] }) } + return (
{config.selectedIds.length} Selected - {config.selectedIds.length === config.assets.length ? ( + {config.selectedIds.length && config.selectedIds.length === config.assets.length ? (