From 85570e3e82c4f58f3eb86511a90ef200991556d3 Mon Sep 17 00:00:00 2001 From: Gilles Wittenberg Date: Tue, 16 Mar 2021 15:07:58 +0100 Subject: [PATCH 1/2] Remove code, files --- .../DebriefDeleteButton.tsx | 26 ---------- .../DebriefForm/DebriefEditForm.tsx | 26 ---------- .../CaseTimeline/components/EventWrapper.tsx | 24 +++------ .../components/TimelineEventItem.tsx | 4 +- src/app/pages/case/debriefings/EditPage.tsx | 49 ------------------- .../debriefings/hooks/usePageDebriefing.ts | 21 +------- src/app/pages/cases/routes.tsx | 7 --- 7 files changed, 10 insertions(+), 147 deletions(-) delete mode 100644 src/app/components/case/debriefings/DebriefDeleteButton/DebriefDeleteButton.tsx delete mode 100644 src/app/components/case/debriefings/DebriefForm/DebriefEditForm.tsx delete mode 100644 src/app/pages/case/debriefings/EditPage.tsx diff --git a/src/app/components/case/debriefings/DebriefDeleteButton/DebriefDeleteButton.tsx b/src/app/components/case/debriefings/DebriefDeleteButton/DebriefDeleteButton.tsx deleted file mode 100644 index e66503647..000000000 --- a/src/app/components/case/debriefings/DebriefDeleteButton/DebriefDeleteButton.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react" -import { Button } from "@amsterdam/asc-ui" - -import usePageDebriefing from "app/pages/case/debriefings/hooks/usePageDebriefing" -import { Delete } from "app/components/shared/Icons" - -type Props = { - id: Components.Schemas.Case["id"] - debriefingId: Components.Schemas.Debriefing["id"] -} - -const CONFIRM_TEXT = "Weet je zeker dat je deze debriefing wilt verwijderen?" -const BUTTON_TEXT = "Terugkoppeling verwijderen" - -const DebriefDeleteButton: React.FC = ({ id, debriefingId }) => { - - const { handleDelete } = usePageDebriefing(id, debriefingId) - const onDelete = () => { - if (!window.confirm(CONFIRM_TEXT)) return - handleDelete() - } - - return -} - -export default DebriefDeleteButton \ No newline at end of file diff --git a/src/app/components/case/debriefings/DebriefForm/DebriefEditForm.tsx b/src/app/components/case/debriefings/DebriefForm/DebriefEditForm.tsx deleted file mode 100644 index f7d7a5e33..000000000 --- a/src/app/components/case/debriefings/DebriefForm/DebriefEditForm.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import React from "react" -import { FormTitle } from "@amsterdam/asc-ui" - -import { useDebriefings } from "app/state/rest" -import usePageDebriefing from "app/pages/case/debriefings/hooks/usePageDebriefing" -import DebriefForm from "./DebriefForm" - -type Props = { - id: Components.Schemas.Case["id"] - debriefingId: Components.Schemas.Debriefing["id"] -} - -const DebriefEditForm: React.FC = ({ id, debriefingId }) => { - - const [data, { isBusy }] = useDebriefings(debriefingId) - const { handleUpdate } = usePageDebriefing(id, debriefingId) - - return ( - <> - Wijzig de terugkoppeling van de gehouden debrief - - - ) -} - -export default DebriefEditForm \ No newline at end of file diff --git a/src/app/components/cases/CaseTimeline/components/EventWrapper.tsx b/src/app/components/cases/CaseTimeline/components/EventWrapper.tsx index af9d66bd1..76b4067e7 100644 --- a/src/app/components/cases/CaseTimeline/components/EventWrapper.tsx +++ b/src/app/components/cases/CaseTimeline/components/EventWrapper.tsx @@ -1,31 +1,19 @@ import React from "react" import type { Field } from "../helpers/fields" import EventData from "./EventData" -import ButtonEditEvent from "./ButtonEditEvent" -import to from "app/routing/utils/to" type Props = { fields: Field[] caseEvent: Components.Schemas.CaseEvent isNested?: boolean - pathName?: string } -const EventWrapper: React.FC = ({ fields, caseEvent: { case: caseId, event_values, emitter_id, emitter_is_editable, emitter_is_editable_until }, isNested, pathName }) => ( - <> - - { emitter_is_editable_until && pathName !== undefined && - - } - +const EventWrapper: React.FC = ({ fields, caseEvent: { event_values }, isNested }) => ( + ) export default EventWrapper diff --git a/src/app/components/cases/CaseTimeline/components/TimelineEventItem.tsx b/src/app/components/cases/CaseTimeline/components/TimelineEventItem.tsx index 585f650ad..8dd73b083 100644 --- a/src/app/components/cases/CaseTimeline/components/TimelineEventItem.tsx +++ b/src/app/components/cases/CaseTimeline/components/TimelineEventItem.tsx @@ -38,9 +38,9 @@ const TimelineEventItem: React.FC = ({ fields, caseEvents, title = "", da largeCircle={ false } isNested={ true } > - + : - + } ) ) } diff --git a/src/app/pages/case/debriefings/EditPage.tsx b/src/app/pages/case/debriefings/EditPage.tsx deleted file mode 100644 index 8d9921d73..000000000 --- a/src/app/pages/case/debriefings/EditPage.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import React from "react" -import { RouteComponentProps } from "@reach/router" - -import DefaultLayout from "app/components/layouts/DefaultLayout/DefaultLayout" -import PageHeading from "app/components/shared/PageHeading/PageHeading" -import BreadCrumbs from "app/components/shared/BreadCrumbs/BreadCrumbs" -import { Row, RowWithColumn, Column } from "app/components/layouts/Grid" -import parseUrlParamId from "app/routing/utils/parseUrlParamId" -import isValidUrlParamId from "app/routing/utils/isValidUrlParamId" -import NotFoundPage from "app/pages/errors/NotFoundPage" -import CaseHeading from "app/components/cases/CaseHeading/CaseHeading" -import DebriefDeleteButton from "app/components/case/debriefings/DebriefDeleteButton/DebriefDeleteButton" -import DebriefEditForm from "app/components/case/debriefings/DebriefForm/DebriefEditForm" - -type Props = { - id: string - debriefingId: string -} - -const EditPage: React.FC> = ({ id: idString, debriefingId: debriefingIdString }) => { - - const id = parseUrlParamId(idString) - const debriefingId = parseUrlParamId(debriefingIdString) - - return ( - isValidUrlParamId(id) && - isValidUrlParamId(debriefingId) ? - - - - - - - - - - - - - - - - - : - - ) -} - -export default EditPage diff --git a/src/app/pages/case/debriefings/hooks/usePageDebriefing.ts b/src/app/pages/case/debriefings/hooks/usePageDebriefing.ts index b89c44751..e76cae838 100644 --- a/src/app/pages/case/debriefings/hooks/usePageDebriefing.ts +++ b/src/app/pages/case/debriefings/hooks/usePageDebriefing.ts @@ -5,7 +5,7 @@ import { useFlashMessages } from "app/state/flashMessages/useFlashMessages" import navigateTo from "app/routing/navigateTo" const usePageDebriefing = (caseId?: Components.Schemas.Case["id"], id?: Components.Schemas.Debriefing["id"]) => { - const [, { execPost, execPut, execDelete }] = useDebriefings(id, { lazy: true }) + const [, { execPost }] = useDebriefings(id, { lazy: true }) const { addSuccessFlashMessage } = useFlashMessages() const path = `/zaken/${ caseId ?? "" }` @@ -18,24 +18,7 @@ const usePageDebriefing = (caseId?: Components.Schemas.Case["id"], id?: Componen [addSuccessFlashMessage, path, execPost] ) - const handleUpdate = useCallback(payload => - execPut(payload).then(() => { - addSuccessFlashMessage(path, "Succes", "De debriefing is succesvol gewijzigd") - return navigateTo(path) - }), - [addSuccessFlashMessage, path, execPut] - ) - - const handleDelete = useCallback(() => - execDelete().then(() => { - addSuccessFlashMessage(path, "Succes", "De debriefing is succesvol verwijderd") - // TODO: Fix bug that debrief will be refetched, cause it's cache hook is used within displayed component - return navigateTo(path) - }), - [addSuccessFlashMessage, path, execDelete] - ) - - return { handleCreate, handleUpdate, handleDelete } + return { handleCreate } } export default usePageDebriefing diff --git a/src/app/pages/cases/routes.tsx b/src/app/pages/cases/routes.tsx index 01e991b0a..a329e96e5 100644 --- a/src/app/pages/cases/routes.tsx +++ b/src/app/pages/cases/routes.tsx @@ -1,7 +1,6 @@ import IndexPage from "app/pages/cases/index/IndexPage" import DetailsPage from "app/pages/cases/details/DetailsPage" import DebriefCreatePage from "app/pages/case/debriefings/CreatePage" -import DebriefEditPage from "app/pages/case/debriefings/EditPage" import OpinionCreatePage from "app/pages/case/opinions/CreatePage" import SummonCreatePage from "app/pages/case/summons/CreatePage" import DecisionCreatePage from "app/pages/case/decisions/CreatePage" @@ -9,7 +8,6 @@ import CorrespondenceCreatePage from "app/pages/case/correspondence/CreatePage" import CompleteCasePage from "app/pages/cases/complete/CompleteCasePage" import VisitCreatePage from "app/pages/case/visits/CreatePage" - // NOTE: please add your own POC-specific routes here. export default { "/zaken": { @@ -37,11 +35,6 @@ export default { title: "Debrief terugkoppeling geven", icon: "Edit" }, - "debriefing/:debriefingId": { - Page: DebriefEditPage, - title: "Debrief terugkoppeling wijzigen", - icon: "Edit" - }, "besluit": { Page: DecisionCreatePage, title: "Resultaat besluit", From fa134df856c804cee88e3031f61ff0eb3f065ff6 Mon Sep 17 00:00:00 2001 From: Gilles Wittenberg Date: Tue, 16 Mar 2021 16:07:10 +0100 Subject: [PATCH 2/2] Generate types --- src/__generated__/apiSchema.d.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/__generated__/apiSchema.d.ts b/src/__generated__/apiSchema.d.ts index c289992f3..db85857ab 100644 --- a/src/__generated__/apiSchema.d.ts +++ b/src/__generated__/apiSchema.d.ts @@ -90,8 +90,6 @@ declare namespace Components { readonly date_created: string; // date-time type: TypeEnum; emitter_id: number; - emitter_is_editable: boolean; - emitter_is_editable_until: string; // date-time case: number; } export interface CaseReason { @@ -120,8 +118,6 @@ declare namespace Components { readonly date_modified: string; // date-time violation?: ViolationEnum; feedback: string; - readonly is_editable: boolean; - readonly is_editable_until: string; // date-time } export interface DebriefingCreate { readonly id: number; @@ -385,8 +381,6 @@ declare namespace Components { readonly date_modified?: string; // date-time violation?: ViolationEnum; feedback?: string; - readonly is_editable?: boolean; - readonly is_editable_until?: string; // date-time } export interface PatchedSummon { readonly id?: number; @@ -710,6 +704,29 @@ declare namespace Paths { export type $200 = Components.Schemas.Case; } } + namespace CasesSearchList { + namespace Parameters { + export type Page = number; + export type PostalCode = string; + export type StartDate = string; // date + export type StreetName = string; + export type StreetNumber = string; + export type Suffix = string; + export type Team = string; + } + export interface QueryParameters { + page?: Parameters.Page; + postalCode?: Parameters.PostalCode; + start_date?: Parameters.StartDate /* date */; + streetName?: Parameters.StreetName; + streetNumber?: Parameters.StreetNumber; + suffix?: Parameters.Suffix; + team?: Parameters.Team; + } + namespace Responses { + export type $200 = Components.Schemas.PaginatedCaseList; + } + } namespace CasesTasksList { namespace Parameters { export type Id = number;