File tree Expand file tree Collapse file tree 3 files changed +47
-3
lines changed
components/onboarding-cta Expand file tree Collapse file tree 3 files changed +47
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
} from "medusa-react"
12
12
import React , { useEffect , useState } from "react"
13
13
import { useCartDropdown } from "./cart-dropdown-context"
14
+ import { useSearchParams } from "next/navigation"
14
15
15
16
interface VariantInfoProps {
16
17
variantId : string
@@ -57,6 +58,17 @@ export const StoreProvider = ({ children }: StoreProps) => {
57
58
const removeLineItem = useDeleteLineItem ( cart ?. id ! )
58
59
const adjustLineItem = useUpdateLineItem ( cart ?. id ! )
59
60
61
+ // check if the user is onboarding and sets the onboarding session storage
62
+ const searchParams = useSearchParams ( )
63
+ const onboardingCartId = searchParams . get ( "cart_id" )
64
+ const isOnboarding = searchParams . get ( "onboarding" )
65
+
66
+ useEffect ( ( ) => {
67
+ if ( isOnboarding === "true" ) {
68
+ sessionStorage . setItem ( "onboarding" , "true" )
69
+ }
70
+ } , [ isOnboarding ] )
71
+
60
72
const storeRegion = ( regionId : string , countryCode : string ) => {
61
73
if ( ! IS_SERVER ) {
62
74
localStorage . setItem (
@@ -195,7 +207,7 @@ export const StoreProvider = ({ children }: StoreProps) => {
195
207
196
208
useEffect ( ( ) => {
197
209
const ensureCart = async ( ) => {
198
- const cartId = getCart ( )
210
+ const cartId = onboardingCartId || getCart ( )
199
211
const region = getRegion ( )
200
212
201
213
if ( cartId ) {
Original file line number Diff line number Diff line change
1
+ import Button from "@modules/common/components/button"
2
+
3
+ const OnboardingCta = ( { orderId } : { orderId : string } ) => {
4
+ return (
5
+ < div className = "max-w-4xl h-full bg-white w-full mb-4" >
6
+ < div className = "flex flex-col gap-y-6 center p-10 md:items-center" >
7
+ < span className = "text-gray-700 text-xl" >
8
+ Your test order was successfully created! 🎉
9
+ </ span >
10
+ < span className = "text-gray-700 text-small-regular" >
11
+ You can now complete setting up your store in the admin.
12
+ </ span >
13
+ < a
14
+ href = { `http://localhost:7001/a/orders/?order_id=${ orderId } &onboarding_step=setup_finished_nextjs` }
15
+ >
16
+ < Button className = "md:w-80" > Complete setup in admin</ Button >
17
+ </ a >
18
+ </ div >
19
+ </ div >
20
+ )
21
+ }
22
+
23
+ export default OnboardingCta
Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ import Items from "@modules/order/components/items"
6
6
import OrderDetails from "@modules/order/components/order-details"
7
7
import OrderSummary from "@modules/order/components/order-summary"
8
8
import ShippingDetails from "@modules/order/components/shipping-details"
9
- import React from "react"
9
+ import OnboardingCta from "@modules/order/components/onboarding-cta"
10
+ import React , { useEffect , useState } from "react"
10
11
11
12
type OrderCompletedTemplateProps = {
12
13
order : Order
@@ -15,9 +16,17 @@ type OrderCompletedTemplateProps = {
15
16
const OrderCompletedTemplate : React . FC < OrderCompletedTemplateProps > = ( {
16
17
order,
17
18
} ) => {
19
+ const [ isOnboarding , setIsOnboarding ] = useState < boolean > ( false )
20
+
21
+ useEffect ( ( ) => {
22
+ const onboarding = window . sessionStorage . getItem ( "onboarding" )
23
+ setIsOnboarding ( onboarding === "true" )
24
+ } , [ ] )
25
+
18
26
return (
19
27
< div className = "bg-gray-50 py-6 min-h-[calc(100vh-64px)]" >
20
- < div className = "content-container flex justify-center" >
28
+ < div className = "content-container flex flex-col justify-center items-center" >
29
+ { isOnboarding && < OnboardingCta orderId = { order . id } /> }
21
30
< div className = "max-w-4xl h-full bg-white w-full" >
22
31
< OrderDetails order = { order } />
23
32
< Items
You can’t perform that action at this time.
0 commit comments