From 61964b36c9c6ec34821eec916a5f51578e8db7cd Mon Sep 17 00:00:00 2001 From: Joonatan Kuosa Date: Thu, 12 Sep 2024 11:57:19 +0300 Subject: [PATCH] fix: pink terms box layout --- apps/ui/components/reservation/EditStep0.tsx | 40 ++++++++++++++++++-- apps/ui/pages/reservations/[id]/edit.tsx | 26 ------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/apps/ui/components/reservation/EditStep0.tsx b/apps/ui/components/reservation/EditStep0.tsx index ffa70d453..071602e90 100644 --- a/apps/ui/components/reservation/EditStep0.tsx +++ b/apps/ui/components/reservation/EditStep0.tsx @@ -25,13 +25,19 @@ import { import { CalendarWrapper } from "../reservation-unit/ReservationUnitStyles"; import { type UseFormReturn } from "react-hook-form"; import { type PendingReservationFormType } from "@/components/reservation-unit/schema"; -import { fromUIDate } from "common/src/common/util"; +import { + convertLanguageCode, + fromUIDate, + getTranslationSafe, +} from "common/src/common/util"; import { useReservableTimes } from "@/hooks/useReservableTimes"; import { ButtonLikeLink } from "../common/ButtonLikeLink"; import { ReservationTimePicker } from "./ReservationTimePicker"; import { QuickReservation } from "../reservation-unit/QuickReservation"; import { getNextAvailableTime } from "../reservation-unit/utils"; import { ReservationInfoCard } from "./ReservationInfoCard"; +import { Subheading } from "common/src/reservation-form/styles"; +import Sanitize from "@/components/common/Sanitize"; type ReservationUnitNodeT = NonNullable< ReservationUnitPageQuery["reservationUnit"] @@ -48,7 +54,12 @@ type Props = { }; const StyledCalendarWrapper = styled(CalendarWrapper)` + grid-column: 1 / -1; margin-bottom: 0; + @media (min-width: ${breakpoints.l}) { + grid-column: span 1; + grid-row: 3 / span 2; + } `; const Actions = styled.div` @@ -77,7 +88,18 @@ const StyledQuickReservation = styled(QuickReservation)` @media (min-width: ${breakpoints.m}) { grid-column-start: unset; grid-column-end: -1; - grid-row: 3 / -1; + grid-row: 3; + } +`; + +const PinkBox = styled.div` + padding: 1px var(--spacing-m) var(--spacing-m); + background-color: var(--color-suomenlinna-light); + grid-column: 1 / -1; + grid-row: -1; + @media (min-width: ${breakpoints.l}) { + grid-column: span 1 / -1; + grid-row: unset; } `; @@ -105,7 +127,7 @@ export function EditStep0({ nextStep, isLoading, }: Props): JSX.Element { - const { t } = useTranslation(); + const { t, i18n } = useTranslation(); const originalBegin = new Date(reservation.begin); const originalEnd = new Date(reservation.end); @@ -189,6 +211,9 @@ export function EditStep0({ activeApplicationRounds, }); + const lang = convertLanguageCode(i18n.language); + const termsOfUse = getTranslationSafe(reservationUnit, "termsOfUse", lang); + return ( <> + {/* TODO on mobile in the design this is after the calendar but before action buttons */} + {termsOfUse !== "" && ( + + {t("reservations:reservationInfoBoxHeading")} + + + )} diff --git a/apps/ui/pages/reservations/[id]/edit.tsx b/apps/ui/pages/reservations/[id]/edit.tsx index 26bec57e0..7cc125bde 100644 --- a/apps/ui/pages/reservations/[id]/edit.tsx +++ b/apps/ui/pages/reservations/[id]/edit.tsx @@ -30,9 +30,6 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { errorToast } from "common/src/common/toast"; import { reservationsPrefix } from "@/modules/const"; -import { Subheading } from "common/src/reservation-form/styles"; -import { getTranslation } from "@/modules/util"; -import Sanitize from "@/components/common/Sanitize"; import { EditStep0 } from "@/components/reservation/EditStep0"; import { EditStep1 } from "@/components/reservation/EditStep1"; import { @@ -62,20 +59,6 @@ const StyledStepper = styled(Stepper)` margin: var(--spacing-layout-m) 0 var(--spacing-layout-m); `; -const PinkBox = styled.div` - padding: 1px var(--spacing-m) var(--spacing-m); - background-color: var(--color-suomenlinna-light); - grid-column: 1 / -1; - grid-row: -1; - @media (min-width: ${breakpoints.m}) { - grid-column: span 3; - grid-row: unset; - } - @media (min-width: ${breakpoints.l}) { - grid-column: -3 / span 2; - } -`; - // copy of ReservationCancellation but some changes to grid layoout // see if we can refactor cancellation to use the same heading const HeadingSection = styled.div` @@ -168,8 +151,6 @@ function ReservationEditPage(props: PropsNarrowed): JSX.Element { ? "reservations:editReservationTime" : "reservationCalendar:heading.pendingReservation"; - const termsOfUse = getTranslation(reservationUnit, "termsOfUse"); - const handleStepClick = (e: React.MouseEvent) => { const target = e.currentTarget; const s = target @@ -230,13 +211,6 @@ function ReservationEditPage(props: PropsNarrowed): JSX.Element { steps={steps} /> - {/* TODO on mobile in the design this is after the calendar but before action buttons */} - {step === 0 && termsOfUse && ( - - {t("reservations:reservationInfoBoxHeading")} - - - )} {step === 0 ? (