Skip to content

Commit

Permalink
Correct get prevPage from localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
Кусак Александр authored and blake-r committed Apr 25, 2023
1 parent 13f63f1 commit 33e348f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/ExportComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,21 @@ export const mimeTypes: Record<ExporterType, string> = {
xml: 'text/xml',
};

interface prevPageData {
hash?: string,
key?: string,
pathname?: string,
search?: string,
state?: string,
}

export const getExportedFileName = (extension: string) =>
`export-${format(Date.now(), 'yyyy-MM-dd_HH-mm')}.${extension}`;

const ExportComponent: FC<ActionProps> = ({ resource }) => {
const filter: Record<string, string> = {};
const prevFilter: URLSearchParams = new URLSearchParams(JSON.parse(localStorage.getItem("prevPage") ?? "{}")?.search);
const prevPage: prevPageData = JSON.parse(localStorage.getItem("prevPage") ?? "{}");
const prevFilter: URLSearchParams = new URLSearchParams(prevPage.search);
let query = prevFilter ?? new URLSearchParams(location.search);
for (const entry of query.entries()) {
const [key, value] = entry;
Expand Down

0 comments on commit 33e348f

Please sign in to comment.