11import { ReservationState } from "common/types/common" ;
2- import { IconArrowRight , IconCalendar , IconSignout } from "hds-react" ;
2+ import {
3+ IconArrowRight ,
4+ IconCalendar ,
5+ IconLinkExternal ,
6+ IconSignout ,
7+ } from "hds-react" ;
38import { useRouter } from "next/router" ;
49import React , { useMemo } from "react" ;
510import { Trans , useTranslation } from "next-i18next" ;
@@ -8,19 +13,24 @@ import styled from "styled-components";
813import { fontMedium , fontRegular , H2 } from "common/src/common/typography" ;
914import { Reservation } from "common/src/reservation-form/types" ;
1015import {
16+ PaymentOrderType ,
1117 ReservationsReservationStateChoices ,
18+ ReservationType ,
1219 ReservationUnitType ,
1320} from "common/types/gql-types" ;
1421import { Subheading } from "common/src/reservation-form/styles" ;
22+ import { breakpoints } from "common/src/common/style" ;
1523import { getReservationUnitInstructionsKey } from "../../modules/reservationUnit" ;
1624import { getTranslation , reservationsUrl } from "../../modules/util" ;
17- import { BlackButton } from "../../styles/util" ;
25+ import { BlackButton , LinkButton } from "../../styles/util" ;
1826import { Paragraph } from "./styles" ;
1927import { reservationUnitPath } from "../../modules/const" ;
28+ import { useLogout } from "../../hooks/useLogout" ;
2029
2130type Props = {
22- reservation : Reservation ;
31+ reservation : Reservation | ReservationType ;
2332 reservationUnit : ReservationUnitType ;
33+ order ?: PaymentOrderType ;
2434} ;
2535
2636const Wrapper = styled . div `
@@ -33,6 +43,15 @@ const ActionContainer1 = styled.div`
3343 margin: var(--spacing-m) 0 var(--spacing-l);
3444 display: flex;
3545 gap: var(--spacing-m);
46+ flex-direction: column;
47+
48+ > button {
49+ max-width: 20rem;
50+ }
51+
52+ @media (min-width: ${ breakpoints . l } ) {
53+ flex-direction: row;
54+ }
3655` ;
3756
3857const ActionContainer2 = styled . div `
@@ -63,9 +82,11 @@ const InlineStyledLink = styled(Link)`
6382const ReservationConfirmation = ( {
6483 reservation,
6584 reservationUnit,
85+ order,
6686} : Props ) : JSX . Element => {
6787 const { t } = useTranslation ( ) ;
6888 const router = useRouter ( ) ;
89+ const { logout } = useLogout ( ) ;
6990
7091 const instructionsKey = useMemo (
7192 ( ) =>
@@ -94,7 +115,7 @@ const ReservationConfirmation = ({
94115 requiresHandling ? "Handling" : ""
95116 } `}
96117 t = { t }
97- values = { { user : reservation ?. user . email } }
118+ values = { { user : reservation ?. user ? .email } }
98119 components = { {
99120 br : < br /> ,
100121 lnk : (
@@ -118,6 +139,16 @@ const ReservationConfirmation = ({
118139 >
119140 { t ( "reservations:saveToCalendar" ) }
120141 </ BlackButton >
142+ { order ?. receiptUrl && (
143+ < BlackButton
144+ data-testid = "reservation__confirmation--button__receipt-link"
145+ onClick = { ( ) => window . open ( order . receiptUrl , "_blank" ) }
146+ variant = "secondary"
147+ iconRight = { < IconLinkExternal aria-hidden /> }
148+ >
149+ { t ( "reservations:downloadReceipt" ) }
150+ </ BlackButton >
151+ ) }
121152 </ ActionContainer1 >
122153 ) }
123154 { getTranslation ( reservationUnit , instructionsKey ) && (
@@ -141,9 +172,9 @@ const ReservationConfirmation = ({
141172 { t ( "common:gotoFrontpage" ) }
142173 < IconArrowRight aria-hidden size = "m" />
143174 </ StyledLink >
144- < StyledLink href = { reservationsUrl } >
175+ < LinkButton onClick = { ( ) => logout ( ) } >
145176 { t ( "common:logout" ) } < IconSignout size = "m" aria-hidden />
146- </ StyledLink >
177+ </ LinkButton >
147178 </ ActionContainer2 >
148179 </ div >
149180 </ Wrapper >
0 commit comments