Skip to content

Commit

Permalink
Added attachement find
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Sep 29, 2023
1 parent fe66f11 commit a5981dc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pwa/src/services/getNameFromBijlageArray.ts
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 2 additions & 0 deletions pwa/src/services/getPDFName.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const getPDFName = (url: string) => {
if (!url) return;

const finalSlashIndex = url.lastIndexOf("/");
const pdfName = url.substring(finalSlashIndex + 1);
return pdfName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const CardsResultsTemplate: React.FC<CardsResultsTemplateProps> = ({ requ
{request.Publicatiedatum ? translateDate(i18n.language, request.Publicatiedatum) : "N.v.t."}
</CardHeaderDate>
<CardHeaderTitle className={styles.title}>
<Heading2>{request.Titel !== "" ? request.Titel : "Geen titel beschikbaar"}</Heading2>
<Heading2>{request.Titel !== ("" || null) ? request.Titel : "Geen titel beschikbaar"}</Heading2>
</CardHeaderTitle>
</CardHeader>

Expand Down
14 changes: 11 additions & 3 deletions pwa/src/templates/wooItemDetailTemplate/WOOItemDetailTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -133,7 +134,10 @@ export const WOOItemDetailTemplate: React.FC<WOOItemDetailTemplateProps> = ({ wo
<TableCell>{t("Bijlage informatieverzoek")}</TableCell>
<TableCell>
<Link href={getItems.data.URL_informatieverzoek} target="blank">
{getPDFName(getItems.data.URL_informatieverzoek)}
{getNameFromBijlageArray(
getItems.data.URL_informatieverzoek,
getItems.data?.embedded?.Bijlagen,
) ?? getPDFName(getItems.data.URL_informatieverzoek)}
</Link>
</TableCell>
</TableRow>
Expand All @@ -144,7 +148,10 @@ export const WOOItemDetailTemplate: React.FC<WOOItemDetailTemplateProps> = ({ wo
<TableCell>{t("Bijlage inventarisatielijst")}</TableCell>
<TableCell>
<Link href={getItems.data.URL_inventarisatielijst} target="blank">
{getPDFName(getItems.data.URL_inventarisatielijst)}
{getNameFromBijlageArray(
getItems.data.URL_inventarisatielijst,
getItems.data?.embedded?.Bijlagen,
) ?? getPDFName(getItems.data.URL_inventarisatielijst)}
</Link>
</TableCell>
</TableRow>
Expand All @@ -155,7 +162,8 @@ export const WOOItemDetailTemplate: React.FC<WOOItemDetailTemplateProps> = ({ wo
<TableCell>{t("Bijlage besluit")}</TableCell>
<TableCell>
<Link href={getItems.data.URL_besluit} target="blank">
{getPDFName(getItems.data.URL_besluit)}
{getNameFromBijlageArray(getItems.data.URL_besluit, getItems.data?.embedded?.Bijlagen) ??
getPDFName(getItems.data.URL_besluit)}
</Link>
</TableCell>
</TableRow>
Expand Down

0 comments on commit a5981dc

Please sign in to comment.