diff --git a/packages/commerce/src/types/site.ts b/packages/commerce/src/types/site.ts index 73c7dddd2..7223c99d4 100644 --- a/packages/commerce/src/types/site.ts +++ b/packages/commerce/src/types/site.ts @@ -7,6 +7,8 @@ export type Category = { export type Brand = any +export type Navigation = any + export type SiteTypes = { category: Category brand: Brand diff --git a/packages/opencommerce/src/types/site.ts b/packages/opencommerce/src/types/site.ts index e399f9af9..b0c7334cb 100644 --- a/packages/opencommerce/src/types/site.ts +++ b/packages/opencommerce/src/types/site.ts @@ -15,16 +15,16 @@ export type Vendor = { } } -export type NavigationItem = { +export type Navigation = { url: string label: string isUrlRelative: boolean shouldOpenInNewWindow: boolean - items?: NavigationItem[] + items?: Navigation[] } export type SiteTypes = CoreSiteTypes & { - navigation: NavigationItem + navigation: Navigation } export type GetSiteInfoOperation = { diff --git a/packages/opencommerce/src/utils/normalize.ts b/packages/opencommerce/src/utils/normalize.ts index 4bde65272..2d7a88103 100644 --- a/packages/opencommerce/src/utils/normalize.ts +++ b/packages/opencommerce/src/utils/normalize.ts @@ -9,7 +9,7 @@ import { Category, Vendor, OCVendor, - NavigationItem, + Navigation, } from '../types/site' import { CatalogItemProduct, @@ -310,7 +310,7 @@ function normalizeLineItem(cartItemEdge: CartItemEdge): LineItem { export const normalizeNavigation = ( navigationTreeItems: NavigationTreeItem[] -): NavigationItem[] => { +): Navigation[] => { return navigationTreeItems.map(({ items, navigationItem: { data } }) => { return { url: data?.url ?? '/', diff --git a/site/components/checkout/ShippingMethodView/ShippingMethodView.tsx b/site/components/checkout/ShippingMethodView/ShippingMethodView.tsx index 21c73fde2..ca0bde53b 100644 --- a/site/components/checkout/ShippingMethodView/ShippingMethodView.tsx +++ b/site/components/checkout/ShippingMethodView/ShippingMethodView.tsx @@ -4,6 +4,21 @@ import SidebarLayout from '@components/common/SidebarLayout' import { useUI } from '@components/ui/context' import { Button } from '@components/ui' import { useCheckoutContext } from '../context' +import { Key, ReactChild, ReactFragment, ReactPortal } from 'react' + +type FulfillmentGroup = { + type: string +} + +type FulfillmentOption = { + fulfillmentMethod: { + _id: string + displayName: string + } + price: { + displayAmount: string + } +} const ShippingMethod = () => { const { setSidebarView } = useUI() @@ -13,7 +28,7 @@ const ShippingMethod = () => { const updateShippingMethod = useUpdateUpdateAddress() const shippingGroup = cart?.checkout?.fulfillmentGroups.find( - (group) => group?.type === 'shipping' + (group: FulfillmentGroup) => group?.type === 'shipping' ) const handleSubmit = async (event: React.ChangeEvent) => { @@ -40,30 +55,33 @@ const ShippingMethod = () => { Shipping Methods
- {shippingGroup.availableFulfillmentOptions.map((option) => ( -
-
- - - {option?.fulfillmentMethod?.displayName || - 'Shipping Method'} - -
- {option?.price.displayAmount} -
- ))} + {shippingGroup.availableFulfillmentOptions.map( + (option: FulfillmentOption) => ( +
+
+ + + {option?.fulfillmentMethod?.displayName || + 'Shipping Method'} + +
+ {option?.price.displayAmount} +
+ ) + )}
diff --git a/site/components/checkout/context.tsx b/site/components/checkout/context.tsx index 5287f2603..02b67541a 100644 --- a/site/components/checkout/context.tsx +++ b/site/components/checkout/context.tsx @@ -7,7 +7,7 @@ import React, { createContext, } from 'react' import type { CardFields } from '@commerce/types/customer/card' -import type { AddressFields } from '@framework/types/customer/address' +import type { AddressFields } from '@commerce/types/customer/address' export type State = { cardFields: CardFields diff --git a/site/components/common/Layout/Layout.tsx b/site/components/common/Layout/Layout.tsx index 914fc111e..c59a495f4 100644 --- a/site/components/common/Layout/Layout.tsx +++ b/site/components/common/Layout/Layout.tsx @@ -16,9 +16,8 @@ import ShippingMethodView from '@components/checkout/ShippingMethodView' import { CheckoutProvider } from '@components/checkout/context' import { MenuSidebarView } from '@components/common/UserNav' import type { Page } from '@commerce/types/page' -import type { Category } from '@commerce/types/site' +import type { Category, Navigation } from '@commerce/types/site' import type { Link as LinkProps } from '../UserNav/MenuSidebarView' -import { NavigationItem } from '@framework/types/site' const Loading = () => (
@@ -54,7 +53,7 @@ interface Props { pageProps: { pages?: Page[] categories: Category[] - navigation: NavigationItem[] + navigation: Navigation[] } } @@ -88,7 +87,8 @@ const SidebarView: React.FC<{ {sidebarView === 'CART_VIEW' && } {sidebarView === 'SHIPPING_VIEW' && } {sidebarView === 'PAYMENT_VIEW' && } - {sidebarView === 'SHIPPING_METHOD_VIEW' && } + {process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED && + sidebarView === 'SHIPPING_METHOD_VIEW' && } {sidebarView === 'CHECKOUT_VIEW' && } {sidebarView === 'MOBILE_MENU_VIEW' && } diff --git a/site/components/common/Navbar/CustomNavbar.tsx b/site/components/common/Navbar/CustomNavbar.tsx index 57e49b763..e69a0a956 100644 --- a/site/components/common/Navbar/CustomNavbar.tsx +++ b/site/components/common/Navbar/CustomNavbar.tsx @@ -1,12 +1,18 @@ import cn from 'clsx' import Link from 'next/link' -import { NavigationItem } from '@framework/types/site' - import s from './Navbar.module.css' +type Navigation = { + url: string + label: string + isUrlRelative: boolean + shouldOpenInNewWindow: boolean + items?: Navigation[] +} + interface SubItemProps { - subItem: NavigationItem + subItem: Navigation level?: number } @@ -46,7 +52,7 @@ const SubItem = ({ subItem, level = 0 }: SubItemProps) => { } interface CustomNavbarProps { - links?: NavigationItem[] + links?: Navigation[] } const CustomNavbar = ({ links = [] }: CustomNavbarProps) => { diff --git a/site/components/common/Navbar/Navbar.tsx b/site/components/common/Navbar/Navbar.tsx index 13f5bf685..1b5419fab 100644 --- a/site/components/common/Navbar/Navbar.tsx +++ b/site/components/common/Navbar/Navbar.tsx @@ -5,7 +5,7 @@ import s from './Navbar.module.css' import NavbarRoot from './NavbarRoot' import { Logo, Container } from '@components/ui' import { Searchbar, UserNav } from '@components/common' -import { SiteTypes } from '@framework/types/site' +import { Navigation } from '@commerce/types/site' import CustomNavbar from './CustomNavbar' interface Link { @@ -15,7 +15,7 @@ interface Link { interface NavbarProps { links?: Link[] - customNavigation?: SiteTypes['navigation'][] + customNavigation?: Navigation[] } const Navbar: FC = ({ links, customNavigation }) => ( diff --git a/site/tsconfig.json b/site/tsconfig.json index 652a8edab..7c91afd6f 100644 --- a/site/tsconfig.json +++ b/site/tsconfig.json @@ -3,11 +3,7 @@ "baseUrl": ".", "target": "esnext", "module": "esnext", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -20,43 +16,17 @@ "jsx": "preserve", "incremental": true, "paths": { - "@lib/*": [ - "lib/*" - ], - "@utils/*": [ - "utils/*" - ], - "@config/*": [ - "config/*" - ], - "@assets/*": [ - "assets/*" - ], - "@components/*": [ - "components/*" - ], - "@commerce": [ - "../packages/commerce/src" - ], - "@commerce/*": [ - "../packages/commerce/src/*" - ], - "@framework": [ - "../packages/local/src" - ], - "@framework/*": [ - "../packages/local/src/*" - ] + "@lib/*": ["lib/*"], + "@utils/*": ["utils/*"], + "@config/*": ["config/*"], + "@assets/*": ["assets/*"], + "@components/*": ["components/*"], + "@commerce": ["../packages/commerce/src"], + "@commerce/*": ["../packages/commerce/src/*"], + "@framework": ["../packages/local/src"], + "@framework/*": ["../packages/local/src/*"] } }, - "include": [ - "next-env.d.ts", - "**/*.d.ts", - "**/*.ts", - "**/*.tsx", - "**/*.js" - ], - "exclude": [ - "node_modules" - ] -} \ No newline at end of file + "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"], + "exclude": ["node_modules"] +}