diff --git a/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/ApplicationEvents.tsx b/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/ApplicationEvents.tsx index 0986bb1ad..703ebca68 100644 --- a/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/ApplicationEvents.tsx +++ b/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/ApplicationEvents.tsx @@ -202,9 +202,6 @@ function ApplicationSectionColumn({ >): JSX.Element { const { t } = useTranslation(); - // TODO how is Rejected supposed to be shown? or is it ever shown in this list (or any other list)? - // there are no possible actions on this page for it, but do we filter out completely or disable all actions? - // allocations are not specific to the reservation unit const isAllocated = (as: ApplicationSectionNode) => as.allocations != null && as.allocations > 0; @@ -214,6 +211,11 @@ function ApplicationSectionColumn({ .filter((ruo) => ruo.reservationUnit.pk === reservationUnit.pk) ?.map((ruo) => ruo.locked) .some(Boolean); + const isRejected = (as: ApplicationSectionNode) => + as.reservationUnitOptions + .filter((ruo) => ruo.reservationUnit.pk === reservationUnit.pk) + ?.map((ruo) => ruo.rejected) + .some(Boolean); const sections = filterNonNullable(applicationSections); const allocated = sections.filter( @@ -224,14 +226,15 @@ function ApplicationSectionColumn({ (as) => as.status !== ApplicationSectionStatusChoice.Handled && isAllocated(as) && - !isLocked(as) + !isLocked(as) && + !isRejected(as) ); - const locked = sections.filter((as) => isLocked(as)); + const locked = sections.filter((as) => isLocked(as) || isRejected(as)); // take certain states and omit colliding application events const unallocatedApplicationEvents = (applicationSections ?? []).filter( - (as) => !isAllocated(as) + (as) => !isAllocated(as) && !isLocked(as) && !isRejected(as) ); return ( diff --git a/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/index.tsx b/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/index.tsx index 558e538ad..2d7b9d7a2 100644 --- a/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/index.tsx +++ b/apps/admin-ui/src/spa/recurring-reservations/application-rounds/[id]/allocation/index.tsx @@ -381,31 +381,54 @@ function ApplicationRoundAllocation({ // for calendar / right hand side we do more extensive filtering later. const applicationSections = filterNonNullable( appEventsData?.applicationSections?.edges.map((e) => e?.node) - ).filter((section) => { - const opts = section?.reservationUnitOptions?.filter((r) => { - if (r?.reservationUnit == null) { - return false; - } - if ( - r.allocatedTimeSlots.filter( - (ats) => ats.reservationUnitOption?.pk === r.pk - ).length > 0 - ) { + ) + .filter((section) => { + const opts = section?.reservationUnitOptions?.filter((r) => { + if (r?.reservationUnit == null) { + return false; + } + if ( + r.allocatedTimeSlots.filter( + (ats) => ats.reservationUnitOption?.pk === r.pk + ).length > 0 + ) { + return true; + } + if (preferredOrderFilterQuery.length > 0) { + const includedInPreferredOrder = + preferredOrderFilterQuery.includes(r.preferredOrder) || + (includePreferredOrder10OrHigher && (r.preferredOrder ?? 0) >= 10); + const orderFiltered = + includedInPreferredOrder && + r.reservationUnit.pk === reservationUnitFilterQuery; + return orderFiltered; + } + return r?.reservationUnit.pk === reservationUnitFilterQuery; + }); + return opts.length > 0; + }) + .map((section) => { + // query includes locked and rejected show we can show them in the left column + // but no allocation can be made to those + // which are made using suitableTimeRanges so filter them out + const opts = section?.reservationUnitOptions?.filter((r) => { + if (r.reservationUnit.pk !== reservationUnitFilterQuery) { + return false; + } + if (r?.locked || r?.rejected) { + return false; + } return true; + }); + + if (opts.length === 0) { + return { + ...section, + suitableTimeRanges: [], + }; } - if (preferredOrderFilterQuery.length > 0) { - const includedInPreferredOrder = - preferredOrderFilterQuery.includes(r.preferredOrder) || - (includePreferredOrder10OrHigher && (r.preferredOrder ?? 0) >= 10); - const orderFiltered = - includedInPreferredOrder && - r.reservationUnit.pk === reservationUnitFilterQuery; - return orderFiltered; - } - return r?.reservationUnit.pk === reservationUnitFilterQuery; + return section; }); - return opts.length > 0; - }); const priorityOptions = ([300, 200] as const).map((n) => ({ value: n,