summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/data/project.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-07 15:07:11 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-07 15:07:11 +0200
commitaa788a3ad18badfac8beaabdaffc88b9e52f9306 (patch)
tree2046d0a401ca0853d5e85de9d6360edcb79f7ebd /opendc-web/opendc-web-ui/src/data/project.js
parent1ce8bf170cda2afab334cd330325cd4fbb97dab4 (diff)
ui: Remove current ids state from Redux
This change removes the current active identifiers from the Redux state. Instead, we use the router query to track the active project, portfolio and topology.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/data/project.js')
-rw-r--r--opendc-web/opendc-web-ui/src/data/project.js21
1 files changed, 4 insertions, 17 deletions
diff --git a/opendc-web/opendc-web-ui/src/data/project.js b/opendc-web/opendc-web-ui/src/data/project.js
index d4c95370..30b36efa 100644
--- a/opendc-web/opendc-web-ui/src/data/project.js
+++ b/opendc-web/opendc-web-ui/src/data/project.js
@@ -21,6 +21,7 @@
*/
import { useSelector } from 'react-redux'
+import { useRouter } from 'next/router'
/**
* Return the available projects.
@@ -40,23 +41,9 @@ export function useProject(projectId) {
* Return the current active project.
*/
export function useActiveProject() {
- return useSelector((state) =>
- state.currentProjectId !== '-1' ? state.objects.project[state.currentProjectId] : undefined
- )
-}
-
-/**
- * Return the active portfolio.
- */
-export function useActivePortfolio() {
- return useSelector((state) => state.objects.portfolio[state.currentPortfolioId])
-}
-
-/**
- * Return the active scenario.
- */
-export function useActiveScenario() {
- return useSelector((state) => state.objects.scenario[state.currentScenarioId])
+ const router = useRouter()
+ const { project: projectId } = router.query
+ return useSelector((state) => state.objects.project[projectId])
}
/**