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

Fix/link to ereol #654

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
83cfbc5
Use stylelint to indent user loans & reservations mock data files
Adamik10 Nov 2, 2023
5feea57
Add new graphql fragments & query & update the schema
Adamik10 Nov 2, 2023
5c272b2
Make it possible for LinkButton to recieve an id
Adamik10 Nov 2, 2023
7cab1b3
Make MaterialButtonLoading accept classNames from parents
Adamik10 Nov 2, 2023
6f991c1
Link to ereol material page from reservation details for ereol materials
Adamik10 Nov 2, 2023
6e24e9f
Merge branch 'develop' into fix/link-to-ereol
Adamik10 Nov 2, 2023
ea333ad
Merge branch 'develop' into fix/link-to-ereol
Adamik10 Nov 2, 2023
005426d
Update reservation-details.test with a new reservation work identifier
Adamik10 Nov 2, 2023
369fe96
Make sure loading button in reservation details modal is placed correct
Adamik10 Nov 7, 2023
7a6e7df
Make sure "Go to ereol" button has a data-cy prop for Cypress testing
Adamik10 Nov 7, 2023
73b7a65
Introduce advanced-search-fbi-api.json Cypress fixture & use it
Adamik10 Nov 7, 2023
b4be81f
Document findAccessManifestationByIdentifier in reservation modal helper
Adamik10 Nov 14, 2023
6017164
Add ereolenHomepageUrl to the global url props
Adamik10 Nov 15, 2023
aca0778
Use global ereolenHomepageUrl in reservation details instead of a string
Adamik10 Nov 15, 2023
7d64e20
Limit complex search query to 1 result in reservation details component
Adamik10 Nov 15, 2023
8071a8e
Merge branch 'develop' into fix/link-to-ereol
Adamik10 Nov 15, 2023
d44b051
Merge branch 'demo_2023-48-0' into fix/link-to-ereol
Adamik10 Nov 20, 2023
7cb0812
Merge branch 'demo_2023-48-0' into fix/link-to-ereol
Adamik10 Nov 27, 2023
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

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"];
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved

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

export const findEreolAccessLinkFromManifestations = (
manifestations: AccessManifestations
) => {
const manifestationWithEreolAccess = manifestations.find((manifestation) => {
return manifestation.access.find((access) => {
return access.__typename === "Ereol";
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
});
});
const ereolAccess = manifestationWithEreolAccess?.access.find(
(access) => access.__typename === "Ereol"
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
);
// 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;
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
};

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"
Adamik10 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading