From 33e348f7c1cbd7b5f2457aaa4801281dfd933b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D1=83=D1=81=D0=B0=D0=BA=20=D0=90=D0=BB=D0=B5=D0=BA?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=B4=D1=80?= Date: Mon, 24 Apr 2023 13:00:09 +0300 Subject: [PATCH] Correct get prevPage from localstorage --- src/components/ExportComponent.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/ExportComponent.tsx b/src/components/ExportComponent.tsx index c3f1252..ebbed2b 100644 --- a/src/components/ExportComponent.tsx +++ b/src/components/ExportComponent.tsx @@ -12,12 +12,21 @@ export const mimeTypes: Record = { 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 = ({ resource }) => { const filter: Record = {}; - 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;