From a5981dc247bbf61c1c858514f4f2d4a0b13596c2 Mon Sep 17 00:00:00 2001 From: Remko Date: Fri, 29 Sep 2023 14:54:54 +0200 Subject: [PATCH 1/2] Added attachement find --- pwa/src/services/getNameFromBijlageArray.ts | 8 ++++++++ pwa/src/services/getPDFName.ts | 2 ++ .../cardsResultsTemplate/CardsResultsTemplate.tsx | 2 +- .../WOOItemDetailTemplate.tsx | 14 +++++++++++--- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 pwa/src/services/getNameFromBijlageArray.ts diff --git a/pwa/src/services/getNameFromBijlageArray.ts b/pwa/src/services/getNameFromBijlageArray.ts new file mode 100644 index 00000000..b6172f9b --- /dev/null +++ b/pwa/src/services/getNameFromBijlageArray.ts @@ -0,0 +1,8 @@ +export const getNameFromBijlageArray = (url: string, array: any[]) => { + if (!array) return; + const bijlage = array.find((option) => { + return option.URL_Bijlage === url; + }); + + return bijlage?.Titel_Bijlage; +}; diff --git a/pwa/src/services/getPDFName.ts b/pwa/src/services/getPDFName.ts index 8ace533f..cf2b6ea8 100644 --- a/pwa/src/services/getPDFName.ts +++ b/pwa/src/services/getPDFName.ts @@ -1,4 +1,6 @@ export const getPDFName = (url: string) => { + if (!url) return; + const finalSlashIndex = url.lastIndexOf("/"); const pdfName = url.substring(finalSlashIndex + 1); return pdfName; diff --git a/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx b/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx index cf2a776b..d4b53b03 100644 --- a/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx +++ b/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx @@ -26,7 +26,7 @@ export const CardsResultsTemplate: React.FC = ({ requ {request.Publicatiedatum ? translateDate(i18n.language, request.Publicatiedatum) : "N.v.t."} - {request.Titel !== "" ? request.Titel : "Geen titel beschikbaar"} + {request.Titel !== ("" || null) ? request.Titel : "Geen titel beschikbaar"} diff --git a/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx b/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx index 975cfef6..e1db54d0 100644 --- a/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx +++ b/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx @@ -22,6 +22,7 @@ import { useOpenWoo } from "../../hooks/openWoo"; import Skeleton from "react-loading-skeleton"; import { getPDFName } from "../../services/getPDFName"; import { isUUID } from "../../services/isUUID"; +import { getNameFromBijlageArray } from "../../services/getNameFromBijlageArray"; interface WOOItemDetailTemplateProps { wooItemId: string; @@ -133,7 +134,10 @@ export const WOOItemDetailTemplate: React.FC = ({ wo {t("Bijlage informatieverzoek")} - {getPDFName(getItems.data.URL_informatieverzoek)} + {getNameFromBijlageArray( + getItems.data.URL_informatieverzoek, + getItems.data?.embedded?.Bijlagen, + ) ?? getPDFName(getItems.data.URL_informatieverzoek)} @@ -144,7 +148,10 @@ export const WOOItemDetailTemplate: React.FC = ({ wo {t("Bijlage inventarisatielijst")} - {getPDFName(getItems.data.URL_inventarisatielijst)} + {getNameFromBijlageArray( + getItems.data.URL_inventarisatielijst, + getItems.data?.embedded?.Bijlagen, + ) ?? getPDFName(getItems.data.URL_inventarisatielijst)} @@ -155,7 +162,8 @@ export const WOOItemDetailTemplate: React.FC = ({ wo {t("Bijlage besluit")} - {getPDFName(getItems.data.URL_besluit)} + {getNameFromBijlageArray(getItems.data.URL_besluit, getItems.data?.embedded?.Bijlagen) ?? + getPDFName(getItems.data.URL_besluit)} From 566e376429a1334b6ce1e76cbe22d94107d1cf6e Mon Sep 17 00:00:00 2001 From: Remko Date: Tue, 3 Oct 2023 09:40:56 +0200 Subject: [PATCH 2/2] requested changes --- pwa/src/services/getNameFromBijlageArray.ts | 9 ++------- .../CardsResultsTemplate.tsx | 2 +- .../WOOItemDetailTemplate.tsx | 16 ++++++++++++---- pwa/static/.env.development | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/pwa/src/services/getNameFromBijlageArray.ts b/pwa/src/services/getNameFromBijlageArray.ts index b6172f9b..103472fc 100644 --- a/pwa/src/services/getNameFromBijlageArray.ts +++ b/pwa/src/services/getNameFromBijlageArray.ts @@ -1,8 +1,3 @@ -export const getNameFromBijlageArray = (url: string, array: any[]) => { - if (!array) return; - const bijlage = array.find((option) => { - return option.URL_Bijlage === url; - }); - - return bijlage?.Titel_Bijlage; +export const getBijlageTitleFromURL = (url: string, bijlagen: any[]): string | undefined => { + return bijlagen.find((bijlage) => bijlage.URL_Bijlage === url)?.Titel_Bijlage; }; diff --git a/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx b/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx index d4b53b03..6dbf4a06 100644 --- a/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx +++ b/pwa/src/templates/templateParts/cardsResultsTemplate/CardsResultsTemplate.tsx @@ -26,7 +26,7 @@ export const CardsResultsTemplate: React.FC = ({ requ {request.Publicatiedatum ? translateDate(i18n.language, request.Publicatiedatum) : "N.v.t."} - {request.Titel !== ("" || null) ? request.Titel : "Geen titel beschikbaar"} + {request.Titel ?? "Geen titel beschikbaar"} diff --git a/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx b/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx index e1db54d0..56a305a7 100644 --- a/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx +++ b/pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx @@ -22,7 +22,7 @@ import { useOpenWoo } from "../../hooks/openWoo"; import Skeleton from "react-loading-skeleton"; import { getPDFName } from "../../services/getPDFName"; import { isUUID } from "../../services/isUUID"; -import { getNameFromBijlageArray } from "../../services/getNameFromBijlageArray"; +import { getBijlageTitleFromURL } from "../../services/getNameFromBijlageArray"; interface WOOItemDetailTemplateProps { wooItemId: string; @@ -134,7 +134,7 @@ export const WOOItemDetailTemplate: React.FC = ({ wo {t("Bijlage informatieverzoek")} - {getNameFromBijlageArray( + {getBijlageTitleFromURL( getItems.data.URL_informatieverzoek, getItems.data?.embedded?.Bijlagen, ) ?? getPDFName(getItems.data.URL_informatieverzoek)} @@ -148,11 +148,19 @@ export const WOOItemDetailTemplate: React.FC = ({ wo {t("Bijlage inventarisatielijst")} - {getNameFromBijlageArray( + {getBijlageTitleFromURL( getItems.data.URL_inventarisatielijst, getItems.data?.embedded?.Bijlagen, ) ?? getPDFName(getItems.data.URL_inventarisatielijst)} + <> + {console.log( + getBijlageTitleFromURL( + getItems.data.URL_inventarisatielijst, + getItems.data?.embedded?.Bijlagen, + ), + )} + )} @@ -162,7 +170,7 @@ export const WOOItemDetailTemplate: React.FC = ({ wo {t("Bijlage besluit")} - {getNameFromBijlageArray(getItems.data.URL_besluit, getItems.data?.embedded?.Bijlagen) ?? + {getBijlageTitleFromURL(getItems.data.URL_besluit, getItems.data?.embedded?.Bijlagen) ?? getPDFName(getItems.data.URL_besluit)} diff --git a/pwa/static/.env.development b/pwa/static/.env.development index 4656d5f5..c58bbd25 100644 --- a/pwa/static/.env.development +++ b/pwa/static/.env.development @@ -8,7 +8,7 @@ GATSBY_API_BASE_URL=https://api.gateway.commonground.nu/api GATSBY_NL_DESIGN_THEME_CLASSNAME=conduction-theme # Header -GATSBY_FAVICON_URL=https://conduction.nl/wp-content/uploads/2021/07/cropped-favicon-32x32.png +GATSBY_FAVICON_URL="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIKICAgICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgdmVy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IDM4IDIxIDUzIDIxIDg0IDEgMjEgLTE0IDI2IC0xNCA1NCAxIDE3IDggMzEgMTkgMzEKMjMgMCA4IC0xMTMgNzIgLTEyNiA3MiAtNSAwIC0zOSAtMTcgLTc2IC0zOHoiLz4KICAgIDwvZz4KPC9zdmc+Cg==" GATSBY_HEADER_LOGO_URL=https://conduction.nl/wp-content/uploads/2021/07/cropped-conductionlogo-1.png #Jumbotron @@ -16,7 +16,7 @@ GATSBY_ORGANISATION_NAME=Conduction GATSBY_JUMBOTRON_IMAGE_URL=https://www.conduction.nl/wp-content/uploads/2021/07/cropped-Conduction_HOME_0000_afb1-1.png # Footer -GATSBY_FOOTER_LOGO_URL=data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDIwMDEwOTA0Ly9FTiIKICAgICJodHRwOi8vd3d3LnczLm9yZy9UUi8yMDAxL1JFQy1TVkctMjAwMTA5MDQvRFREL3N2ZzEwLmR0ZCI+CjxzdmcgdmVyc2lvbj0iMS4wIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgICAgd2lkdGg9IjcxLjAwMDAwMHB0IiBoZWlnaHQ9IjcwLjAwMDAwMHB0IiB2aWV3Qm94PSIwIDAgNzEuMDAwMDAwIDcwLjAwMDAwMCIKICAgICBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0Ij4KCiAgICA8ZyB0cmFuc2Zvcm09InRyYW5zbGF0ZSgwLjAwMDAwMCw3MC4wMDAwMDApIHNjYWxlKDAuMTAwMDAwLC0wLjEwMDAwMCkiCiAgICAgICBmaWxsPSIjNDM3NkZDIiBzdHJva2U9Im5vbmUiPgogICAgICAgIDxwYXRoIGQ9Ik0yMTggNTkyIGwtMTM3IC03NyAwIC0xNjUgMCAtMTY1IDEzMSAtNzQgYzc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