Skip to content

Commit

Permalink
Merge pull request #1096 from danskernesdigitalebibliotek/divide-loan…
Browse files Browse the repository at this point in the history
…s-that-cant-be-renewed

Show renewable loans grouped first, then non-renewable
  • Loading branch information
Adamik10 authored Apr 9, 2024
2 parents e6d5cfa + e3c8854 commit 0e4f6f9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/components/GroupModal/GroupModalLoansList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ const GroupModalLoansList: FC<GroupModalLoansListProps> = ({
selectMaterials,
pageSize
}) => {
// Show renewable materials first, then non-renewable
const groupedMaterials = materials.sort(
(a, b) => Number(!!b.isRenewable) - Number(!!a.isRenewable)
);
const t = useText();
const [displayedMaterials, setDisplayedMaterials] = useState<LoanType[]>([]);
const { itemsShown, PagerComponent, firstInNewPage } = usePager({
hitcount: materials.length,
hitcount: groupedMaterials.length,
pageSize
});

useEffect(() => {
setDisplayedMaterials([...materials].splice(0, itemsShown));
}, [itemsShown, materials]);
setDisplayedMaterials([...groupedMaterials].splice(0, itemsShown));
}, [itemsShown, groupedMaterials]);

const onMaterialChecked = (item: ListType) => {
const selectedMaterialsCopy = [...selectedMaterials];
Expand Down

0 comments on commit 0e4f6f9

Please sign in to comment.