Skip to content

Commit 63e92e3

Browse files
acasazzamalessani
authored andcommitted
fix: Server side rendering error for react 18
1 parent 0547a08 commit 63e92e3

26 files changed

Lines changed: 482 additions & 252 deletions

File tree

components/composite/Checkout/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ const Checkout: React.FC<Props> = ({
5353
privacyUrl,
5454
}) => {
5555
const ctx = useContext(AppContext)
56+
console.log('ctx', ctx)
5657
const { query } = useRouter()
5758

5859
let paypalPayerId = ""
@@ -142,14 +143,15 @@ const Checkout: React.FC<Props> = ({
142143
<StepCustomer className="mb-6" step={1} />
143144
</AccordionItem>
144145
</AccordionProvider>
145-
{ctx.isShipmentRequired && (
146+
<>{ctx.isShipmentRequired && (
146147
<AccordionProvider
147148
activeStep={activeStep}
148149
lastActivableStep={lastActivableStep}
149150
setActiveStep={setActiveStep}
150151
step="Shipping"
151152
steps={steps}
152153
isStepRequired={ctx.isShipmentRequired}
154+
isStepDone={ctx.hasShippingMethod}
153155
>
154156
<AccordionItem
155157
index={2}
@@ -160,7 +162,7 @@ const Checkout: React.FC<Props> = ({
160162
<StepShipping className="mb-6" step={2} />
161163
</AccordionItem>
162164
</AccordionProvider>
163-
)}
165+
)}</>
164166
<AccordionProvider
165167
activeStep={activeStep}
166168
lastActivableStep={lastActivableStep}

components/composite/ErrorContainer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Footer } from "components/ui/Footer"
44

55
import { Wrapper, LogoWrapper, FullLogo, Main, Error } from "./styled"
66

7-
export const ErrorContainer: React.FC = ({ children }) => {
7+
export const ErrorContainer = ({ children }: { children: JSX.Element[] | JSX.Element | null }) => {
88
return (
99
<Base>
1010
<Container>

components/composite/StepComplete/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export const StepComplete: React.FC<Props> = ({
143143
/>
144144
</RecapBox>
145145
</div>
146-
{ctx.isShipmentRequired && (
146+
<>{ctx.isShipmentRequired && (
147147
<div data-testid="shipping-address-recap">
148148
<RecapItemTitle>
149149
{t("stepComplete.ship_to")}
@@ -163,7 +163,7 @@ export const StepComplete: React.FC<Props> = ({
163163
/>
164164
</RecapBox>
165165
</div>
166-
)}
166+
)}</>
167167
</AddressContainer>
168168
</RecapCol>
169169

components/composite/StepCustomer/AddressSectionSaveForm/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import styled from "styled-components"
22
import tw from "twin.macro"
33

4-
export const AddressSectionSaveForm: React.FC = ({ children }) => {
4+
interface Props {
5+
children?: JSX.Element[] | JSX.Element
6+
}
7+
8+
export const AddressSectionSaveForm = ({ children }: Props): JSX.Element => {
59
return <Wrapper>{children}</Wrapper>
610
}
711
const Wrapper = styled.div`

components/composite/StepCustomer/AddressSectionTitle/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import styled from "styled-components"
22
import tw from "twin.macro"
33

4-
export const AddressSectionTitle: React.FC = ({ children, ...rest }) => {
4+
interface Props {
5+
children?: JSX.Element[] | JSX.Element
6+
}
7+
8+
export const AddressSectionTitle = ({ children, ...rest }: Props): JSX.Element => {
59
return <Wrapper {...rest}>{children}</Wrapper>
610
}
711

components/composite/StepCustomer/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Order } from "@commercelayer/sdk"
22
import classNames from "classnames"
3-
import { Fragment, useContext, useEffect, useState } from "react"
3+
import { useContext, useEffect, useState } from "react"
44
import { useTranslation } from "react-i18next"
55

66
import { AccordionContext } from "components/data/AccordionProvider"
@@ -138,8 +138,9 @@ export const StepCustomer: React.FC<Props> = () => {
138138
})}
139139
>
140140
<StepContent>
141+
<>
141142
{accordionCtx.isActive && (
142-
<Fragment>
143+
<>
143144
{isGuest ? (
144145
<CheckoutAddresses
145146
shippingAddress={shippingAddress}
@@ -174,8 +175,9 @@ export const StepCustomer: React.FC<Props> = () => {
174175
handleSave={handleSave}
175176
/>
176177
)}
177-
</Fragment>
178+
</>
178179
)}
180+
</>
179181
</StepContent>
180182
</StepContainer>
181183
)

components/composite/StepPayment/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export const StepPayment: React.FC = () => {
130130
})}
131131
>
132132
<StepContent>
133+
<>
133134
{accordionCtx.isActive && (
134135
<div>
135136
{isPaymentRequired ? (
@@ -153,6 +154,7 @@ export const StepPayment: React.FC = () => {
153154
)}
154155
</div>
155156
)}
157+
</>
156158
</StepContent>
157159
</StepContainer>
158160
)

components/composite/StepShipping/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const StepShipping: React.FC<Props> = () => {
103103
const appCtx = useContext(AppContext)
104104
const accordionCtx = useContext(AccordionContext)
105105
const gtmCtx = useContext(GTMContext)
106-
106+
console.log(accordionCtx)
107107
const { t } = useTranslation()
108108

109109
if (!appCtx || !accordionCtx) {
@@ -166,6 +166,7 @@ export const StepShipping: React.FC<Props> = () => {
166166
if (gtmCtx?.fireAddShippingInfo) {
167167
await gtmCtx.fireAddShippingInfo()
168168
}
169+
console.log('order', order)
169170
appCtx.autoSelectShippingMethod(order)
170171
}
171172

@@ -178,6 +179,8 @@ export const StepShipping: React.FC<Props> = () => {
178179
})}
179180
>
180181
<StepContent>
182+
<>
183+
181184
{isShipmentRequired && (
182185
<div>
183186
{accordionCtx.isActive && (
@@ -369,6 +372,7 @@ export const StepShipping: React.FC<Props> = () => {
369372
)}
370373
</div>
371374
)}
375+
</>
372376
</StepContent>
373377
</StepContainer>
374378
)

components/data/AccordionProvider/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface AccordionProviderProps {
2323
setActiveStep?: (step: SingleStepEnum) => void
2424
isStepRequired?: boolean
2525
isStepDone?: boolean
26+
children?: JSX.Element[] | JSX.Element | null
2627
}
2728

2829
export const AccordionProvider: React.FC<AccordionProviderProps> = ({

components/data/AppProvider/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ interface AppProviderProps {
8585
slug: string
8686
orderId: string
8787
accessToken: string
88+
children?: JSX.Element[] | JSX.Element | null
8889
}
8990

9091
export const AppProvider: React.FC<AppProviderProps> = ({
@@ -215,14 +216,14 @@ export const AppProvider: React.FC<AppProviderProps> = ({
215216

216217
const autoSelectShippingMethod = async (order?: Order) => {
217218
dispatch({ type: ActionType.START_LOADING })
218-
219219
const currentOrder = order ?? (await fetchOrder(cl, orderId))
220220
const others = calculateSettings(
221221
currentOrder,
222222
state.isShipmentRequired,
223223
state.customerAddresses
224224
)
225-
225+
console.log('others', others)
226+
debugger
226227
dispatch({
227228
type: ActionType.SAVE_SHIPMENTS,
228229
payload: {

0 commit comments

Comments
 (0)