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

Commit c46157f

Browse files
vincit-matujoonatank
authored andcommitted
fix: my units calendar now shows the reservation name with prefix
- makes translation function a required parameter in getReserveeName
1 parent b9db783 commit c46157f

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

apps/admin-ui/src/component/my-units/ReservationUnitCalendar.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from "common/src/helpers";
2929
import { RELATED_RESERVATION_STATES } from "common/src/const";
3030
import { ReservationUnitWithAffectingArgs } from "common/src/queries/fragments";
31+
import { TFunction } from "next-i18next";
3132

3233
type Props = {
3334
begin: string;
@@ -50,14 +51,16 @@ const Container = styled.div`
5051
const getEventTitle = ({
5152
reservationUnitPk,
5253
reservation,
54+
t,
5355
}: {
5456
reservationUnitPk: number;
5557
reservation: ReservationNode;
58+
t: TFunction;
5659
}) => {
5760
const reservationUnit = reservation.reservationUnit?.[0];
5861
const isOtherReservationUnit = reservationUnitPk !== reservationUnit?.pk;
5962

60-
const reserveeName = getReserveeName(reservation);
63+
const reserveeName = getReserveeName(reservation, t);
6164
if (isOtherReservationUnit) {
6265
const reservationUnitName = reservationUnit?.nameFi ?? "";
6366

@@ -67,10 +70,15 @@ const getEventTitle = ({
6770
return [reserveeName, ""];
6871
};
6972

70-
const constructEventTitle = (res: ReservationNode, resUnitPk: number) => {
73+
const constructEventTitle = (
74+
res: ReservationNode,
75+
resUnitPk: number,
76+
t: TFunction
77+
) => {
7178
const [reservee, unit] = getEventTitle({
7279
reservationUnitPk: resUnitPk,
7380
reservation: res,
81+
t,
7482
});
7583
if (unit.length > 0) {
7684
return `${reservee} (${unit})`;
@@ -124,7 +132,7 @@ export function ReservationUnitCalendar({
124132
const events = reservations.map((reservation) => {
125133
const isBlocked = reservation.type === ReservationTypeChoice.Blocked;
126134
const title = !isBlocked
127-
? constructEventTitle(reservation, reservationUnitPk)
135+
? constructEventTitle(reservation, reservationUnitPk, t)
128136
: t("MyUnits.Calendar.legend.closed");
129137
return {
130138
title,

apps/admin-ui/src/component/my-units/UnitCalendar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ function getEventTitle({
317317
}
318318

319319
return event && event?.pk !== event?.reservationUnit?.[0]?.pk
320-
? getReserveeName(event)
320+
? getReserveeName(event, t)
321321
: title;
322322
}
323323

apps/admin-ui/src/component/reservations/requested/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export const getTranslationKeyForCustomerTypeChoice = (
198198

199199
export const getReserveeName = (
200200
reservation: ReservationNode,
201-
t?: TFunction,
201+
t: TFunction,
202202
length = 50
203203
): string => {
204204
let prefix = "";

0 commit comments

Comments
 (0)