Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development to main, week 39 #92

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[]) => {
remko48 marked this conversation as resolved.
Show resolved Hide resolved
if (!array) return;
remko48 marked this conversation as resolved.
Show resolved Hide resolved
const bijlage = array.find((option) => {
return option.URL_Bijlage === url;
});

return bijlage?.Titel_Bijlage;
remko48 marked this conversation as resolved.
Show resolved Hide resolved
};
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>
remko48 marked this conversation as resolved.
Show resolved Hide resolved
</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
Loading