mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
feat(Documents Filter): Keep the URL and UI state in sync when status filter changes
This commit is contained in:
@ -83,6 +83,20 @@ const DocumentsPage: NextPageWithLayout = (props: any) => {
|
|||||||
return filteredDocuments;
|
return filteredDocuments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSetSelectedStatusFilter(status: any) {
|
||||||
|
router.replace(
|
||||||
|
{
|
||||||
|
pathname: router.pathname,
|
||||||
|
query: { filter: status.value },
|
||||||
|
},
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
shallow: true, // Perform a shallow update, without reloading the page
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setSelectedStatusFilter(status);
|
||||||
|
}
|
||||||
|
|
||||||
function wasXDaysAgoOrLess(documentDate: Date, lastXDays: number): boolean {
|
function wasXDaysAgoOrLess(documentDate: Date, lastXDays: number): boolean {
|
||||||
if (lastXDays < 0) return true;
|
if (lastXDays < 0) return true;
|
||||||
|
|
||||||
@ -138,7 +152,7 @@ const DocumentsPage: NextPageWithLayout = (props: any) => {
|
|||||||
label="Status"
|
label="Status"
|
||||||
options={statusFilters}
|
options={statusFilters}
|
||||||
value={selectedStatusFilter}
|
value={selectedStatusFilter}
|
||||||
onChange={setSelectedStatusFilter}
|
onChange={handleSetSelectedStatusFilter}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="mt-20 max-w-[1100px]" hidden={!loading}>
|
<div className="mt-20 max-w-[1100px]" hidden={!loading}>
|
||||||
|
|||||||
Reference in New Issue
Block a user