Fix failed build for local package

Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
Chloe 2022-05-19 11:01:49 +07:00
parent a29bb6fc27
commit cd145b05eb
9 changed files with 80 additions and 84 deletions

View File

@ -7,6 +7,8 @@ export type Category = {
export type Brand = any export type Brand = any
export type Navigation = any
export type SiteTypes = { export type SiteTypes = {
category: Category category: Category
brand: Brand brand: Brand

View File

@ -15,16 +15,16 @@ export type Vendor = {
} }
} }
export type NavigationItem = { export type Navigation = {
url: string url: string
label: string label: string
isUrlRelative: boolean isUrlRelative: boolean
shouldOpenInNewWindow: boolean shouldOpenInNewWindow: boolean
items?: NavigationItem[] items?: Navigation[]
} }
export type SiteTypes = CoreSiteTypes & { export type SiteTypes = CoreSiteTypes & {
navigation: NavigationItem navigation: Navigation
} }
export type GetSiteInfoOperation<T extends SiteTypes = SiteTypes> = { export type GetSiteInfoOperation<T extends SiteTypes = SiteTypes> = {

View File

@ -9,7 +9,7 @@ import {
Category, Category,
Vendor, Vendor,
OCVendor, OCVendor,
NavigationItem, Navigation,
} from '../types/site' } from '../types/site'
import { import {
CatalogItemProduct, CatalogItemProduct,
@ -310,7 +310,7 @@ function normalizeLineItem(cartItemEdge: CartItemEdge): LineItem {
export const normalizeNavigation = ( export const normalizeNavigation = (
navigationTreeItems: NavigationTreeItem[] navigationTreeItems: NavigationTreeItem[]
): NavigationItem[] => { ): Navigation[] => {
return navigationTreeItems.map(({ items, navigationItem: { data } }) => { return navigationTreeItems.map(({ items, navigationItem: { data } }) => {
return { return {
url: data?.url ?? '/', url: data?.url ?? '/',

View File

@ -4,6 +4,21 @@ import SidebarLayout from '@components/common/SidebarLayout'
import { useUI } from '@components/ui/context' import { useUI } from '@components/ui/context'
import { Button } from '@components/ui' import { Button } from '@components/ui'
import { useCheckoutContext } from '../context' 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 ShippingMethod = () => {
const { setSidebarView } = useUI() const { setSidebarView } = useUI()
@ -13,7 +28,7 @@ const ShippingMethod = () => {
const updateShippingMethod = useUpdateUpdateAddress() const updateShippingMethod = useUpdateUpdateAddress()
const shippingGroup = cart?.checkout?.fulfillmentGroups.find( const shippingGroup = cart?.checkout?.fulfillmentGroups.find(
(group) => group?.type === 'shipping' (group: FulfillmentGroup) => group?.type === 'shipping'
) )
const handleSubmit = async (event: React.ChangeEvent<HTMLFormElement>) => { const handleSubmit = async (event: React.ChangeEvent<HTMLFormElement>) => {
@ -40,30 +55,33 @@ const ShippingMethod = () => {
Shipping Methods Shipping Methods
</h2> </h2>
<div> <div>
{shippingGroup.availableFulfillmentOptions.map((option) => ( {shippingGroup.availableFulfillmentOptions.map(
<div (option: FulfillmentOption) => (
className="flex flex-row my-3 items-center justify-between" <div
key={option?.fulfillmentMethod?._id} className="flex flex-row my-3 items-center justify-between"
> key={option?.fulfillmentMethod?._id}
<fieldset className="flex flex-row items-center"> >
<input <fieldset className="flex flex-row items-center">
name="shippingMethod" <input
className="bg-black" name="shippingMethod"
type="radio" className="bg-black"
value={option?.fulfillmentMethod?._id} type="radio"
defaultChecked={ value={option?.fulfillmentMethod?._id}
shippingGroup.selectedFulfillmentOption?.fulfillmentMethod defaultChecked={
?._id === option?.fulfillmentMethod?._id shippingGroup.selectedFulfillmentOption
} ?.fulfillmentMethod?._id ===
/> option?.fulfillmentMethod?._id
<span className="ml-3 text-sm"> }
{option?.fulfillmentMethod?.displayName || />
'Shipping Method'} <span className="ml-3 text-sm">
</span> {option?.fulfillmentMethod?.displayName ||
</fieldset> 'Shipping Method'}
<span>{option?.price.displayAmount}</span> </span>
</div> </fieldset>
))} <span>{option?.price.displayAmount}</span>
</div>
)
)}
</div> </div>
</div> </div>
<div className="sticky z-20 bottom-0 w-full right-0 left-0 py-12 bg-accent-0 border-t border-accent-2 px-6"> <div className="sticky z-20 bottom-0 w-full right-0 left-0 py-12 bg-accent-0 border-t border-accent-2 px-6">

View File

@ -7,7 +7,7 @@ import React, {
createContext, createContext,
} from 'react' } from 'react'
import type { CardFields } from '@commerce/types/customer/card' 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 = { export type State = {
cardFields: CardFields cardFields: CardFields

View File

@ -16,9 +16,8 @@ import ShippingMethodView from '@components/checkout/ShippingMethodView'
import { CheckoutProvider } from '@components/checkout/context' import { CheckoutProvider } from '@components/checkout/context'
import { MenuSidebarView } from '@components/common/UserNav' import { MenuSidebarView } from '@components/common/UserNav'
import type { Page } from '@commerce/types/page' 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 type { Link as LinkProps } from '../UserNav/MenuSidebarView'
import { NavigationItem } from '@framework/types/site'
const Loading = () => ( const Loading = () => (
<div className="w-80 h-80 flex items-center text-center justify-center p-3"> <div className="w-80 h-80 flex items-center text-center justify-center p-3">
@ -54,7 +53,7 @@ interface Props {
pageProps: { pageProps: {
pages?: Page[] pages?: Page[]
categories: Category[] categories: Category[]
navigation: NavigationItem[] navigation: Navigation[]
} }
} }
@ -88,7 +87,8 @@ const SidebarView: React.FC<{
{sidebarView === 'CART_VIEW' && <CartSidebarView />} {sidebarView === 'CART_VIEW' && <CartSidebarView />}
{sidebarView === 'SHIPPING_VIEW' && <ShippingView />} {sidebarView === 'SHIPPING_VIEW' && <ShippingView />}
{sidebarView === 'PAYMENT_VIEW' && <PaymentMethodView />} {sidebarView === 'PAYMENT_VIEW' && <PaymentMethodView />}
{sidebarView === 'SHIPPING_METHOD_VIEW' && <ShippingMethodView />} {process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED &&
sidebarView === 'SHIPPING_METHOD_VIEW' && <ShippingMethodView />}
{sidebarView === 'CHECKOUT_VIEW' && <CheckoutSidebarView />} {sidebarView === 'CHECKOUT_VIEW' && <CheckoutSidebarView />}
{sidebarView === 'MOBILE_MENU_VIEW' && <MenuSidebarView links={links} />} {sidebarView === 'MOBILE_MENU_VIEW' && <MenuSidebarView links={links} />}
</Sidebar> </Sidebar>

View File

@ -1,12 +1,18 @@
import cn from 'clsx' import cn from 'clsx'
import Link from 'next/link' import Link from 'next/link'
import { NavigationItem } from '@framework/types/site'
import s from './Navbar.module.css' import s from './Navbar.module.css'
type Navigation = {
url: string
label: string
isUrlRelative: boolean
shouldOpenInNewWindow: boolean
items?: Navigation[]
}
interface SubItemProps { interface SubItemProps {
subItem: NavigationItem subItem: Navigation
level?: number level?: number
} }
@ -46,7 +52,7 @@ const SubItem = ({ subItem, level = 0 }: SubItemProps) => {
} }
interface CustomNavbarProps { interface CustomNavbarProps {
links?: NavigationItem[] links?: Navigation[]
} }
const CustomNavbar = ({ links = [] }: CustomNavbarProps) => { const CustomNavbar = ({ links = [] }: CustomNavbarProps) => {

View File

@ -5,7 +5,7 @@ import s from './Navbar.module.css'
import NavbarRoot from './NavbarRoot' import NavbarRoot from './NavbarRoot'
import { Logo, Container } from '@components/ui' import { Logo, Container } from '@components/ui'
import { Searchbar, UserNav } from '@components/common' import { Searchbar, UserNav } from '@components/common'
import { SiteTypes } from '@framework/types/site' import { Navigation } from '@commerce/types/site'
import CustomNavbar from './CustomNavbar' import CustomNavbar from './CustomNavbar'
interface Link { interface Link {
@ -15,7 +15,7 @@ interface Link {
interface NavbarProps { interface NavbarProps {
links?: Link[] links?: Link[]
customNavigation?: SiteTypes['navigation'][] customNavigation?: Navigation[]
} }
const Navbar: FC<NavbarProps> = ({ links, customNavigation }) => ( const Navbar: FC<NavbarProps> = ({ links, customNavigation }) => (

View File

@ -3,11 +3,7 @@
"baseUrl": ".", "baseUrl": ".",
"target": "esnext", "target": "esnext",
"module": "esnext", "module": "esnext",
"lib": [ "lib": ["dom", "dom.iterable", "esnext"],
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
@ -20,43 +16,17 @@
"jsx": "preserve", "jsx": "preserve",
"incremental": true, "incremental": true,
"paths": { "paths": {
"@lib/*": [ "@lib/*": ["lib/*"],
"lib/*" "@utils/*": ["utils/*"],
], "@config/*": ["config/*"],
"@utils/*": [ "@assets/*": ["assets/*"],
"utils/*" "@components/*": ["components/*"],
], "@commerce": ["../packages/commerce/src"],
"@config/*": [ "@commerce/*": ["../packages/commerce/src/*"],
"config/*" "@framework": ["../packages/local/src"],
], "@framework/*": ["../packages/local/src/*"]
"@assets/*": [
"assets/*"
],
"@components/*": [
"components/*"
],
"@commerce": [
"../packages/commerce/src"
],
"@commerce/*": [
"../packages/commerce/src/*"
],
"@framework": [
"../packages/local/src"
],
"@framework/*": [
"../packages/local/src/*"
]
} }
}, },
"include": [ "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"next-env.d.ts", "exclude": ["node_modules"]
"**/*.d.ts",
"**/*.ts",
"**/*.tsx",
"**/*.js"
],
"exclude": [
"node_modules"
]
} }