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 Navigation = any
export type SiteTypes = {
category: Category
brand: Brand

View File

@ -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<T extends SiteTypes = SiteTypes> = {

View File

@ -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 ?? '/',

View File

@ -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<HTMLFormElement>) => {
@ -40,7 +55,8 @@ const ShippingMethod = () => {
Shipping Methods
</h2>
<div>
{shippingGroup.availableFulfillmentOptions.map((option) => (
{shippingGroup.availableFulfillmentOptions.map(
(option: FulfillmentOption) => (
<div
className="flex flex-row my-3 items-center justify-between"
key={option?.fulfillmentMethod?._id}
@ -52,8 +68,9 @@ const ShippingMethod = () => {
type="radio"
value={option?.fulfillmentMethod?._id}
defaultChecked={
shippingGroup.selectedFulfillmentOption?.fulfillmentMethod
?._id === option?.fulfillmentMethod?._id
shippingGroup.selectedFulfillmentOption
?.fulfillmentMethod?._id ===
option?.fulfillmentMethod?._id
}
/>
<span className="ml-3 text-sm">
@ -63,7 +80,8 @@ const ShippingMethod = () => {
</fieldset>
<span>{option?.price.displayAmount}</span>
</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">

View File

@ -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

View File

@ -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 = () => (
<div className="w-80 h-80 flex items-center text-center justify-center p-3">
@ -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' && <CartSidebarView />}
{sidebarView === 'SHIPPING_VIEW' && <ShippingView />}
{sidebarView === 'PAYMENT_VIEW' && <PaymentMethodView />}
{sidebarView === 'SHIPPING_METHOD_VIEW' && <ShippingMethodView />}
{process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED &&
sidebarView === 'SHIPPING_METHOD_VIEW' && <ShippingMethodView />}
{sidebarView === 'CHECKOUT_VIEW' && <CheckoutSidebarView />}
{sidebarView === 'MOBILE_MENU_VIEW' && <MenuSidebarView links={links} />}
</Sidebar>

View File

@ -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) => {

View File

@ -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<NavbarProps> = ({ links, customNavigation }) => (

View File

@ -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"
]
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": ["node_modules"]
}