11// Copyright The OpenTelemetry Authors
22// SPDX-License-Identifier: Apache-2.0
33
4- import { NextPage } from 'next' ;
4+ import { InferGetServerSidePropsType , NextPage } from 'next' ;
55import Head from 'next/head' ;
66import Link from 'next/link' ;
77import { useRouter } from 'next/router' ;
@@ -14,8 +14,17 @@ import Recommendations from '../../../../components/Recommendations';
1414import AdProvider from '../../../../providers/Ad.provider' ;
1515import * as S from '../../../../styles/Checkout.styled' ;
1616import { IProductCheckout } from '../../../../types/Cart' ;
17+ import { getCookie } from 'cookies-next' ;
1718
18- const Checkout : NextPage = ( ) => {
19+ export async function getServerSideProps ( ) {
20+ const userId = getCookie ( 'USERID' ) as string ;
21+
22+ return {
23+ props : { userId } ,
24+ } ;
25+ }
26+
27+ const Checkout : NextPage < InferGetServerSidePropsType < typeof getServerSideProps > > = ( { userId } ) => {
1928 const { query } = useRouter ( ) ;
2029 const { items = [ ] , shippingAddress } = JSON . parse ( ( query . order || '{}' ) as string ) as IProductCheckout ;
2130
@@ -35,11 +44,7 @@ const Checkout: NextPage = () => {
3544
3645 < S . ItemList >
3746 { items . map ( checkoutItem => (
38- < CheckoutItem
39- key = { checkoutItem . item . productId }
40- checkoutItem = { checkoutItem }
41- address = { shippingAddress }
42- />
47+ < CheckoutItem key = { checkoutItem . item . productId } checkoutItem = { checkoutItem } address = { shippingAddress } />
4348 ) ) }
4449 </ S . ItemList >
4550
@@ -52,7 +57,7 @@ const Checkout: NextPage = () => {
5257 < Recommendations />
5358 </ S . Checkout >
5459 < Ad />
55- < Footer />
60+ < Footer userId = { userId } />
5661 </ Layout >
5762 </ AdProvider >
5863 ) ;
0 commit comments