Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ To learn how to use an example, open its `README.md` file. You'll find the detai
| [Product Reviews](./product-reviews/README.md) | Custom Feature | Allow customers to add product reviews, and merchants to manage them. |
| [Quotes Management](./quotes-management/README.md) | Custom Feature | Allow customers to send quotes, and merchants to manage and accept them. |
| [Re-order Feature](./re-order/README.md) | Custom Feature | Allow customers to re-order a previous order. |
| [Request Returns from Storefront](./returns-storefront/README.md) | Storefront | Let custmers request a return of their order from the storefront. |
| [Resend Integration](./resend-integration/README.md) | Integration | Integrate Resend to send notifications in Medusa. |
| [Restaurant Marketplace](./restaurant-marketplace/README.md) | Custom Feature | Build an Uber-Eats clone with Medusa. |
| [Restock Notification](./restock-notification/README.md) | Custom Feature | Allow customers to subscribe to product restock notifications. |
Expand Down
17 changes: 17 additions & 0 deletions returns-storefront/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Your Medusa backend, should be updated to where you are hosting your server. Remember to update CORS settings for your server. See – https://docs.medusajs.com/learn/configurations/medusa-config#httpstorecors
MEDUSA_BACKEND_URL=http://localhost:9000

# Your publishable key that can be attached to sales channels. See - https://docs.medusajs.com/resources/storefront-development/publishable-api-keys
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_test

# Your store URL, should be updated to where you are hosting your storefront.
NEXT_PUBLIC_BASE_URL=http://localhost:8000

# Your preferred default region. When middleware cannot determine the user region from the "x-vercel-country" header, the default region will be used. ISO-2 lowercase format.
NEXT_PUBLIC_DEFAULT_REGION=us

# Your Stripe public key. See – https://docs.medusajs.com/resources/commerce-modules/payment/payment-provider/stripe
NEXT_PUBLIC_STRIPE_KEY=

# Your Next.js revalidation secret. See – https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#on-demand-revalidation
REVALIDATE_SECRET=supersecret
3 changes: 3 additions & 0 deletions returns-storefront/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["next/core-web-vitals"]
};
71 changes: 71 additions & 0 deletions returns-storefront/.github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Bug report for the Medusa Next.js Starter
description: File a bug report.
title: "[Bug]: "
labels: ["status: needs triaging", "bug"]
body:
- type: markdown
attributes:
value: "## System information"
- type: markdown
attributes:
value: |
The system information will help us reproduce the issue in the same environment
- type: textarea
attributes:
label: Package.json file
description: Copy/paste the contents of the `package.json` file. No need to use backticks
placeholder: No need to use markdown backticks. Just copy/paste the contents of the file
render: JSON
validations:
required: true
- type: input
attributes:
label: Node.js version
description: Copy/paste the output of `node -v` command.
placeholder: v21.0.0
validations:
required: true
- type: input
attributes:
label: Operating system name and version
validations:
required: true
- type: input
attributes:
label: Browser name
- type: markdown
attributes:
value: "## Describe the issue"
- type: markdown
attributes:
value: |
Please explain your issue in-depth along with the relevant screenshots and code snippets
- type: textarea
attributes:
label: What happended?
placeholder: A clear and concise description of what the bug is
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
validations:
required: true
- type: textarea
attributes:
label: Actual behavior
validations:
required: true
- type: markdown
attributes:
value: "## Reproduction"
- type: markdown
attributes:
value: |
Providing a reproduction repo allows us to quickly validate the issue and get back to you.
- type: input
attributes:
label: Link to reproduction repo
description: Please reproduce the issue in isolation and share it as a Github repo with us
validations:
required: true
57 changes: 57 additions & 0 deletions returns-storefront/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# IDEs
.idea
.vscode

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

# typescript
*.tsbuildinfo
node_modules

.yarn
.swc
dump.rdb
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
/playwright/.auth
8 changes: 8 additions & 0 deletions returns-storefront/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"arrowParens": "always",
"semi": false,
"endOfLine": "auto",
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
7 changes: 7 additions & 0 deletions returns-storefront/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.2.3.cjs
21 changes: 21 additions & 0 deletions returns-storefront/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Medusa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions returns-storefront/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Medusa v2 Example: Create Returns from Storefront

