From b0f6e94fbaa14ea78b11bd162b8cdea3a7d5c0d1 Mon Sep 17 00:00:00 2001 From: Netanel Gilad Date: Mon, 18 Sep 2023 17:56:16 +0300 Subject: [PATCH 1/4] Adds Wix provider (#1195) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b4cff7612..5816f61e6 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Vercel is happy to partner and work with any commerce provider to help them get - [Shopware](https://github.com/shopwareLabs/vercel-commerce) ([Demo](https://shopware-vercel-commerce-react.vercel.app/)) - [Swell](https://github.com/swellstores/verswell-commerce) ([Demo](https://verswell-commerce.vercel.app/)) - [Umbraco](https://github.com/umbraco/Umbraco.VercelCommerce.Demo) ([Demo](https://vercel-commerce-demo.umbraco.com/)) +- [Wix](https://github.com/wix/nextjs-commerce) ([Demo](https://wix-nextjs-commerce.vercel.app/)) > Note: Providers, if you are looking to use similar products for your demo, you can [download these assets](https://drive.google.com/file/d/1q_bKerjrwZgHwCw0ovfUMW6He9VtepO_/view?usp=sharing). From d9f875b5391129444e7ff5fedc4118993632759d Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Mon, 18 Sep 2023 15:25:03 -0500 Subject: [PATCH 2/4] Removes unnecessary search state (#1201) --- components/layout/navbar/search.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/components/layout/navbar/search.tsx b/components/layout/navbar/search.tsx index c7a410b9d..57032a035 100644 --- a/components/layout/navbar/search.tsx +++ b/components/layout/navbar/search.tsx @@ -1,19 +1,12 @@ 'use client'; -import { useRouter, useSearchParams } from 'next/navigation'; -import { useEffect, useState } from 'react'; - import { MagnifyingGlassIcon } from '@heroicons/react/24/outline'; import { createUrl } from 'lib/utils'; +import { useRouter, useSearchParams } from 'next/navigation'; export default function Search() { const router = useRouter(); const searchParams = useSearchParams(); - const [searchValue, setSearchValue] = useState(''); - - useEffect(() => { - setSearchValue(searchParams?.get('q') || ''); - }, [searchParams, setSearchValue]); function onSubmit(e: React.FormEvent) { e.preventDefault(); @@ -38,8 +31,7 @@ export default function Search() { name="search" placeholder="Search for products..." autoComplete="off" - value={searchValue} - onChange={(e) => setSearchValue(e.target.value)} + defaultValue={searchParams?.get('q') || ''} className="w-full rounded-lg border bg-white px-4 py-2 text-sm text-black placeholder:text-neutral-500 dark:border-neutral-800 dark:bg-transparent dark:text-white dark:placeholder:text-neutral-400" />
From 5cb1245432c9f188471ccbf2d36e7a892a4ac33d Mon Sep 17 00:00:00 2001 From: Michael Novotny Date: Mon, 2 Oct 2023 10:18:56 -0500 Subject: [PATCH 3/4] Adds environment variable validation (#1198) * Adds environment variable validation * Adds bracket checking in SHOPIFY_STORE_DOMAIN * Prettier * Adds link --------- Co-authored-by: Lee Robinson --- app/sitemap.ts | 3 +++ lib/utils.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/app/sitemap.ts b/app/sitemap.ts index 46d39669c..fe8ed96ac 100644 --- a/app/sitemap.ts +++ b/app/sitemap.ts @@ -1,4 +1,5 @@ import { getCollections, getPages, getProducts } from 'lib/shopify'; +import { validateEnvironmentVariables } from 'lib/utils'; import { MetadataRoute } from 'next'; type Route = { @@ -11,6 +12,8 @@ const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL : 'http://localhost:3000'; export default async function sitemap(): Promise { + validateEnvironmentVariables(); + const routesMap = [''].map((route) => ({ url: `${baseUrl}${route}`, lastModified: new Date().toISOString() diff --git a/lib/utils.ts b/lib/utils.ts index 02ff6fe1b..69b76d29b 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -9,3 +9,31 @@ export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyUR export const ensureStartsWith = (stringToCheck: string, startsWith: string) => stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`; + +export const validateEnvironmentVariables = () => { + const requiredEnvironmentVariables = ['SHOPIFY_STORE_DOMAIN', 'SHOPIFY_STOREFRONT_ACCESS_TOKEN']; + const missingEnvironmentVariables = [] as string[]; + + requiredEnvironmentVariables.forEach((envVar) => { + if (!process.env[envVar]) { + missingEnvironmentVariables.push(envVar); + } + }); + + if (missingEnvironmentVariables.length) { + throw new Error( + `The following environment variables are missing. Your site will not work without them. Read more: https://vercel.com/docs/integrations/shopify#configure-environment-variables\n\n${missingEnvironmentVariables.join( + '\n' + )}\n` + ); + } + + if ( + process.env.SHOPIFY_STORE_DOMAIN?.includes('[') || + process.env.SHOPIFY_STORE_DOMAIN?.includes(']') + ) { + throw new Error( + 'Your `SHOPIFY_STORE_DOMAIN` environment variable includes brackets (ie. `[` and / or `]`). Your site will not work with them there. Please remove them.' + ); + } +}; From 2035fa0431251908fb3dfb42c3d424dfa1dec0e0 Mon Sep 17 00:00:00 2001 From: Tucker Massad Date: Fri, 6 Oct 2023 10:28:14 -0400 Subject: [PATCH 4/4] Fixes pnpm typo in README (#1215) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5816f61e6..838cd1a04 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Your app should now be running on [localhost:3000](http://localhost:3000/). 1. Select the `Vercel Solutions` scope. 1. Connect to the existing `commerce-shopify` project. 1. Run `vc env pull` to get environment variables. -1. Run `pmpm dev` to ensure everything is working correctly. +1. Run `pnpm dev` to ensure everything is working correctly. ## Vercel, Next.js Commerce, and Shopify Integration Guide