mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
Merge branch 'common' of https://github.com/KieIO/grocery-vercel-commerce into m6-quangnhanupdate
This commit is contained in:
3
next-env.d.ts
vendored
3
next-env.d.ts
vendored
@@ -1,6 +1,3 @@
|
|||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/types/global" />
|
/// <reference types="next/types/global" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
|
||||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
"dev": "NODE_OPTIONS='--inspect' PORT=3005 next dev",
|
"dev": "NODE_OPTIONS='--inspect' PORT=3005 next dev",
|
||||||
"dev-windows": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
"dev-windows": "set NODE_OPTIONS='--inspect' && set PORT=3005 && next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "PORT=3005 next start",
|
||||||
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
||||||
"prettier-fix": "prettier --write .",
|
"prettier-fix": "prettier --write .",
|
||||||
"find:unused": "npx next-unused",
|
"find:unused": "npx next-unused",
|
||||||
|
@@ -1,12 +0,0 @@
|
|||||||
import { } from "src/components/modules/404"
|
|
||||||
import { Layout } from 'src/components/common'
|
|
||||||
import { ErrorPage } from "src/components/modules/error"
|
|
||||||
|
|
||||||
export default function Error() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<ErrorPage/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Error.Layout = Layout
|
|
13
pages/account.tsx
Normal file
13
pages/account.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Layout } from 'src/components/common';
|
||||||
|
import { AccountPage } from 'src/components/modules/account';
|
||||||
|
|
||||||
|
const Account = () => {
|
||||||
|
return (
|
||||||
|
<AccountPage/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Account.Layout = Layout
|
||||||
|
|
||||||
|
export default Account;
|
@@ -2,6 +2,7 @@ import classNames from 'classnames'
|
|||||||
import React, { memo, useEffect, useMemo, useRef, useState } from 'react'
|
import React, { memo, useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { useModalCommon } from 'src/components/hooks'
|
import { useModalCommon } from 'src/components/hooks'
|
||||||
import { isMobile } from 'src/utils/funtion.utils'
|
import { isMobile } from 'src/utils/funtion.utils'
|
||||||
|
import { CartDrawer } from '..'
|
||||||
import ModalAuthenticate from '../ModalAuthenticate/ModalAuthenticate'
|
import ModalAuthenticate from '../ModalAuthenticate/ModalAuthenticate'
|
||||||
import ModalCreateUserInfo from '../ModalCreateUserInfo/ModalCreateUserInfo'
|
import ModalCreateUserInfo from '../ModalCreateUserInfo/ModalCreateUserInfo'
|
||||||
import HeaderHighLight from './components/HeaderHighLight/HeaderHighLight'
|
import HeaderHighLight from './components/HeaderHighLight/HeaderHighLight'
|
||||||
@@ -10,14 +11,23 @@ import HeaderSubMenu from './components/HeaderSubMenu/HeaderSubMenu'
|
|||||||
import HeaderSubMenuMobile from './components/HeaderSubMenuMobile/HeaderSubMenuMobile'
|
import HeaderSubMenuMobile from './components/HeaderSubMenuMobile/HeaderSubMenuMobile'
|
||||||
import s from './Header.module.scss'
|
import s from './Header.module.scss'
|
||||||
interface props {
|
interface props {
|
||||||
toggleFilter:()=>void
|
toggleFilter: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const Header = memo(({toggleFilter}:props) => {
|
const Header = memo(({ toggleFilter }: props) => {
|
||||||
const headeFullRef = useRef<HTMLDivElement>(null)
|
const headeFullRef = useRef<HTMLDivElement>(null)
|
||||||
const [isFullHeader, setIsFullHeader] = useState<boolean>(true)
|
const [isFullHeader, setIsFullHeader] = useState<boolean>(true)
|
||||||
const { visible: visibleModalAuthen, closeModal: closeModalAuthen, openModal: openModalAuthen } = useModalCommon({ initialValue: false })
|
const { visible: visibleModalAuthen, closeModal: closeModalAuthen, openModal: openModalAuthen } = useModalCommon({ initialValue: false })
|
||||||
const { visible: visibleModalInfo, closeModal: closeModalInfo, openModal: openModalInfo } = useModalCommon({ initialValue: false })
|
const { visible: visibleModalInfo, closeModal: closeModalInfo, openModal: openModalInfo } = useModalCommon({ initialValue: false })
|
||||||
|
const { visible: visibleCartDrawer, openModal: openCartDrawer, closeModal: closeCartDrawer } = useModalCommon({ initialValue: false })
|
||||||
|
|
||||||
|
const toggleCart = () => {
|
||||||
|
if (visibleCartDrawer) {
|
||||||
|
closeCartDrawer()
|
||||||
|
} else {
|
||||||
|
openCartDrawer()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const headerHeight = useMemo(() => {
|
const headerHeight = useMemo(() => {
|
||||||
return headeFullRef.current?.offsetHeight
|
return headeFullRef.current?.offsetHeight
|
||||||
@@ -46,6 +56,7 @@ const Header = memo(({toggleFilter}:props) => {
|
|||||||
<div className={s.menu}>
|
<div className={s.menu}>
|
||||||
<HeaderMenu
|
<HeaderMenu
|
||||||
toggleFilter={toggleFilter}
|
toggleFilter={toggleFilter}
|
||||||
|
toggleCart={toggleCart}
|
||||||
isFull={isFullHeader}
|
isFull={isFullHeader}
|
||||||
openModalAuthen={openModalAuthen}
|
openModalAuthen={openModalAuthen}
|
||||||
openModalInfo={openModalInfo} />
|
openModalInfo={openModalInfo} />
|
||||||
@@ -60,6 +71,7 @@ const Header = memo(({toggleFilter}:props) => {
|
|||||||
})}>
|
})}>
|
||||||
<HeaderMenu isFull={isFullHeader}
|
<HeaderMenu isFull={isFullHeader}
|
||||||
toggleFilter={toggleFilter}
|
toggleFilter={toggleFilter}
|
||||||
|
toggleCart={toggleCart}
|
||||||
openModalAuthen={openModalAuthen}
|
openModalAuthen={openModalAuthen}
|
||||||
openModalInfo={openModalInfo} />
|
openModalInfo={openModalInfo} />
|
||||||
</div>
|
</div>
|
||||||
@@ -67,6 +79,9 @@ const Header = memo(({toggleFilter}:props) => {
|
|||||||
<HeaderSubMenuMobile />
|
<HeaderSubMenuMobile />
|
||||||
<ModalAuthenticate visible={visibleModalAuthen} closeModal={closeModalAuthen} />
|
<ModalAuthenticate visible={visibleModalAuthen} closeModal={closeModalAuthen} />
|
||||||
<ModalCreateUserInfo demoVisible={visibleModalInfo} demoCloseModal={closeModalInfo} />
|
<ModalCreateUserInfo demoVisible={visibleModalInfo} demoCloseModal={closeModalInfo} />
|
||||||
|
<CartDrawer
|
||||||
|
visible={visibleCartDrawer}
|
||||||
|
onClose={closeCartDrawer} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
@@ -14,11 +14,12 @@ interface Props {
|
|||||||
openModalAuthen: () => void,
|
openModalAuthen: () => void,
|
||||||
openModalInfo: () => void,
|
openModalInfo: () => void,
|
||||||
toggleFilter:() => void,
|
toggleFilter:() => void,
|
||||||
|
toggleCart:() => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
const FILTER_PAGE = [ROUTE.HOME,ROUTE.PRODUCTS]
|
const FILTER_PAGE = [ROUTE.HOME,ROUTE.PRODUCTS]
|
||||||
|
|
||||||
const HeaderMenu = memo(({ isFull, openModalAuthen, openModalInfo, toggleFilter }: Props) => {
|
const HeaderMenu = memo(({ isFull, openModalAuthen, openModalInfo, toggleFilter, toggleCart }: Props) => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const optionMenu = useMemo(() => [
|
const optionMenu = useMemo(() => [
|
||||||
{
|
{
|
||||||
@@ -81,7 +82,7 @@ const HeaderMenu = memo(({ isFull, openModalAuthen, openModalInfo, toggleFilter
|
|||||||
<MenuDropdown options={optionMenu} isHasArrow={false}><IconUser /></MenuDropdown>
|
<MenuDropdown options={optionMenu} isHasArrow={false}><IconUser /></MenuDropdown>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<button className={s.btnCart}>
|
<button className={s.btnCart} onClick={toggleCart}>
|
||||||
<IconBuy />
|
<IconBuy />
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
import { CommerceProvider } from '@framework'
|
import { CommerceProvider } from '@framework'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import { FilterProvider } from 'src/components/contexts/FilterContext'
|
|
||||||
import { useModalCommon } from 'src/components/hooks'
|
import { useModalCommon } from 'src/components/hooks'
|
||||||
import { BRAND, CATEGORY, FEATURED } from 'src/utils/constanst.utils'
|
import { BRAND, CATEGORY, FEATURED } from 'src/utils/constanst.utils'
|
||||||
import { CartDrawer, CustomShapeSvg } from '..'
|
import { CustomShapeSvg } from '..'
|
||||||
import Footer from '../Footer/Footer'
|
import Footer from '../Footer/Footer'
|
||||||
import Header from '../Header/Header'
|
import Header from '../Header/Header'
|
||||||
import MenuNavigationProductList from '../MenuNavigationProductList/MenuNavigationProductList'
|
import MenuNavigationProductList from '../MenuNavigationProductList/MenuNavigationProductList'
|
||||||
@@ -18,18 +17,9 @@ interface Props {
|
|||||||
// note: demo code
|
// note: demo code
|
||||||
const Layout: FC<Props> = ({ children }) => {
|
const Layout: FC<Props> = ({ children }) => {
|
||||||
const { locale = 'en-US' } = useRouter()
|
const { locale = 'en-US' } = useRouter()
|
||||||
const { visible: visibleCartDrawer, openModal, closeModal: closeCartDrawer } = useModalCommon({ initialValue: false })
|
|
||||||
const { visible: visibleFilter, openModal: openFilter, closeModal: closeFilter } = useModalCommon({ initialValue: false })
|
const { visible: visibleFilter, openModal: openFilter, closeModal: closeFilter } = useModalCommon({ initialValue: false })
|
||||||
|
|
||||||
const toggle = () => {
|
|
||||||
if (visibleCartDrawer) {
|
|
||||||
closeCartDrawer()
|
|
||||||
} else {
|
|
||||||
openModal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const toggleFilter = () => {
|
const toggleFilter = () => {
|
||||||
console.log("click")
|
|
||||||
if (visibleFilter) {
|
if (visibleFilter) {
|
||||||
closeFilter()
|
closeFilter()
|
||||||
} else {
|
} else {
|
||||||
@@ -41,11 +31,8 @@ const Layout: FC<Props> = ({ children }) => {
|
|||||||
<div className={s.mainLayout}>
|
<div className={s.mainLayout}>
|
||||||
<Header toggleFilter={toggleFilter}/>
|
<Header toggleFilter={toggleFilter}/>
|
||||||
<main >{children}</main>
|
<main >{children}</main>
|
||||||
<button onClick={toggle}>toggle card: {visibleCartDrawer.toString()}</button>
|
|
||||||
<CustomShapeSvg/>
|
<CustomShapeSvg/>
|
||||||
<CartDrawer
|
|
||||||
visible={visibleCartDrawer}
|
|
||||||
onClose={closeCartDrawer} />
|
|
||||||
<div className={s.filter}><MenuNavigationProductList categories={CATEGORY} brands={BRAND} featured={FEATURED} visible={visibleFilter} onClose={closeFilter}/> </div>
|
<div className={s.filter}><MenuNavigationProductList categories={CATEGORY} brands={BRAND} featured={FEATURED} visible={visibleFilter} onClose={closeFilter}/> </div>
|
||||||
<Footer />
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import { ROUTE } from 'src/utils/constanst.utils'
|
||||||
import { ProductProps } from 'src/utils/types.utils'
|
import { ProductProps } from 'src/utils/types.utils'
|
||||||
import ButtonCommon from '../ButtonCommon/ButtonCommon'
|
import ButtonCommon from '../ButtonCommon/ButtonCommon'
|
||||||
import ButtonIconBuy from '../ButtonIconBuy/ButtonIconBuy'
|
import ButtonIconBuy from '../ButtonIconBuy/ButtonIconBuy'
|
||||||
@@ -31,7 +32,7 @@ const ProductCard = ({
|
|||||||
return (
|
return (
|
||||||
<div className={s.productCardWarpper}>
|
<div className={s.productCardWarpper}>
|
||||||
<div className={s.cardTop}>
|
<div className={s.cardTop}>
|
||||||
<Link href="#">
|
<Link href={`${ROUTE.PRODUCT_DETAIL}/test`}>
|
||||||
<div className={s.productImage}>
|
<div className={s.productImage}>
|
||||||
<img src={imageSrc} alt="image" />
|
<img src={imageSrc} alt="image" />
|
||||||
</div>
|
</div>
|
||||||
@@ -42,7 +43,7 @@ const ProductCard = ({
|
|||||||
</div>
|
</div>
|
||||||
<div className={s.cardMid}>
|
<div className={s.cardMid}>
|
||||||
<div className={s.cardMidTop}>
|
<div className={s.cardMidTop}>
|
||||||
<Link href="#">
|
<Link href={`${ROUTE.PRODUCT_DETAIL}/test`}>
|
||||||
<div className={s.productname}>{name} </div>
|
<div className={s.productname}>{name} </div>
|
||||||
</Link>
|
</Link>
|
||||||
<div className={s.productWeight}>{weight}</div>
|
<div className={s.productWeight}>{weight}</div>
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import React, { useRef, useEffect, Children, ReactElement, PropsWithChildren, useState, cloneElement } from "react"
|
import React, { useRef, useEffect, Children, ReactElement, PropsWithChildren, useState, cloneElement } from "react"
|
||||||
import s from './AccountNavigation.module.scss'
|
import s from './AccountNavigation.module.scss'
|
||||||
|
|
||||||
import AccountNavigationItem from './components/AccountNavigationItem/AccountNavigationItem'
|
import AccountNavigationItem from './components/AccountNavigationItem'
|
||||||
import {TabPaneProps} from '../../../common/TabCommon/components/TabPane/TabPane'
|
import {TabPaneProps} from '../../../common/TabCommon/components/TabPane/TabPane'
|
||||||
|
|
||||||
interface AccountNavigationProps {
|
interface AccountNavigationProps {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
@import '../../../../../../styles/utilities';
|
@import '../../../../../styles/utilities';
|
||||||
|
|
||||||
.accountNavigationItem {
|
.accountNavigationItem {
|
||||||
width: 28rem;
|
width: 28rem;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import React, { RefObject } from "react";
|
import React from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import s from './AccountNavigationItem.module.scss'
|
import s from './AccountNavigationItem.module.scss'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user