From 00238bd241b8628dc9820afc2fcd2f61452f52ef Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Mon, 28 Oct 2024 12:19:20 +0100 Subject: [PATCH] :recycle: #459 - refactor: combine hooks directories --- frontend/src/hooks/index.ts | 10 ++++++++++ .../hooks/useCombinedSearchParams.test.ts | 0 .../hooks/useCombinedSearchParams.ts | 0 .../hooks/useFields.test.ts | 4 ++-- .../destructionlist => }/hooks/useFields.ts | 12 ++++++------ .../destructionlist => }/hooks/useFilter.ts | 0 .../destructionlist => }/hooks/usePage.ts | 0 .../useSelectielijstKlasseChoices.test.ts | 2 +- .../hooks/useSelectielijstKlasseChoices.ts | 2 +- .../destructionlist => }/hooks/useSort.ts | 0 .../hooks/useZaakReviewStatusBadges.tsx | 2 +- .../hooks/useZaakReviewStatuses.tsx | 2 +- .../hooks/useZaakSelection.test.ts | 2 +- .../hooks/useZaakSelection.ts | 4 ++-- .../hooks/useZaaktypeChoices.ts | 6 +++--- .../destructionlist/abstract/BaseListView.tsx | 18 +++++++++--------- .../create/DestructionListCreate.tsx | 2 +- .../detail/hooks/useSecondaryNavigation.tsx | 3 +-- .../DestructionListProcessReviewPage.tsx | 2 +- .../src/pages/destructionlist/hooks/index.ts | 10 ---------- .../review/DestructionListReview.tsx | 3 +-- 21 files changed, 41 insertions(+), 43 deletions(-) rename frontend/src/{pages/destructionlist => }/hooks/useCombinedSearchParams.test.ts (100%) rename frontend/src/{pages/destructionlist => }/hooks/useCombinedSearchParams.ts (100%) rename frontend/src/{pages/destructionlist => }/hooks/useFields.test.ts (96%) rename frontend/src/{pages/destructionlist => }/hooks/useFields.ts (95%) rename frontend/src/{pages/destructionlist => }/hooks/useFilter.ts (100%) rename frontend/src/{pages/destructionlist => }/hooks/usePage.ts (100%) rename frontend/src/{pages/destructionlist => }/hooks/useSelectielijstKlasseChoices.test.ts (94%) rename frontend/src/{pages/destructionlist => }/hooks/useSelectielijstKlasseChoices.ts (90%) rename frontend/src/{pages/destructionlist => }/hooks/useSort.ts (100%) rename frontend/src/{pages/destructionlist => }/hooks/useZaakReviewStatusBadges.tsx (97%) rename frontend/src/{pages/destructionlist => }/hooks/useZaakReviewStatuses.tsx (97%) rename frontend/src/{pages/destructionlist => }/hooks/useZaakSelection.test.ts (98%) rename frontend/src/{pages/destructionlist => }/hooks/useZaakSelection.ts (98%) rename frontend/src/{pages/destructionlist => }/hooks/useZaaktypeChoices.ts (80%) delete mode 100644 frontend/src/pages/destructionlist/hooks/index.ts diff --git a/frontend/src/hooks/index.ts b/frontend/src/hooks/index.ts index 219afa578..7b0e36fbd 100644 --- a/frontend/src/hooks/index.ts +++ b/frontend/src/hooks/index.ts @@ -1,6 +1,16 @@ export * from "./useAuditLog"; +export * from "./useCombinedSearchParams"; +export * from "./useFields"; +export * from "./useFilter"; export * from "./useLatestReviewResponse"; +export * from "./usePage"; export * from "./usePoll"; export * from "./useReviewers"; +export * from "./useSelectielijstKlasseChoices"; +export * from "./useSort"; export * from "./useSubmitAction"; export * from "./useWhoAmI"; +export * from "./useZaakReviewStatusBadges"; +export * from "./useZaakReviewStatuses"; +export * from "./useZaakSelection"; +export * from "./useZaaktypeChoices"; diff --git a/frontend/src/pages/destructionlist/hooks/useCombinedSearchParams.test.ts b/frontend/src/hooks/useCombinedSearchParams.test.ts similarity index 100% rename from frontend/src/pages/destructionlist/hooks/useCombinedSearchParams.test.ts rename to frontend/src/hooks/useCombinedSearchParams.test.ts diff --git a/frontend/src/pages/destructionlist/hooks/useCombinedSearchParams.ts b/frontend/src/hooks/useCombinedSearchParams.ts similarity index 100% rename from frontend/src/pages/destructionlist/hooks/useCombinedSearchParams.ts rename to frontend/src/hooks/useCombinedSearchParams.ts diff --git a/frontend/src/pages/destructionlist/hooks/useFields.test.ts b/frontend/src/hooks/useFields.test.ts similarity index 96% rename from frontend/src/pages/destructionlist/hooks/useFields.test.ts rename to frontend/src/hooks/useFields.test.ts index a4590b7d8..2f088262f 100644 --- a/frontend/src/pages/destructionlist/hooks/useFields.test.ts +++ b/frontend/src/hooks/useFields.test.ts @@ -1,8 +1,8 @@ import { TypedField } from "@maykin-ui/admin-ui"; import { act, renderHook, waitFor } from "@testing-library/react"; -import { selectieLijstKlasseFactory as mockSelectieLijstKlasseFactory } from "../../../fixtures/selectieLijstKlasseChoices"; -import * as fieldSelection from "../../../lib/fieldSelection/fieldSelection"; +import { selectieLijstKlasseFactory as mockSelectieLijstKlasseFactory } from "../fixtures/selectieLijstKlasseChoices"; +import * as fieldSelection from "../lib/fieldSelection/fieldSelection"; import { useFields } from "./useFields"; jest.mock("./useSelectielijstKlasseChoices", () => ({ diff --git a/frontend/src/pages/destructionlist/hooks/useFields.ts b/frontend/src/hooks/useFields.ts similarity index 95% rename from frontend/src/pages/destructionlist/hooks/useFields.ts rename to frontend/src/hooks/useFields.ts index 58eec2c88..b0aa4b2ed 100644 --- a/frontend/src/pages/destructionlist/hooks/useFields.ts +++ b/frontend/src/hooks/useFields.ts @@ -2,17 +2,17 @@ import { AttributeData, TypedField } from "@maykin-ui/admin-ui"; import { useCallback, useEffect, useState } from "react"; import { useSearchParams } from "react-router-dom"; -import { DestructionList } from "../../../lib/api/destructionLists"; -import { Review } from "../../../lib/api/review"; +import { DestructionList } from "../lib/api/destructionLists"; +import { Review } from "../lib/api/review"; import { FieldSelection, addToFieldSelection, getFieldSelection, removeFromFieldSelection, -} from "../../../lib/fieldSelection/fieldSelection"; -import { formatDate } from "../../../lib/format/date"; -import { ExpandZaak, Zaak } from "../../../types"; -import { FIELD_SELECTION_STORAGE_KEY } from "../../constants"; +} from "../lib/fieldSelection/fieldSelection"; +import { formatDate } from "../lib/format/date"; +import { FIELD_SELECTION_STORAGE_KEY } from "../pages/constants"; +import { ExpandZaak, Zaak } from "../types"; import { useSelectielijstKlasseChoices } from "./useSelectielijstKlasseChoices"; import { useZaaktypeChoices } from "./useZaaktypeChoices"; diff --git a/frontend/src/pages/destructionlist/hooks/useFilter.ts b/frontend/src/hooks/useFilter.ts similarity index 100% rename from frontend/src/pages/destructionlist/hooks/useFilter.ts rename to frontend/src/hooks/useFilter.ts diff --git a/frontend/src/pages/destructionlist/hooks/usePage.ts b/frontend/src/hooks/usePage.ts similarity index 100% rename from frontend/src/pages/destructionlist/hooks/usePage.ts rename to frontend/src/hooks/usePage.ts diff --git a/frontend/src/pages/destructionlist/hooks/useSelectielijstKlasseChoices.test.ts b/frontend/src/hooks/useSelectielijstKlasseChoices.test.ts similarity index 94% rename from frontend/src/pages/destructionlist/hooks/useSelectielijstKlasseChoices.test.ts rename to frontend/src/hooks/useSelectielijstKlasseChoices.test.ts index 9f3f559bf..6286e3c03 100644 --- a/frontend/src/pages/destructionlist/hooks/useSelectielijstKlasseChoices.test.ts +++ b/frontend/src/hooks/useSelectielijstKlasseChoices.test.ts @@ -1,6 +1,6 @@ import { renderHook, waitFor } from "@testing-library/react"; -import { FIXTURE_SELECTIELIJSTKLASSE_CHOICES } from "../../../fixtures/selectieLijstKlasseChoices"; +import { FIXTURE_SELECTIELIJSTKLASSE_CHOICES } from "../fixtures/selectieLijstKlasseChoices"; import { useSelectielijstKlasseChoices } from "./useSelectielijstKlasseChoices"; const mockAlert = jest.fn(); diff --git a/frontend/src/pages/destructionlist/hooks/useSelectielijstKlasseChoices.ts b/frontend/src/hooks/useSelectielijstKlasseChoices.ts similarity index 90% rename from frontend/src/pages/destructionlist/hooks/useSelectielijstKlasseChoices.ts rename to frontend/src/hooks/useSelectielijstKlasseChoices.ts index c47a4cae2..16132d855 100644 --- a/frontend/src/pages/destructionlist/hooks/useSelectielijstKlasseChoices.ts +++ b/frontend/src/hooks/useSelectielijstKlasseChoices.ts @@ -1,7 +1,7 @@ import { Option, useAlert } from "@maykin-ui/admin-ui"; import { useEffect, useState } from "react"; -import { listSelectielijstKlasseChoices } from "../../../lib/api/private"; +import { listSelectielijstKlasseChoices } from "../lib/api/private"; /** * Hook resolving selectielijst choices diff --git a/frontend/src/pages/destructionlist/hooks/useSort.ts b/frontend/src/hooks/useSort.ts similarity index 100% rename from frontend/src/pages/destructionlist/hooks/useSort.ts rename to frontend/src/hooks/useSort.ts diff --git a/frontend/src/pages/destructionlist/hooks/useZaakReviewStatusBadges.tsx b/frontend/src/hooks/useZaakReviewStatusBadges.tsx similarity index 97% rename from frontend/src/pages/destructionlist/hooks/useZaakReviewStatusBadges.tsx rename to frontend/src/hooks/useZaakReviewStatusBadges.tsx index f5eff27d5..c109b23f4 100644 --- a/frontend/src/pages/destructionlist/hooks/useZaakReviewStatusBadges.tsx +++ b/frontend/src/hooks/useZaakReviewStatusBadges.tsx @@ -1,7 +1,7 @@ import { Badge, Solid } from "@maykin-ui/admin-ui"; import React, { useMemo } from "react"; -import { Zaak } from "../../../types"; +import { Zaak } from "../types"; import { ZAAK_REVIEW_STATUS_ENUM, useZaakReviewStatuses, diff --git a/frontend/src/pages/destructionlist/hooks/useZaakReviewStatuses.tsx b/frontend/src/hooks/useZaakReviewStatuses.tsx similarity index 97% rename from frontend/src/pages/destructionlist/hooks/useZaakReviewStatuses.tsx rename to frontend/src/hooks/useZaakReviewStatuses.tsx index c39bdfcee..772c31de9 100644 --- a/frontend/src/pages/destructionlist/hooks/useZaakReviewStatuses.tsx +++ b/frontend/src/hooks/useZaakReviewStatuses.tsx @@ -1,6 +1,6 @@ import { useMemo } from "react"; -import { Zaak } from "../../../types"; +import { Zaak } from "../types"; import { useZaakSelection } from "./useZaakSelection"; export type ZAAK_REVIEW_STATUS_ENUM = boolean | null; diff --git a/frontend/src/pages/destructionlist/hooks/useZaakSelection.test.ts b/frontend/src/hooks/useZaakSelection.test.ts similarity index 98% rename from frontend/src/pages/destructionlist/hooks/useZaakSelection.test.ts rename to frontend/src/hooks/useZaakSelection.test.ts index fceede9f7..9fd964976 100644 --- a/frontend/src/pages/destructionlist/hooks/useZaakSelection.test.ts +++ b/frontend/src/hooks/useZaakSelection.test.ts @@ -1,6 +1,6 @@ import { act, renderHook, waitFor } from "@testing-library/react"; -import { Zaak } from "../../../types"; +import { Zaak } from "../types"; import { useZaakSelection } from "./useZaakSelection"; jest.mock("react-router-dom", () => ({ diff --git a/frontend/src/pages/destructionlist/hooks/useZaakSelection.ts b/frontend/src/hooks/useZaakSelection.ts similarity index 98% rename from frontend/src/pages/destructionlist/hooks/useZaakSelection.ts rename to frontend/src/hooks/useZaakSelection.ts index 5690ffe86..725d5bd53 100644 --- a/frontend/src/pages/destructionlist/hooks/useZaakSelection.ts +++ b/frontend/src/hooks/useZaakSelection.ts @@ -10,8 +10,8 @@ import { clearZaakSelection as libClearZaakSelection, removeFromZaakSelection, setAllZakenSelected, -} from "../../../lib/zaakSelection/zaakSelection"; -import { Zaak } from "../../../types"; +} from "../lib/zaakSelection/zaakSelection"; +import { Zaak } from "../types"; export type ZaakSelectionClearer = () => Promise; diff --git a/frontend/src/pages/destructionlist/hooks/useZaaktypeChoices.ts b/frontend/src/hooks/useZaaktypeChoices.ts similarity index 80% rename from frontend/src/pages/destructionlist/hooks/useZaaktypeChoices.ts rename to frontend/src/hooks/useZaaktypeChoices.ts index d812ee4ca..a114d2540 100644 --- a/frontend/src/pages/destructionlist/hooks/useZaaktypeChoices.ts +++ b/frontend/src/hooks/useZaaktypeChoices.ts @@ -1,9 +1,9 @@ import { useAlert } from "@maykin-ui/admin-ui"; import { useEffect, useState } from "react"; -import { DestructionList } from "../../../lib/api/destructionLists"; -import { ZaaktypeChoice, listZaaktypeChoices } from "../../../lib/api/private"; -import { Review } from "../../../lib/api/review"; +import { DestructionList } from "../lib/api/destructionLists"; +import { ZaaktypeChoice, listZaaktypeChoices } from "../lib/api/private"; +import { Review } from "../lib/api/review"; /** * Hook resolving zaaktype choices diff --git a/frontend/src/pages/destructionlist/abstract/BaseListView.tsx b/frontend/src/pages/destructionlist/abstract/BaseListView.tsx index e309bf069..91aca301b 100644 --- a/frontend/src/pages/destructionlist/abstract/BaseListView.tsx +++ b/frontend/src/pages/destructionlist/abstract/BaseListView.tsx @@ -12,19 +12,19 @@ import React, { useCallback, useMemo } from "react"; import { useNavigation } from "react-router-dom"; import { DestructionListToolbar } from "../../../components"; -import { DestructionList } from "../../../lib/api/destructionLists"; -import { Review } from "../../../lib/api/review"; -import { PaginatedZaken } from "../../../lib/api/zaken"; -import { Zaak } from "../../../types"; -import { useFields } from "../hooks/useFields"; -import { useFilter } from "../hooks/useFilter"; -import { usePage } from "../hooks/usePage"; -import { useSort } from "../hooks/useSort"; +import { useFields } from "../../../hooks/useFields"; +import { useFilter } from "../../../hooks/useFilter"; +import { usePage } from "../../../hooks/usePage"; +import { useSort } from "../../../hooks/useSort"; import { ZaakSelectionDetailGetter, ZaakSelectionZaakFilter, useZaakSelection, -} from "../hooks/useZaakSelection"; +} from "../../../hooks/useZaakSelection"; +import { DestructionList } from "../../../lib/api/destructionLists"; +import { Review } from "../../../lib/api/review"; +import { PaginatedZaken } from "../../../lib/api/zaken"; +import { Zaak } from "../../../types"; /** The template used to format urls to an external application providing zaak details. */ const REACT_APP_ZAAK_URL_TEMPLATE = process.env.REACT_APP_ZAAK_URL_TEMPLATE; diff --git a/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx b/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx index f0bd415f7..4a08189cb 100644 --- a/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx +++ b/frontend/src/pages/destructionlist/create/DestructionListCreate.tsx @@ -14,9 +14,9 @@ import { } from "react-router-dom"; import { useSubmitAction } from "../../../hooks"; +import { useZaakSelection } from "../../../hooks/useZaakSelection"; import { getFilteredZaakSelection } from "../../../lib/zaakSelection/zaakSelection"; import { BaseListView } from "../abstract"; -import { useZaakSelection } from "../hooks/useZaakSelection"; import { DestructionListCreateAction, DestructionListCreateActionResponseData, diff --git a/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx b/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx index 095d61765..9894e6a43 100644 --- a/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx +++ b/frontend/src/pages/destructionlist/detail/hooks/useSecondaryNavigation.tsx @@ -10,7 +10,7 @@ import React, { useMemo } from "react"; import { useNavigation, useRouteLoaderData } from "react-router-dom"; import { ProcessingStatusBadge } from "../../../../components"; -import { useSubmitAction } from "../../../../hooks"; +import { useSubmitAction, useZaakSelection } from "../../../../hooks"; import { ReviewItemResponse } from "../../../../lib/api/reviewResponse"; import { canMarkAsReadyToReview, @@ -18,7 +18,6 @@ import { canTriggerDestruction, } from "../../../../lib/auth/permissions"; import { getFilteredZaakSelection } from "../../../../lib/zaakSelection/zaakSelection"; -import { useZaakSelection } from "../../hooks"; import { UpdateDestructionListAction, UpdateDestructionListProcessReviewAction, diff --git a/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx b/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx index f8ce6ae4c..78ad2e5aa 100644 --- a/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx +++ b/frontend/src/pages/destructionlist/detail/pages/DestructionListProcessReviewPage/DestructionListProcessReviewPage.tsx @@ -2,6 +2,7 @@ import { Outline, Toolbar, TypedField } from "@maykin-ui/admin-ui"; import React, { useMemo, useState } from "react"; import { useRevalidator, useRouteLoaderData } from "react-router-dom"; +import { useZaakReviewStatuses } from "../../../../../hooks"; import { PaginatedDestructionListItems } from "../../../../../lib/api/destructionListsItem"; import { PaginatedZaken } from "../../../../../lib/api/zaken"; import { @@ -11,7 +12,6 @@ import { } from "../../../../../lib/zaakSelection/zaakSelection"; import { Zaak } from "../../../../../types"; import { BaseListView } from "../../../abstract"; -import { useZaakReviewStatuses } from "../../../hooks"; import { DestructionListDetailContext } from "../../DestructionListDetail.loader"; import { useSecondaryNavigation } from "../../hooks/useSecondaryNavigation"; import { diff --git a/frontend/src/pages/destructionlist/hooks/index.ts b/frontend/src/pages/destructionlist/hooks/index.ts deleted file mode 100644 index 71ddf39b9..000000000 --- a/frontend/src/pages/destructionlist/hooks/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -export * from "./useCombinedSearchParams"; -export * from "./useFields"; -export * from "./useFilter"; -export * from "./usePage"; -export * from "./useSelectielijstKlasseChoices"; -export * from "./useSort"; -export * from "./useZaakReviewStatusBadges"; -export * from "./useZaakReviewStatuses"; -export * from "./useZaakSelection"; -export * from "./useZaaktypeChoices"; diff --git a/frontend/src/pages/destructionlist/review/DestructionListReview.tsx b/frontend/src/pages/destructionlist/review/DestructionListReview.tsx index d93691af1..21424faa1 100644 --- a/frontend/src/pages/destructionlist/review/DestructionListReview.tsx +++ b/frontend/src/pages/destructionlist/review/DestructionListReview.tsx @@ -9,7 +9,7 @@ import { import React, { useMemo } from "react"; import { useLoaderData, useRevalidator } from "react-router-dom"; -import { useSubmitAction } from "../../../hooks"; +import { useSubmitAction, useZaakReviewStatusBadges } from "../../../hooks"; import { ZaakReview } from "../../../lib/api/review"; import { ZaakSelection, @@ -18,7 +18,6 @@ import { } from "../../../lib/zaakSelection/zaakSelection"; import { Zaak } from "../../../types"; import { BaseListView } from "../abstract"; -import { useZaakReviewStatusBadges } from "../hooks"; import { ReviewDestructionListAction } from "./DestructionListReview.action"; import "./DestructionListReview.css"; import { DestructionListReviewContext } from "./DestructionListReview.loader";