Skip to content

Commit

Permalink
Merge pull request #17 from developmentseed/1238-use-derived-dataset-…
Browse files Browse the repository at this point in the history
…atom

[#1238] Use the new derived atom for dataset hydration
  • Loading branch information
dzole0311 authored Nov 25, 2024
2 parents aeb1b11 + da25739 commit 9eae23c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
29 changes: 18 additions & 11 deletions app/(datasets)/exploration/exploration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,11 @@ import {
ExplorationAndAnalysis,
DatasetSelectorModal,
useTimelineDatasetAtom,
externalDatasetsAtom,
} from 'app/lib';
import { useSetAtom } from 'jotai';

export default function ExplorationAnalysis({ datasets }: { datasets: any }) {
const [timelineDatasets, setTimelineDatasets] = useTimelineDatasetAtom();
const [datasetModalRevealed, setDatasetModalRevealed] = useState(
!timelineDatasets.length,
);

const openModal = () => {
setDatasetModalRevealed(true);
};
const closeModal = () => {
setDatasetModalRevealed(false);
};
const transformData = () => {
const data = datasets?.map((post) => ({
...post.metadata,
Expand All @@ -42,6 +33,22 @@ export default function ExplorationAnalysis({ datasets }: { datasets: any }) {

const transformed = transformData();

const setExternalDatasets = useSetAtom(externalDatasetsAtom);

setExternalDatasets(transformed);

const openModal = () => {
setDatasetModalRevealed(true);
};
const closeModal = () => {
setDatasetModalRevealed(false);
};

const [timelineDatasets, setTimelineDatasets] = useTimelineDatasetAtom();
const [datasetModalRevealed, setDatasetModalRevealed] = useState(
!timelineDatasets.length,
);

return (
<>
<DatasetSelectorModal
Expand Down
2 changes: 2 additions & 0 deletions app/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
DatasetSelectorModal,
timelineDatasetsAtom,
useTimelineDatasetAtom,
externalDatasetsAtom
} from '@developmentseed/veda-ui';

/**
Expand Down Expand Up @@ -63,6 +64,7 @@ export {
// State
timelineDatasetsAtom,
useTimelineDatasetAtom,
externalDatasetsAtom
};

export type { NavItem, InternalNavLink };
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"fix": "yarn run format && yarn run lint:fix"
},
"dependencies": {
"@developmentseed/veda-ui": "v5.10.0-env-config",
"@developmentseed/veda-ui": "v5.10.0-a",
"@devseed-ui/theme-provider": "^4.1.0",
"@tailwindcss/postcss": "4.0.0-alpha.13",
"@types/node": "20.11.17",
Expand Down

0 comments on commit 9eae23c

Please sign in to comment.