mirror of
https://github.com/vercel/commerce.git
synced 2025-05-13 05:07:51 +00:00
feat(main): refactoring
This commit is contained in:
parent
bc23896efc
commit
4d28219362
@ -1,9 +1,9 @@
|
|||||||
import Navbar from 'components/layout/navbar';
|
import Navbar from 'components/layout/navbar';
|
||||||
import { GeistSans } from 'geist/font';
|
import { GeistSans } from 'geist/font';
|
||||||
|
import ShopifyAnalytics from 'components/layout/shopify-analytics';
|
||||||
import { ensureStartsWith } from 'lib/utils';
|
import { ensureStartsWith } from 'lib/utils';
|
||||||
import { ReactNode, Suspense } from 'react';
|
import { ReactNode, Suspense } from 'react';
|
||||||
import './globals.css';
|
import './globals.css';
|
||||||
import ShopifyAnalytics from 'components/layout/shopify-analytics';
|
|
||||||
|
|
||||||
const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env;
|
const { TWITTER_CREATOR, TWITTER_SITE, SITE_NAME } = process.env;
|
||||||
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
|
const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL
|
||||||
|
@ -5,7 +5,7 @@ import { addToCart, createCart, getCart, removeFromCart, updateCart } from 'lib/
|
|||||||
import { revalidateTag } from 'next/cache';
|
import { revalidateTag } from 'next/cache';
|
||||||
import { cookies } from 'next/headers';
|
import { cookies } from 'next/headers';
|
||||||
import { ShopifyAnalyticsProduct } from '@shopify/hydrogen-react';
|
import { ShopifyAnalyticsProduct } from '@shopify/hydrogen-react';
|
||||||
import { productToAnalytics } from '../../lib/utils';
|
import { productToAnalytics } from 'lib/utils';
|
||||||
|
|
||||||
type AddItemResponse = {
|
type AddItemResponse = {
|
||||||
cartId?: string;
|
cartId?: string;
|
||||||
|
@ -8,7 +8,7 @@ import { ProductVariant } from 'lib/shopify/types';
|
|||||||
import { useSearchParams } from 'next/navigation';
|
import { useSearchParams } from 'next/navigation';
|
||||||
import { useFormState, useFormStatus } from 'react-dom';
|
import { useFormState, useFormStatus } from 'react-dom';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useShopifyAnalytics } from '../../lib/shopify/hooks/use-shopify-analytics';
|
import { useShopifyAnalytics } from 'lib/shopify/hooks/use-shopify-analytics';
|
||||||
|
|
||||||
function SubmitButton({
|
function SubmitButton({
|
||||||
availableForSale,
|
availableForSale,
|
||||||
|
@ -30,7 +30,7 @@ export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden';
|
|||||||
export const DEFAULT_OPTION = 'Default Title';
|
export const DEFAULT_OPTION = 'Default Title';
|
||||||
export const SHOPIFY_GRAPHQL_API_ENDPOINT = '/api/2023-01/graphql.json';
|
export const SHOPIFY_GRAPHQL_API_ENDPOINT = '/api/2023-01/graphql.json';
|
||||||
|
|
||||||
export const currency = 'AED';
|
export const DEFAULT_CURRENCY = 'AED';
|
||||||
|
|
||||||
// use your logic to get language
|
// use your logic to get language
|
||||||
export const defaultLanguage = 'EN';
|
export const DEFAULT_LANGUAGE = 'EN';
|
||||||
|
@ -8,7 +8,7 @@ import {
|
|||||||
ShopifySalesChannel,
|
ShopifySalesChannel,
|
||||||
useShopifyCookies
|
useShopifyCookies
|
||||||
} from '@shopify/hydrogen-react';
|
} from '@shopify/hydrogen-react';
|
||||||
import { currency, defaultLanguage } from 'lib/constants';
|
import { DEFAULT_CURRENCY, DEFAULT_LANGUAGE } from 'lib/constants';
|
||||||
|
|
||||||
const SHOP_ID = process.env.NEXT_PUBLIC_SHOPIFY_SHOP_ID!;
|
const SHOP_ID = process.env.NEXT_PUBLIC_SHOPIFY_SHOP_ID!;
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ export function useShopifyAnalytics() {
|
|||||||
hasUserConsent: true,
|
hasUserConsent: true,
|
||||||
shopifySalesChannel: ShopifySalesChannel.headless,
|
shopifySalesChannel: ShopifySalesChannel.headless,
|
||||||
shopId: `gid://shopify/Shop/${SHOP_ID}`,
|
shopId: `gid://shopify/Shop/${SHOP_ID}`,
|
||||||
currency,
|
currency: DEFAULT_CURRENCY,
|
||||||
acceptedLanguage: defaultLanguage,
|
acceptedLanguage: DEFAULT_LANGUAGE,
|
||||||
...payload
|
...payload
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user