This directory holds the code for the [Create Returns from Storefront tutorial](https://docs.medusajs.com/resources/nextjs-starter/guides/storefront-returns).

## Prerequisites

This codebase only includes the storefront and doesn't include the Medusa application. Refer to the [documentation](https://docs.medusajs.com/learn/installation) to learn how to install Medusa.

## Installation

1. Clone the repository and change to the `returns-storefront` directory:

```bash
git clone https://github.com/medusajs/examples.git
cd examples/returns-storefront
```

2\. Rename the `.env.template` file to `.env` and set the following variables:

```bash
NEXT_PUBLIC_MEDUSA_BACKEND_URL=
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=
```

Where:

- `NEXT_PUBLIC_MEDUSA_BACKEND_URL` is the URL to your Medusa application server.
- `NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY` is the publishable key for your Medusa application. You can retrieve it form the Medusa Admin by going to Settings > Publishable API Keys.

3\. Install dependencies:

```bash
yarn # or npm install
```

4\. While the Medusa application is running, start the Next.js server:

```bash
yarn dev # or npm run dev
```

The storefront will run at `http://localhost:8000`.

## Tip: Add Next.js Starter Storefront as Upstream

This storefront is cloned from the [Next.js Starter Storefront's repository](https://github.com/medusajs/nextjs-starter-medusa). To make sure your storefront always has the necessary updates that the Medusa team pushes to the starter's repository, it's recommended that you add the repo as an upstream:

```bash
git remote add upstream https://github.com/medusajs/nextjs-starter-medusa.git
```

You can then pull updates from the Next.js Starter Storefront's repository.

## More Resources

- [Medusa Documentation](https://docs.medusajs.com)
- [Next.js Documentation](https://nextjs.org/docs)
39 changes: 39 additions & 0 deletions returns-storefront/check-env-variables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const c = require("ansi-colors")

const requiredEnvs = [
{
key: "NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY",
// TODO: we need a good doc to point this to
description:
"Learn how to create a publishable key: https://docs.medusajs.com/v2/resources/storefront-development/publishable-api-keys",
},
]

function checkEnvVariables() {
const missingEnvs = requiredEnvs.filter(function (env) {
return !process.env[env.key]
})

if (missingEnvs.length > 0) {
console.error(
c.red.bold("\n🚫 Error: Missing required environment variables\n")
)

missingEnvs.forEach(function (env) {
console.error(c.yellow(` ${c.bold(env.key)}`))
if (env.description) {
console.error(c.dim(` ${env.description}\n`))
}
})

console.error(
c.yellow(
"\nPlease set these variables in your .env file or environment before starting the application.\n"
)
)

process.exit(1)
}
}

module.exports = checkEnvVariables
5 changes: 5 additions & 0 deletions returns-storefront/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
19 changes: 19 additions & 0 deletions returns-storefront/next-sitemap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const excludedPaths = ["/checkout", "/account/*"]

module.exports = {
siteUrl: process.env.NEXT_PUBLIC_VERCEL_URL,
generateRobotsTxt: true,
exclude: excludedPaths + ["/[sitemap]"],
robotsTxtOptions: {
policies: [
{
userAgent: "*",
allow: "/",
},
{
userAgent: "*",
disallow: excludedPaths,
},
],
},
}
43 changes: 43 additions & 0 deletions returns-storefront/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const checkEnvVariables = require("./check-env-variables")

checkEnvVariables()

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
reactStrictMode: true,
logging: {
fetches: {
fullUrl: true,
},
},
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
images: {
remotePatterns: [
{
protocol: "http",
hostname: "localhost",
},
{
protocol: "https",
hostname: "medusa-public-images.s3.eu-west-1.amazonaws.com",
},
{
protocol: "https",
hostname: "medusa-server-testing.s3.amazonaws.com",
},
{
protocol: "https",
hostname: "medusa-server-testing.s3.us-east-1.amazonaws.com",
},
],
},
}

module.exports = nextConfig
Loading