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 Кусак Александр committed Apr 24, 2023
1 parent b901ad5 commit ea53701
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 @@ -11,12 +11,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 ea53701

Please sign in to comment.