Skip to content

Commit

Permalink
Merge pull request #654 from reload/fix/link-to-ereol
Browse files Browse the repository at this point in the history
Fix/link to ereol
  • Loading branch information
Adamik10 authored Nov 27, 2023
2 parents f972bac + 7cb0812 commit 4ed29e7
Show file tree
Hide file tree
Showing 20 changed files with 557 additions and 71 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"id" : "1b8c0935-12c7-43c9-9a49-3e591cc079bb",
"name" : "Reservations (list)",
"request" : {
"url" : "/v1/user/reservations",
"method" : "GET"
"id": "1b8c0935-12c7-43c9-9a49-3e591cc079bb",
"name": "Reservations (list)",
"request": {
"url": "/v1/user/reservations",
"method": "GET"
},
"response" : {
"status" : 200,
"body" : "{\n \"reservations\": [\n {\n \"productId\": \"0ddd10d0-d69f-4734-8a27-ac4546f4b912\",\n \"identifier\": \"9788711321683\",\n \"createdDateUtc\": \"2022-08-16T10:52:39.932Z\",\n \"status\": 1,\n \"productTitle\": \"Bargums synder\",\n \"expireDateUtc\": \"2023-01-27T19:37:15.63Z\",\n \"expectedRedeemDateUtc\": \"2023-01-27T19:37:15.63Z\"\n },\n {\n \"productId\": \"0ddd10d0-d69f-4734-8a27-ac4546f4b912\",\n \"identifier\": \"9788740047905\",\n \"createdDateUtc\": \"2022-08-16T10:52:39.932Z\",\n \"status\": 2,\n \"productTitle\": \"Bargums synder\",\n \"expireDateUtc\": \"2023-01-27T19:37:15.63Z\",\n \"expectedRedeemDateUtc\": \"2023-01-27T19:37:15.63Z\"\n }\n ],\n \"code\": 101,\n \"message\": \"OK\"\n}",
"headers" : {
"content-type" : "application/json; charset=utf-8",
"date" : "{{now format='yyyy-MM-dd HH:mm:ssZ'}}",
"strict-transport-security" : "max-age=15552000"
"response": {
"status": 200,
"body": "{\n \"reservations\": [\n {\n \"productId\": \"0ddd10d0-d69f-4734-8a27-ac4546f4b912\",\n \"identifier\": \"9788711321683\",\n \"createdDateUtc\": \"2022-08-16T10:52:39.932Z\",\n \"status\": 1,\n \"productTitle\": \"Bargums synder\",\n \"expireDateUtc\": \"2023-01-27T19:37:15.63Z\",\n \"expectedRedeemDateUtc\": \"2023-01-27T19:37:15.63Z\"\n },\n {\n \"productId\": \"0ddd10d0-d69f-4734-8a27-ac4546f4b912\",\n \"identifier\": \"9788702319361\",\n \"createdDateUtc\": \"2022-08-16T10:52:39.932Z\",\n \"status\": 2,\n \"productTitle\": \"Bargums synder\",\n \"expireDateUtc\": \"2023-01-27T19:37:15.63Z\",\n \"expectedRedeemDateUtc\": \"2023-01-27T19:37:15.63Z\"\n }\n ],\n \"code\": 101,\n \"message\": \"OK\"\n}",
"headers": {
"content-type": "application/json; charset=utf-8",
"date": "{{now format='yyyy-MM-dd HH:mm:ssZ'}}",
"strict-transport-security": "max-age=15552000"
}
},
"uuid" : "1b8c0935-12c7-43c9-9a49-3e591cc079bb",
"persistent" : true,
"priority" : 5,
"insertionIndex" : 23,
"postServeActions" : [ ]
}
"uuid": "1b8c0935-12c7-43c9-9a49-3e591cc079bb",
"persistent": true,
"priority": 5,
"insertionIndex": 23,
"postServeActions": []
}
125 changes: 125 additions & 0 deletions cypress/fixtures/reservation-details/advanced-search-fbi-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"data": {
"complexSearch": {
"hitcount": 1,
"works": [
{
"workId": "work-of:870970-basis:22677780",
"manifestations": {
"all": [
{
"pid": "870970-basis:22677780",
"identifiers": [
{
"type": "ISBN",
"value": "9788702319361"
},
{
"type": "ISBN",
"value": "87-00-45994-1"
}
],
"access": [
{
"__typename": "Ereol",
"url": "https://ereolen.dk/ting/object/870970-basis:51412656"
}
]
},
{
"pid": "870970-basis:27639097",
"identifiers": [
{
"type": "ISBN",
"value": "9788702075397"
}
],
"access": [
{
"__typename": "InterLibraryLoan",
"loanIsPossible": true
}
]
},
{
"pid": "870970-basis:29316945",
"identifiers": [
{
"type": "ISBN",
"value": "9788702114331"
}
],
"access": [
{
"__typename": "InterLibraryLoan",
"loanIsPossible": true
}
]
},
{
"pid": "870970-basis:51980239",
"identifiers": [
{
"type": "ISBN",
"value": "9788702173239"
}
],
"access": [
{
"__typename": "InterLibraryLoan",
"loanIsPossible": true
}
]
},
{
"pid": "870970-basis:52652219",
"identifiers": [
{
"type": "ISBN",
"value": "9788702204681"
}
],
"access": [
{
"__typename": "InterLibraryLoan",
"loanIsPossible": true
}
]
},
{
"pid": "870970-basis:54871929",
"identifiers": [
{
"type": "ISBN",
"value": "9788702272444"
}
],
"access": [
{
"__typename": "InterLibraryLoan",
"loanIsPossible": true
}
]
},
{
"pid": "870970-basis:61636935",
"identifiers": [
{
"type": "ISBN",
"value": "9788702319361"
}
],
"access": [
{
"__typename": "InterLibraryLoan",
"loanIsPossible": true
}
]
}
]
}
}
]
}
}
}
4 changes: 4 additions & 0 deletions src/apps/dashboard/dashboard.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export default {
defaultValue: "/user/me/reservations",
control: { type: "text" }
},
ereolenHomepageUrl: {
defaultValue: "https://ereolen.dk/",
control: { type: "text" }
},
yourProfileText: {
defaultValue: "Your profile",
control: { type: "text" }
Expand Down
1 change: 1 addition & 0 deletions src/apps/dashboard/dashboard.entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface DashBoardProps {
physicalLoansUrl: string;
feesPageUrl: string;
reservationsUrl: string;
ereolenHomepageUrl: string;
// Config
blacklistedPickupBranchesConfig: string;
branchesConfig: string;
Expand Down
2 changes: 1 addition & 1 deletion src/apps/material/openOrder.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutation openOrder($input: SubmitOrderInput!) {
submitOrder(input: $input, dryRun: false) {
submitOrder(input: $input, dryRun: false) {
status
message
orderId
Expand Down
4 changes: 4 additions & 0 deletions src/apps/menu/menu.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ export default {
defaultValue: "/Signup",
control: { type: "text" }
},
ereolenHomepageUrl: {
defaultValue: "https://ereolen.dk/",
control: { type: "text" }
},
expirationWarningDaysBeforeConfig: {
defaultValue: "6",
control: { type: "text" }
Expand Down
4 changes: 4 additions & 0 deletions src/apps/patron-page/PatronPage.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default {
"https://images.unsplash.com/photo-1560888126-5c13ad3f9345?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2371&q=80", // A goat.
control: { type: "text" }
},
ereolenHomepageUrl: {
defaultValue: "https://ereolen.dk/",
control: { type: "text" }
},
// Texts
patronPageHeaderText: {
defaultValue: "Patron profile page",
Expand Down
6 changes: 5 additions & 1 deletion src/apps/reservation-list/list/reservation-list.dev.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export default {
"https://images.unsplash.com/photo-1571043733612-d5444ff7d4ae?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1335&q=80",
control: { type: "text" }
},
ereolenHomepageUrl: {
defaultValue: "https://ereolen.dk/",
control: { type: "text" }
},
// Texts
reservationListHeaderText: {
defaultValue: "Your reservations",
Expand Down Expand Up @@ -271,7 +275,7 @@ const { reservationDetails } = getModalIds();
export const ReservationListDigitalDetailsModal = Template.bind({});
ReservationListDigitalDetailsModal.parameters = {
query: {
modal: `${reservationDetails}9788740047905`
modal: `${reservationDetails}9788702319361`
}
};

Expand Down
35 changes: 35 additions & 0 deletions src/apps/reservation-list/modal/reservation-details/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ComplexSearchWithPaginationWorkAccessQuery } from "../../../../core/dbc-gateway/generated/graphql";

type AccessManifestations =
ComplexSearchWithPaginationWorkAccessQuery["complexSearch"]["works"][0]["manifestations"]["all"];

export const findAccessManifestationByIdentifier = (
manifestations: AccessManifestations,
identifier: string
) =>
manifestations.filter((manifestation) =>
manifestation.identifiers.find(
// We are comparing ISBNs here, which can have different formats -
// with spaces/dashes, so we remove all non-digits before comparing.
(id) => id.value.replace(/\D/g, "") === identifier.replace(/\D/g, "")
)
);

export const findEreolAccessLinkFromManifestations = (
manifestations: AccessManifestations
) => {
const manifestationWithEreolAccess = manifestations.find((manifestation) => {
return manifestation.access.find((access) => {
return access.__typename === "Ereol";
});
});
const ereolAccess = manifestationWithEreolAccess?.access.find(
(access) => access.__typename === "Ereol"
);
// TODO: Find out why TS doesn't understand that ereolAccess will always exist
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore-next-line
return ereolAccess?.url;
};

export default {};
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React, { FC } from "react";
import ExternalLinkIcon from "@danskernesdigitalebibliotek/dpl-design-system/build/icons/buttons/icon-btn-external-link.svg";
import Link from "../../../../components/atoms/links/Link";
import { useText } from "../../../../core/utils/text";
import { MaterialProps } from "../../../loan-list/materials/utils/material-fetch-hoc";
import { useUrls } from "../../../../core/utils/url";
import { ReservationType } from "../../../../core/utils/types/reservation-type";
import LinkButton from "../../../../components/Buttons/LinkButton";

export interface ReservationDetailsRedirectProps {
reservation: ReservationType;
openReservationDeleteModal: (deleteReservation: ReservationType) => void;
className?: string;
linkClassNames?: string;
externalLink: URL;
}

const ReservationDetailsRedirect: FC<
Expand All @@ -19,28 +19,30 @@ const ReservationDetailsRedirect: FC<
reservation,
openReservationDeleteModal,
className,
linkClassNames
linkClassNames,
externalLink
}) => {
const t = useText();
const { ereolenMyPageUrl } = useUrls();

return (
<div className={`modal-details__buttons ${className}`}>
<button
type="button"
onClick={() => openReservationDeleteModal(reservation)}
className={`link-tag ${linkClassNames}`}
className={`link-tag cursor-pointer ${linkClassNames}`}
>
{t("reservationDetailsRemoveDigitalReservationText")}
</button>
<Link
href={new URL(ereolenMyPageUrl)}
className="btn-primary btn-filled btn-small arrow__hover--right-small"
<LinkButton
dataCy="go-to-ereolen-button"
size="small"
url={externalLink}
variant="filled"
id="go-to-ereolen-button"
>
{t("reservationDetailsDigitalReservationGoToEreolenText")}
<img src={ExternalLinkIcon} className="btn-icon invert" alt="" />
</Link>
</LinkButton>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ describe("Reservation details modal", () => {
operationName: "getManifestationViaMaterialByFaust",
fixtureFilePath: "reservation-details/fbi-api.json"
});

// Intercept graphql advanced search query.
cy.interceptGraphql({
operationName: "complexSearchWithPaginationWorkAccess",
fixtureFilePath: "reservation-details/advanced-search-fbi-api.json"
});
});

it("It shows digital reservation details modal", () => {
Expand Down Expand Up @@ -88,7 +94,7 @@ describe("Reservation details modal", () => {
reservations: [
{
productId: "0ddd10d0-d69f-4734-8a27-ac4546f4b912",
identifier: "9788740047905",
identifier: "9788702319361",
createdDateUtc: "2022-08-16T10:52:39.932Z",
status: 2,
productTitle: "Bargums synder",
Expand Down Expand Up @@ -191,8 +197,8 @@ describe("Reservation details modal", () => {
.eq(0)
.should("have.text", "Go to eReolen")
.should("have.attr", "href")
// ID 17 2.d.i. link to "ereolen.dk/user/me"
.should("include", "ereolen.dk/user/me");
// ID 17 2.d.i. link to "ereolen.dk"
.should("include", "ereolen.dk");

cy.get(".modal")
.find(".status-label")
Expand Down Expand Up @@ -261,7 +267,7 @@ describe("Reservation details modal", () => {
reservations: [
{
productId: "0ddd10d0-d69f-4734-8a27-ac4546f4b912",
identifier: "9788740047905",
identifier: "9788702319361",
createdDateUtc: "2022-08-16T12:52:39.932Z",
status: 1,
productTitle: "Bargums synder",
Expand Down
Loading

0 comments on commit 4ed29e7

Please sign in to comment.