@@ -5,12 +5,12 @@ import Link from "next/link";
55import { useRouter } from "next/router" ;
66import NextImage from "next/image" ;
77import styled from "styled-components" ;
8- import { H5 , Strongish } from "common/src/common/typography" ;
8+ import { H5 } from "common/src/common/typography" ;
99import { breakpoints } from "common/src/common/style" ;
1010import { ReservationUnitType } from "common/types/gql-types" ;
1111import { format , isToday , isTomorrow } from "date-fns" ;
1212import { toUIDate } from "common/src/common/util" ;
13- import { getAddressAlt , getMainImage , getTranslation } from "@/modules/util" ;
13+ import { getMainImage , getTranslation } from "@/modules/util" ;
1414import IconWithText from "../common/IconWithText" ;
1515import { MediumButton , pixel , truncatedText } from "@/styles/util" ;
1616import {
@@ -38,6 +38,7 @@ const Container = styled.div`
3838
3939const MainContent = styled . div `
4040 display: grid;
41+ gap: var(--spacing-s);
4142 margin: var(--spacing-s);
4243 position: relative;
4344
@@ -61,7 +62,6 @@ const Description = styled.span`
6162 font-family: var(--font-regular);
6263 font-size: var(--fontsize-body-m);
6364 flex-grow: 1;
64- height: 40px;
6565
6666 @media (min-width: ${ breakpoints . m } ) {
6767 height: unset;
@@ -148,21 +148,24 @@ const StyledIconWithText = styled(IconWithText)`
148148 }
149149` ;
150150
151- const StyledTag = styled ( Tag ) `
152- position: absolute;
153- top: 0;
154- right: 0;
155- z-index: 1;
156-
157- &.available {
158- background: var(--color-success-light);
159- }
160- &.no-times {
161- background: var(--color-error-light);
162- }
163- &.closed {
164- background: var(--tag-background);
151+ const StyledTag = styled ( Tag ) < { $status : "available" | "no-times" | "closed" } > `
152+ @media (min-width: ${ breakpoints . s } ) {
153+ position: absolute;
154+ top: 0;
155+ right: 0;
156+ z-index: 1;
165157 }
158+
159+ background: ${ ( { $status } ) => {
160+ switch ( $status ) {
161+ case "available" :
162+ return "var(--color-success-light)" ;
163+ case "no-times" :
164+ return "var(--color-error-light)" ;
165+ case "closed" :
166+ return "var(--tag-background)" ;
167+ }
168+ } } ;
166169` ;
167170
168171const StatusTag = ( ru : {
@@ -173,15 +176,13 @@ const StatusTag = (ru: {
173176
174177 if ( closed ) {
175178 return (
176- < StyledTag className = "closed" >
177- { t ( "reservationUnitCard:closed" ) }
178- </ StyledTag >
179+ < StyledTag $status = "closed" > { t ( "reservationUnitCard:closed" ) } </ StyledTag >
179180 ) ;
180181 }
181182
182183 if ( ! availableAt ) {
183184 return (
184- < StyledTag className = "no-times" >
185+ < StyledTag $status = "no-times" >
185186 { t ( "reservationUnitCard:noTimes" ) }
186187 </ StyledTag >
187188 ) ;
@@ -195,9 +196,7 @@ const StatusTag = (ru: {
195196 dayText = `${ t ( "common:tomorrow" ) } ` ;
196197 } else dayText = `${ toUIDate ( new Date ( availableAt ) ) } ` ;
197198
198- return (
199- < StyledTag className = "available" > { `${ dayText } ${ timeText } ` } </ StyledTag >
200- ) ;
199+ return < StyledTag $status = "available" > { `${ dayText } ${ timeText } ` } </ StyledTag > ;
201200} ;
202201
203202const ReservationUnitCard = ( { reservationUnit } : PropsT ) : JSX . Element => {
@@ -207,8 +206,6 @@ const ReservationUnitCard = ({ reservationUnit }: PropsT): JSX.Element => {
207206
208207 const name = getReservationUnitName ( reservationUnit ) ;
209208
210- const addressString = getAddressAlt ( reservationUnit ) ;
211-
212209 const link = `${ reservationUnitPrefix } /${ reservationUnit . pk } ` ;
213210
214211 const unitName = getUnitName ( reservationUnit . unit ?? undefined ) ;
@@ -233,21 +230,15 @@ const ReservationUnitCard = ({ reservationUnit }: PropsT): JSX.Element => {
233230 < Name >
234231 < StyledInlineLink href = { link } > { name } </ StyledInlineLink >
235232 </ Name >
236- < StatusTag
237- data = { {
238- closed : reservationUnit . isClosed ?? false ,
239- availableAt : reservationUnit . firstReservableDatetime ?? "" ,
240- } }
241- />
242- < Description >
243- { unitName }
244- { addressString && (
245- < >
246- { ", " }
247- < Strongish > { addressString } </ Strongish >
248- </ >
249- ) }
250- </ Description >
233+ < Description > { unitName } </ Description >
234+ < div >
235+ < StatusTag
236+ data = { {
237+ closed : reservationUnit . isClosed ?? false ,
238+ availableAt : reservationUnit . firstReservableDatetime ?? "" ,
239+ } }
240+ />
241+ </ div >
251242 < Bottom >
252243 < Props >
253244 { reservationUnitTypeName && (
0 commit comments