Skip to content

Commit

Permalink
fix some of ill reservation problems, where 'all' shold be used inste…
Browse files Browse the repository at this point in the history
…ad of 'mostRelevant'
  • Loading branch information
kfudbc committed Jan 26, 2024
1 parent c64adac commit 2a25cc0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export function LocalizationInformation({
>{`${pickupBranch?.postalCode} ${pickupBranch?.city}`}</Text>
</div>
)}

{/* maybe move warning together with warning in order-modal. see bibdk2021-1927 */}
{!isLoadingBranches &&
pickupBranch &&
Expand Down
2 changes: 1 addition & 1 deletion src/components/hooks/useOrderPageInformations.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function useOrderPageInformation({
return inferAccessTypes(
periodicaForm,
pickupBranch,
workData?.work?.manifestations?.mostRelevant,
workData?.work?.manifestations?.all,
loanerInfo
);
}, [workData?.work, periodicaForm, pickupBranch]);
Expand Down
8 changes: 2 additions & 6 deletions src/components/hooks/useWorkAndSelectedPids.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ export function useGetManifestationsForOrderButton(workId, selectedPids) {
const workResponse = useData(workId && workFragments.buttonTxt({ workId }));

const allPids = useMemo(() => {
return workResponse?.data?.work?.manifestations?.mostRelevant?.flatMap(
return workResponse?.data?.work?.manifestations?.all?.flatMap(
(manifestation) => manifestation.pid
);
}, [
workId,
selectedPids,
workResponse?.data?.work?.manifestations?.mostRelevant,
]);
}, [workId, selectedPids, workResponse?.data?.work?.manifestations?.all]);

const manifestationsResponse = useData(
allPids &&
Expand Down
2 changes: 1 addition & 1 deletion src/components/work/overview/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function Overview({
className = "",
skeleton = false,
}) {
const manifestations = work?.manifestations?.mostRelevant;
const manifestations = work?.manifestations?.all;
const router = useRouter();

const { uniqueMaterialTypes, inUniqueMaterialTypes, flatPidsByType } =
Expand Down
2 changes: 1 addition & 1 deletion src/components/work/reservationbutton/ReservationButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export const ReservationButton = ({
modal,
handleOrderFinished = undefined,
}) => {
const physicalCopy = checkPhysicalCopy([access?.[0]])?.[0]; //TODO why do we check all accesses if only one is used in the end?
const physicalCopy = checkPhysicalCopy(access)?.[0]; //TODO why do we check all accesses if only one is used in the end?
const digitalCopy = checkDigitalCopy([access?.[0]])?.[0]; //TODO why do we check all accesses if only one is used in the end?

const noSelectedManifestations = Boolean(isEmpty(access));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import useUser from "@/components/hooks/useUser";
* @returns {React.ReactElement|null}
*/
function OrderButtonTextBelow({ access, skeleton }) {
const physicalCopy = checkPhysicalCopy([access?.[0]])?.[0];
const physicalCopy = checkPhysicalCopy(access)?.[0];
const digitalCopy = checkDigitalCopy([access?.[0]])?.[0];
const isPeriodicaLike = getAreAccessesPeriodicaLike([access?.[0]])?.[0];

Expand Down
7 changes: 5 additions & 2 deletions src/lib/api/work.fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ export function buttonTxt({ workId }) {
manifestations {
all {
pid
materialTypes {
...materialTypesFragment
}
}
mostRelevant {
pid
Expand Down Expand Up @@ -766,7 +769,7 @@ export function orderPageWorkWithManifestations({ workId }) {
}
workTypes
manifestations {
mostRelevant {
all {
...manifestationAccess
...manifestationDetailsForAccessFactory
}
Expand Down Expand Up @@ -807,7 +810,7 @@ export function overviewWork({ workId }) {
}
workTypes
manifestations {
mostRelevant {
all {
ownerWork {
workTypes
}
Expand Down

0 comments on commit 2a25cc0

Please sign in to comment.