diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 4e0af30..e2e95e2 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -97,7 +97,7 @@ export default function NavBar() { - + ); } diff --git a/src/components/matches/MatchDetail.tsx b/src/components/matches/MatchDetail.tsx index 582eaac..ce379df 100644 --- a/src/components/matches/MatchDetail.tsx +++ b/src/components/matches/MatchDetail.tsx @@ -50,13 +50,8 @@ const MatchDetail = ({ matchId }: { matchId: string }) => { } return ( - - + + )} - {fulfilledItems.length !== otherPersonFulfilledItems.length && - isSender && ( - - Noen av de overleverte bøkene har vært på andres vegne. Ta kontakt - med stand for mer informasjon. - - )} + {isSender && + otherPersonFulfilledItems.some( + (item) => !fulfilledItems.includes(item), + ) && ( + + Noen av bøkene du har levert tilhørte en annen elev. Du er selv + ansvarlig for at bøkene du opprinnelig fikk utdelt blir levert. Hvis + noen andre leverer bøkene dine, eller vi finner dem når skapene + tømmes, vil de bli markert som levert. + + )} + {!isFulfilled && ( <> - + Hvordan fungerer det? Du skal møte en annen elev og utveksle bøker. Det er viktig at den diff --git a/src/components/matches/matches-helper.tsx b/src/components/matches/matches-helper.tsx index d79a0f3..bf7ef8e 100644 --- a/src/components/matches/matches-helper.tsx +++ b/src/components/matches/matches-helper.tsx @@ -12,7 +12,7 @@ export interface ItemStatus { export const MatchHeader = ({ children }: { children: ReactNode }) => { return ( - + {children} ); @@ -33,21 +33,26 @@ export function calculateFulfilledStandMatchItems( return { fulfilledHandoffItems, fulfilledPickupItems }; } -export function calculateFulfilledUserMatchCustomerItems( +export function calculateFulfilledUserMatchItems( match: UserMatchWithDetails, isSender: boolean, ): string[] { return match.expectedItems.filter((item) => - (isSender ? match.deliveredBlIds : match.receivedBlIds).some( - (blId) => match.blIdToItemMap[blId] === item, + // For a sender, an item must have been both delivered and received to be fulfilled, though + // it does not need to be the same blId; someone else can deliver your book, and you can + // deliver someone else's, and that's fine. + // For the receiver, we only care that the book is received. + (isSender + ? [match.deliveredBlIds, match.receivedBlIds] + : [match.receivedBlIds] + ).every((registeredBlIds) => + registeredBlIds.some((blId) => match.blIdToItemMap[blId] === item), ), ); } export function calculateItemStatuses( match: T, - // surpressing because it thinks "match" is an actual variable - // eslint-disable-next-line no-unused-vars expectedItemsSelector: (match: T) => string[], fulfilledItems: string[], ): ItemStatus[] { @@ -86,7 +91,7 @@ export function isMatchFulfilled( ); } else { return ( - calculateFulfilledUserMatchCustomerItems(match, isSender).length >= + calculateFulfilledUserMatchItems(match, isSender).length >= match.expectedItems.length ); } @@ -108,7 +113,7 @@ export function isMatchBegun( calculateFulfilledStandMatchItems(match); return fulfilledHandoffItems.length > 0 || fulfilledPickupItems.length > 0; } else { - return calculateFulfilledUserMatchCustomerItems(match, isSender).length > 0; + return calculateFulfilledUserMatchItems(match, isSender).length > 0; } } diff --git a/src/components/matches/matchesList/ProgressBar.tsx b/src/components/matches/matchesList/ProgressBar.tsx index 040ea21..0349806 100644 --- a/src/components/matches/matchesList/ProgressBar.tsx +++ b/src/components/matches/matchesList/ProgressBar.tsx @@ -18,8 +18,11 @@ const ProgressBar: React.FC<{ flexDirection: "row", placeItems: "center", gap: "0.2rem", + marginBottom: "0.5rem", + } + : { + marginBottom: "0.5rem", } - : {} } > {finished && } diff --git a/src/components/matches/matchesList/UserMatchListItem.tsx b/src/components/matches/matchesList/UserMatchListItem.tsx index 3d18374..fe653e7 100644 --- a/src/components/matches/matchesList/UserMatchListItem.tsx +++ b/src/components/matches/matchesList/UserMatchListItem.tsx @@ -2,7 +2,7 @@ import { Box, Typography } from "@mui/material"; import React from "react"; import { - calculateFulfilledUserMatchCustomerItems, + calculateFulfilledUserMatchItems, isMatchBegun, isMatchFulfilled, isUserSenderInMatch, @@ -24,10 +24,7 @@ const UserMatchListItem: React.FC<{ const isSender = isUserSenderInMatch(match, currentUserId); const isBegun = isMatchBegun(match, isSender); const isFulfilled = isMatchFulfilled(match, isSender); - const fulfilledItems = calculateFulfilledUserMatchCustomerItems( - match, - isSender, - ); + const fulfilledItems = calculateFulfilledUserMatchItems(match, isSender); return (