From 353be19e5ed1bbd1e04e37e8a78d171af68dc424 Mon Sep 17 00:00:00 2001 From: remyvdwereld <86827854+remyvdwereld@users.noreply.github.com> Date: Wed, 20 Sep 2023 13:29:35 +0200 Subject: [PATCH] Styling updated --- .../organisms/CaseDetail/CaseDetail.tsx | 4 +- .../sections/{Status.tsx => History.tsx} | 6 +-- .../organisms/CaseDetail/sections/Logbook.tsx | 2 +- .../organisms/CaseDetail/sections/Owner.tsx | 42 +++++++++++++++++++ .../CaseDetail/sections/Residence.tsx | 10 ++--- .../CaseDetail/{utils.tsx => utils.ts} | 25 +---------- src/app/features/types.ts | 2 + 7 files changed, 55 insertions(+), 36 deletions(-) rename src/app/features/cases/components/organisms/CaseDetail/sections/{Status.tsx => History.tsx} (79%) create mode 100644 src/app/features/cases/components/organisms/CaseDetail/sections/Owner.tsx rename src/app/features/cases/components/organisms/CaseDetail/{utils.tsx => utils.ts} (63%) diff --git a/src/app/features/cases/components/organisms/CaseDetail/CaseDetail.tsx b/src/app/features/cases/components/organisms/CaseDetail/CaseDetail.tsx index efc85516f..7d41b324f 100644 --- a/src/app/features/cases/components/organisms/CaseDetail/CaseDetail.tsx +++ b/src/app/features/cases/components/organisms/CaseDetail/CaseDetail.tsx @@ -8,7 +8,7 @@ import Logbook from "./sections/Logbook" import Residence from "./sections/Residence" import Permits from "./sections/Permits" import ResidentsView from "./sections/ResidentsView" -import Status from "./sections/Status" +import History from "./sections/History" import VacationRentalThisYear from "./sections/VacationRentalThisYear" type Props = { @@ -45,7 +45,7 @@ const CaseDetail: FC = ({ caseId }) => { - + ) } diff --git a/src/app/features/cases/components/organisms/CaseDetail/sections/Status.tsx b/src/app/features/cases/components/organisms/CaseDetail/sections/History.tsx similarity index 79% rename from src/app/features/cases/components/organisms/CaseDetail/sections/Status.tsx rename to src/app/features/cases/components/organisms/CaseDetail/sections/History.tsx index 56892841b..9a47fcff1 100644 --- a/src/app/features/cases/components/organisms/CaseDetail/sections/Status.tsx +++ b/src/app/features/cases/components/organisms/CaseDetail/sections/History.tsx @@ -6,11 +6,11 @@ type Props = { caseId: string } -const Status: React.FC = ({ caseId }) => { +const History: React.FC = ({ caseId }) => { const { data } = useCaseEvents(caseId) return ( - + { data !== undefined && = ({ caseId }) => { ) } -export default Status +export default History diff --git a/src/app/features/cases/components/organisms/CaseDetail/sections/Logbook.tsx b/src/app/features/cases/components/organisms/CaseDetail/sections/Logbook.tsx index 2f8a98a26..289c5f7c8 100644 --- a/src/app/features/cases/components/organisms/CaseDetail/sections/Logbook.tsx +++ b/src/app/features/cases/components/organisms/CaseDetail/sections/Logbook.tsx @@ -149,7 +149,7 @@ const Logbook: React.FC = ({ caseId }) => { .map(mapLogbookItemToDetailComponents(observations?.results!, suggestNextVisits?.results!)) .flat() - return details.length ? details : [ "Geen notities." ] + return details.length ? details : [ "Geen notities" ] }, [ caseData, caseVisitsData, users, observations, suggestNextVisits ]) return ( diff --git a/src/app/features/cases/components/organisms/CaseDetail/sections/Owner.tsx b/src/app/features/cases/components/organisms/CaseDetail/sections/Owner.tsx new file mode 100644 index 000000000..72656ba6b --- /dev/null +++ b/src/app/features/cases/components/organisms/CaseDetail/sections/Owner.tsx @@ -0,0 +1,42 @@ +import React, { FC } from "react" +import styled from "styled-components" +import { BrkData, BrkDataError, Case } from "app/features/types" + +const Ul = styled.ul` + list-style-position: inside; + padding-left: 0; +` + +type Props = { + caseData: Case +} + +const Owner: FC = ({ caseData: { brk_data } }) => { + const hasBrkError = (brk_data as BrkDataError).error + // An error has occurred! + if (hasBrkError) { + return <>BRK-gegevens kunnen momenteel niet worden opgehaald. + } + + const brkData = brk_data as BrkData + + if (brkData.results.length) { + const rechten = brkData.results.map(result => ( + + { result?.cultuurcode_bebouwd?.omschrijving && ( + { result?.cultuurcode_bebouwd?.omschrijving } + )} +
    { result?.rechten?.map(recht =>
  • { recht._display }
  • ) }
+
+ )) + return ( + + { rechten } + + ) + } + // BRK is empty and that shouldn't be possible. + return <>Er zijn geen BRK-gegevens gevonden. +} + +export default Owner diff --git a/src/app/features/cases/components/organisms/CaseDetail/sections/Residence.tsx b/src/app/features/cases/components/organisms/CaseDetail/sections/Residence.tsx index 413b2f50d..cc35e2b56 100644 --- a/src/app/features/cases/components/organisms/CaseDetail/sections/Residence.tsx +++ b/src/app/features/cases/components/organisms/CaseDetail/sections/Residence.tsx @@ -4,8 +4,9 @@ import { useCase } from "app/state/rest" import { BagData, BagDataError } from "app/features/types" import MailtoAnchor from "app/features/cases/components/molecules/MailtoAnchor/MailtoAnchor" -import { getAddress, getBagId, getEigenaar } from "../utils" +import { getAddress, getBagId } from "../utils" import CaseDetailSection from "../CaseDetailSection" +import Owner from "./Owner" type Props = { caseId: string @@ -42,7 +43,6 @@ const Residence: FC = ({ caseId }) => { // General const address = getAddress(caseData.address) - const eigenaar = getEigenaar(caseData) const postalCode = caseData.address.postal_code // Terugmeld email @@ -61,11 +61,9 @@ const Residence: FC = ({ caseId }) => { woonbootAanduiding={ woonbootAanduiding } /> - const ownerField = [ "Eigenaar", { eigenaar } ] - const woningFields = [ [ "Databron", "BRK" ], - ownerField, + , [ "Databron", "BAG" ], [ "Gebruiksdoel", woningBestemming ], [ "Soort object (feitelijk gebruik)", woningGebruik ], @@ -80,7 +78,7 @@ const Residence: FC = ({ caseId }) => { [ "Status", woonbootStatus || "–" ], [ "Indicatie geconstateerd", woonbootIndicatie ], [ "Aanduiding in onderzoek", woonbootAanduiding ], - ownerField, + , mailtoAnchor ] diff --git a/src/app/features/cases/components/organisms/CaseDetail/utils.tsx b/src/app/features/cases/components/organisms/CaseDetail/utils.ts similarity index 63% rename from src/app/features/cases/components/organisms/CaseDetail/utils.tsx rename to src/app/features/cases/components/organisms/CaseDetail/utils.ts index 9510f9bbe..d480c7cd0 100644 --- a/src/app/features/cases/components/organisms/CaseDetail/utils.tsx +++ b/src/app/features/cases/components/organisms/CaseDetail/utils.ts @@ -1,4 +1,4 @@ -import { BagData, BagDataError, BrkData, BrkDataError, Case, Address } from "app/features/types" +import { BagData, BagDataError, Case, Address } from "app/features/types" import displayAddress from "app/features/shared/utils/displayAddress" export const getAddress = (address: Address) => displayAddress(address.street_name, address.number, address.suffix_letter || undefined, address.suffix || undefined) @@ -10,29 +10,6 @@ export const getBagId = (caseData: Case) => { return hasBagData ? (bagData.verblijfsobjectidentificatie ?? bagData.ligplaatsidentificatie) : undefined } -export const getEigenaar = (caseData: Case) => { - const hasBrkData = (caseData.brk_data as BrkDataError).error === undefined - - if (!hasBrkData) { - return undefined - } - - const brkData = caseData.brk_data as BrkData - - if (brkData.results.length) { - const rechten = brkData.results.map(result => ( - <> - { result?.cultuurcode_bebouwd?.omschrijving && ( - { result?.cultuurcode_bebouwd?.omschrijving } - )} -
    {result?.rechten?.map(recht =>
  • { recht._display}
  • )}
- - )) - return rechten - } - return undefined -} - export const isNullish = (a: any): a is undefined | null => a === undefined || a === null || a === "" const logbookTranslationsMap: Record = { diff --git a/src/app/features/types.ts b/src/app/features/types.ts index 2ec409f73..90f64dc99 100644 --- a/src/app/features/types.ts +++ b/src/app/features/types.ts @@ -31,10 +31,12 @@ export type BagDataError = { export type BrkData = { results: { + id: string cultuurcode_bebouwd?: { omschrijving?: string } rechten?: { + id: string _display: string }[] }[]