Skip to content

Commit

Permalink
♻️ #459 - refactor: combine hooks directories
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Oct 29, 2024
1 parent 74ea563 commit 00238bd
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 43 deletions.
10 changes: 10 additions & 0 deletions frontend/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Original file line number Diff line number Diff line change
@@ -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", () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions frontend/src/pages/destructionlist/abstract/BaseListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ 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,
canMarkListAsFinal,
canTriggerDestruction,
} from "../../../../lib/auth/permissions";
import { getFilteredZaakSelection } from "../../../../lib/zaakSelection/zaakSelection";
import { useZaakSelection } from "../../hooks";
import {
UpdateDestructionListAction,
UpdateDestructionListProcessReviewAction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/pages/destructionlist/hooks/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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";
Expand Down

0 comments on commit 00238bd

Please sign in to comment.