Skip to content

Commit 4945449

Browse files
authored
Merge pull request #172 from medusajs/feat/onboarding
feat: add onboarding CTA to product page
2 parents 29e8b3f + f13af0b commit 4945449

File tree

8 files changed

+40
-10
lines changed

8 files changed

+40
-10
lines changed

src/app/api/categories/[category]/[subcategory]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type ProductCategoryResponse = ProductCategoryDTO & {
1111

1212
/**
1313
* This endpoint uses the serverless Product Module to retrieve a category and its products by handle.
14-
* The module connects directly to you Medusa database to retrieve and manipulate data, without the need for a dedicated server.
14+
* The module connects directly to your Medusa database to retrieve and manipulate data, without the need for a dedicated server.
1515
* Read more about the Product Module here: https://docs.medusajs.com/modules/products/serverless-module
1616
*/
1717
export async function GET(

src/app/api/categories/route.ts

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

55
/**
66
* This endpoint uses the serverless Product Module to list and count all product categories.
7-
* The module connects directly to you Medusa database to retrieve and manipulate data, without the need for a dedicated server.
7+
* The module connects directly to your Medusa database to retrieve and manipulate data, without the need for a dedicated server.
88
* Read more about the Product Module here: https://docs.medusajs.com/modules/products/serverless-module
99
*/
1010
export async function GET(request: NextRequest) {

src/app/api/collections/[handle]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import getPrices from "@lib/util/get-product-prices"
66

77
/**
88
* This endpoint uses the serverless Product Module to retrieve a collection and its products by handle.
9-
* The module connects directly to you Medusa database to retrieve and manipulate data, without the need for a dedicated server.
9+
* The module connects directly to your Medusa database to retrieve and manipulate data, without the need for a dedicated server.
1010
* Read more about the Product Module here: https://docs.medusajs.com/modules/products/serverless-module
1111
*/
1212
export async function GET(

src/app/api/collections/route.ts

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

55
/**
66
* This endpoint uses the serverless Product Module to list and count all product collections.
7-
* The module connects directly to you Medusa database to retrieve and manipulate data, without the need for a dedicated server.
7+
* The module connects directly to your Medusa database to retrieve and manipulate data, without the need for a dedicated server.
88
* Read more about the Product Module here: https://docs.medusajs.com/modules/products/serverless-module
99
*/
1010
export async function GET(request: NextRequest) {

src/app/api/products/[handle]/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { initialize as initializeProductModule } from "@medusajs/product"
55

66
/**
77
* This endpoint uses the serverless Product Module to retrieve a product by handle.
8-
* The module connects directly to you Medusa database to retrieve and manipulate data, without the need for a dedicated server.
8+
* The module connects directly to your Medusa database to retrieve and manipulate data, without the need for a dedicated server.
99
* Read more about the Product Module here: https://docs.medusajs.com/modules/products/serverless-module
1010
*/
1111
export async function GET(

src/app/api/products/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { notFound } from "next/navigation"
1111

1212
/**
1313
* This endpoint uses the serverless Product Module to retrieve a list of products.
14-
* The module connects directly to you Medusa database to retrieve and manipulate data, without the need for a dedicated server.
14+
* The module connects directly to your Medusa database to retrieve and manipulate data, without the need for a dedicated server.
1515
* Read more about the Product Module here: https://docs.medusajs.com/modules/products/serverless-module
1616
*/
1717
export async function GET(request: NextRequest) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Button from "@modules/common/components/button"
2+
3+
const ProductOnboardingCta = () => {
4+
return (
5+
<div className="max-w-4xl h-full bg-gray-100 w-full mb-4 p-8">
6+
<div className="flex flex-col gap-y-6 center">
7+
<span className="text-gray-700 text-xl">
8+
Your demo product was successfully created! 🎉
9+
</span>
10+
<span className="text-gray-700 text-small-regular">
11+
You can now continue setting up your store in the admin.
12+
</span>
13+
<a href="http://localhost:7001/a/orders?onboarding_step=create_order_nextjs">
14+
<Button className="md:w-80">Continue setup in admin</Button>
15+
</a>
16+
</div>
17+
</div>
18+
)
19+
}
20+
21+
export default ProductOnboardingCta

src/modules/products/templates/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
11
"use client"
22

3+
import React, { useEffect, useRef, useState } from "react"
34
import { ProductProvider } from "@lib/context/product-context"
45
import { useIntersection } from "@lib/hooks/use-in-view"
6+
import ProductInfo from "@modules/products/templates/product-info"
57
import ProductTabs from "@modules/products/components/product-tabs"
68
import RelatedProducts from "@modules/products/components/related-products"
7-
import ProductInfo from "@modules/products/templates/product-info"
8-
import React, { useRef } from "react"
9-
import ImageGallery from "../components/image-gallary"
10-
import MobileActions from "../components/mobile-actions"
9+
import ImageGallery from "@modules/products/components/image-gallary"
10+
import MobileActions from "@modules/products/components/mobile-actions"
11+
import ProductOnboardingCta from "@modules/products/components/product-onboarding-cta"
1112
import { PricedProduct } from "@medusajs/medusa/dist/types/pricing"
1213

1314
type ProductTemplateProps = {
1415
product: PricedProduct
1516
}
1617

1718
const ProductTemplate: React.FC<ProductTemplateProps> = ({ product }) => {
19+
const [isOnboarding, setIsOnboarding] = useState<boolean>(false)
20+
1821
const info = useRef<HTMLDivElement>(null)
1922

2023
const inView = useIntersection(info, "0px")
2124

25+
useEffect(() => {
26+
const onboarding = window.sessionStorage.getItem("onboarding")
27+
setIsOnboarding(onboarding === "true")
28+
}, [])
29+
2230
return (
2331
<ProductProvider product={product}>
2432
<div className="content-container flex flex-col small:flex-row small:items-start py-6 relative">
@@ -29,6 +37,7 @@ const ProductTemplate: React.FC<ProductTemplateProps> = ({ product }) => {
2937
className="small:sticky small:top-20 w-full py-8 small:py-0 small:max-w-[344px] medium:max-w-[400px] flex flex-col gap-y-12"
3038
ref={info}
3139
>
40+
{isOnboarding && <ProductOnboardingCta />}
3241
<ProductInfo product={product} />
3342
<ProductTabs product={product} />
3443
</div>

0 commit comments

Comments
 (0)