From 82b61b6c589078837e9b76d8d01ab36466aff00d Mon Sep 17 00:00:00 2001 From: okorie2 Date: Mon, 9 Dec 2024 16:46:12 +0000 Subject: [PATCH] feat: persist sort by state in external data search --- .../routes/upload-module/upload-steps/externalSearch.tsx | 7 ++++--- src/app/state/recoil/atoms/index.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/app/modules/dataset-module/routes/upload-module/upload-steps/externalSearch.tsx b/src/app/modules/dataset-module/routes/upload-module/upload-steps/externalSearch.tsx index 035a8380c..1052b413a 100644 --- a/src/app/modules/dataset-module/routes/upload-module/upload-steps/externalSearch.tsx +++ b/src/app/modules/dataset-module/routes/upload-module/upload-steps/externalSearch.tsx @@ -8,8 +8,8 @@ import axios from "axios"; import CircleLoader from "app/modules/home-module/components/Loader"; import { useInfinityScroll } from "app/hooks/useInfinityScroll"; import SourceCategoryList from "app/modules/dataset-module/routes/upload-module/component/externalSourcesList"; -import { useSetRecoilState } from "recoil"; -import { planDialogAtom } from "app/state/recoil/atoms"; +import { useRecoilState, useSetRecoilState } from "recoil"; +import { externalDataSortByAtom, planDialogAtom } from "app/state/recoil/atoms"; import SaveAltIcon from "@material-ui/icons/SaveAlt"; import ExternalSearchTable from "app/modules/dataset-module/routes/upload-module/component/table/externalSearchTable"; import { useCheckUserPlan } from "app/hooks/useCheckUserPlan"; @@ -46,7 +46,8 @@ export default function ExternalSearch(props: { const observerTarget = React.useRef(null); const [view, setView] = React.useState<"grid" | "table">("grid"); - const [sortValue, setSortValue] = React.useState("name"); + // const [sortValue, setSortValue] = React.useState("name"); + const [sortValue, setSortValue] = useRecoilState(externalDataSortByAtom); const token = useStoreState((state) => state.AuthToken.value); const [loading, setLoading] = React.useState(false); const [offset, setOffset] = React.useState(0); diff --git a/src/app/state/recoil/atoms/index.ts b/src/app/state/recoil/atoms/index.ts index bb184b2f2..0abebac77 100644 --- a/src/app/state/recoil/atoms/index.ts +++ b/src/app/state/recoil/atoms/index.ts @@ -38,6 +38,14 @@ export const allAssetsSortBy = atom<"name" | "updatedDate" | "createdDate">({ effects_UNSTABLE: [persistAtom], }); +export const externalDataSortByAtom = atom< + "name" | "updatedDate" | "createdDate" +>({ + key: "externalDataSortByAtom", + default: "updatedDate", + effects_UNSTABLE: [persistAtom], +}); + export const homeDisplayAtom = atom<"all" | "data" | "charts" | "reports">({ key: "homeDisplayAtom", default: "all",