Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit d06ab5c

Browse files
committed
fix: consistent reservation list count
1 parent 18b5989 commit d06ab5c

3 files changed

Lines changed: 11 additions & 14 deletions

File tree

apps/admin-ui/src/component/ReservationsList.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import usePermission from "@/hooks/usePermission";
88
import { Permission } from "@/modules/permissionHelper";
99
import { NewReservationModal } from "./reservations/EditTimeModal";
1010
import { useModal } from "@/context/ModalContext";
11+
import { H6 } from "common";
1112

1213
export type NewReservationListItem = {
1314
date: Date;
@@ -197,7 +198,7 @@ const TitleWrapper = styled.div`
197198
`;
198199

199200
type Props = {
200-
header?: React.ReactNode;
201+
header?: string;
201202
items: NewReservationListItem[];
202203
hasPadding?: boolean;
203204
};
@@ -214,10 +215,16 @@ export function ReservationList(props: Props | ExtendedProps) {
214215
const hasReservation =
215216
"reservationToCopy" in props && !!props.reservationToCopy;
216217

218+
const removed = items.filter((x) => x.isRemoved).length;
219+
const count = items.length - removed;
217220
return (
218221
<ListWrapper data-testid="reservations-list">
219222
<TitleWrapper>
220-
{header}
223+
{header != null && (
224+
<H6 as="h3" style={{ flexGrow: 1 }}>
225+
{header} {`(${count})`}
226+
</H6>
227+
)}
221228
{hasReservation && (
222229
<div>
223230
<AddNewReservationButton

apps/admin-ui/src/component/reservations/requested/RecurringReservationsView.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from "react";
2-
import { H6 } from "common/src/common/typography";
32
import { useTranslation } from "react-i18next";
43
import { format } from "date-fns";
54
import {
@@ -173,7 +172,7 @@ export function RecurringReservationsView({
173172

174173
return (
175174
<ReservationList
176-
header={<H6 as="h3">{t("RecurringReservationsView.Heading")}</H6>}
175+
header={t("RecurringReservationsView.Heading")}
177176
items={items}
178177
reservationToCopy={reservationToCopy}
179178
refetch={refetch}

apps/admin-ui/src/spa/my-units/recurring/RecurringReservationDone.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useParams } from "react-router-dom";
44
import styled from "styled-components";
55
import { Container } from "hds-react";
66
import { ErrorBoundary } from "react-error-boundary";
7-
import { H1, H6 } from "common/src/common/typography";
7+
import { H1 } from "common/src/common/typography";
88
import { breakpoints } from "common/src/common/style";
99
import { RecurringReservationsView } from "@/component/reservations/requested/RecurringReservationsView";
1010
import { ActionsWrapper } from "./commonStyling";
@@ -18,10 +18,6 @@ const InfoSection = styled.p`
1818
margin: var(--spacing-l) 0;
1919
`;
2020

21-
const StyledH6 = styled(H6)`
22-
margin-bottom: 0;
23-
`;
24-
2521
const StyledContainer = styled(Container)`
2622
margin-top: var(--spacing-2-xl);
2723
@media (min-width: ${breakpoints.m}) {
@@ -57,17 +53,12 @@ function RecurringReservationDoneInner({
5753
const reservationPk = reservations[0]?.pk;
5854
const reservationUrl = reservationPk ? `/reservations/${reservationPk}` : "";
5955

60-
const successes = reservations;
61-
6256
return (
6357
<StyledContainer>
6458
<H1 $legacy>
6559
{reservations.length > 0 ? t(`title`) : t("allFailedTitle")}
6660
</H1>
6761
<InfoSection>{t(`successInfo`)}</InfoSection>
68-
<StyledH6 as="h2">
69-
{t("successSubtitle")} ({successes.length})
70-
</StyledH6>
7162
<RecurringReservationsView recurringPk={recurringPk} />
7263
<ActionsWrapper>
7364
<ButtonLikeLink to="../../.." relative="path">

0 commit comments

Comments
 (0)