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

Reader player feature v2 #1665

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open

Conversation

kasperbirch1
Copy link
Contributor

@kasperbirch1 kasperbirch1 commented Jan 24, 2025

Link to issue

https://reload.atlassian.net/browse/DDFBRA-185
https://reload.atlassian.net/browse/DDFBRA-186
https://reload.atlassian.net/browse/DDFBRA-188
https://reload.atlassian.net/browse/DDFBRA-189

danskernesdigitalebibliotek/dpl-cms#2016

Description

This pull request fully integrates loan reservations and teasers for Publizon e-materials.

Changes & Features

With these changes, you can:

  • Loan e-materials
  • Reserve e-materials
Button Behavior Updates
  • If you have loaned a material, the loan button will shift to "Read / Listen to E-Material".
  • If you have reserved an e-material, the button will update to "E-Material Reserved" and will link to the user's reservation list.
  • In the loan and reservation modals, the button that previously linked to eroelen.dk now correctly links to the respective e-material.

Additionally, it enables all features that were previously hidden by the featureFlag.isActive("readerPlayer") check.

Note: There are still links to “eReolen Global,” such as /work/work-of:300756-katalog:107708154?type=e-bog, which the reader/player cannot handle because it only supports "Publizon" materials and not "Overdrive" materials.

Test

https://varnish.pr-2016.dpl-cms.dplplat01.dpl.reload.dk/work/work-of:870970-basis:138374319?type=lydbog+%28online%29

Almost always loaned material
https://varnish.pr-2016.dpl-cms.dplplat01.dpl.reload.dk/work/work-of:870970-basis:137757451?type=e-bog

reader-player-02.mp4

@kasperbirch1 kasperbirch1 force-pushed the reader-player-feature-v2 branch from c53aa90 to 237178a Compare January 27, 2025 10:13
`useReaderPlayer`:
- Refactored `useReaderPlayer` to include `useOnlineAvailabilityData` for checking material availability.
- Introduced `showMaterialButton`, `showLoanButton`, and `showReserveButton` logic in `useReaderPlayer` to centralize UI behavior.
- Optimize the code by removing unnecessary returns

`MaterialButtonsOnlineInternal`:
- Updated `MaterialButtonsOnlineInternal` to use new `showMaterialButton`, `showLoanButton`, and `showReserveButton` flags.
- Integrated `usePostV1UserLoansIdentifier` and `usePostV1UserReservationsIdentifier` to enable loan and reservation actions.

Next step is to ensure that the user is forced to log in when clicking on the loan button (opens modal) and dynamically adds the email and phoneNumber for reservations. Also, find out what to do when the phoneNumber is not available in the user profile data.
Updated the label to match the text on the main button, making it clearer that this is an e-material. Tested on mobile screens, and no display issues were found.
… modal

- Implemented `OnlineInternalModal` and `OnlineInternalModalBody` to handle confirmation processes for E-loan or reservation.
- Modified `MaterialButtonsOnlineInternal` to redirect unauthenticated users to the login page before rendering the modal. Additionally, added `openModal` to determine whether the buttons should open the modal or initiate a loan/reservation.
- Fixed logic for determining which buttons should be displayed in `useReaderPlayer`.
- Added simple success and error handling with `ModalMessage` inside `OnlineInternalModalBody`.
- Refactored variable names and streamlined logic for better maintainability and clarity.
Remove "ok" button and display the `MaterialButtonsOnlineInternal` in the `ModalMessage` so users can open reader or player
If the user already has a reserved e-material, it will display a `LinkButton` that links to the user's reservation page.

I had forgotten about `useLoans`, which we should definitely use here to simplify the code. I also added `useReservations` to determine the `isAlreadyReservedButtonVisible` variable.
@kasperbirch1 kasperbirch1 force-pushed the reader-player-feature-v2 branch 3 times, most recently from 25cade5 to f40db66 Compare January 28, 2025 09:00
Added a link to the material instead of a link to Erolen.

Fix cypress (`useGetWorkUrlFromPublizonIdentifier`)

Because I now use `useGetWorkUrlFromPublizonIdentifier` instead of `useComplexSearchWithPaginationWorkAccessQuery` inside `src/apps/reservation-list/modal/reservation-details/reservation-details.tsx`.
`MaterialButtonOnlineExternal` is no longer applied to Publizon eBooks but still supports eReolen Global (OverDrive) links.
This feature is now fully integrated and should no longer be hidden.
The use of `useLoans` and `useReservations` caused unexpected behavior, where the FBS API was called, leading to Cypress test failures. I was unable to get `enabled: !isUserAnonymous` to work properly with the FBS API. However, I believe it is also preferable to call Publizon directly from `useReaderPlayer`, as FBS materials are not relevant in this context.

Before this change, I temporarily fixed the Cypress test by adding fixtures for:

`cy.intercept("GET", "**/external/agencyid/patrons/patronid/loans/v2", {`inside src/components/reservation/reservation.test.ts.
Instead of linking to the reservation list, it now directly opens the `DeleteReservationModal`.

Known Issues:
- After deleting an e-material, `&modal=undefined9788740092912` is not removed.
- A bug causes `undefined` to be prefixed, affecting both this modal and the one in the reservation list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants