feat: edit activeCustomer

This commit is contained in:
Quangnhankie
2021-10-10 14:45:44 +07:00
parent 95f2f0f230
commit 1126030abc
5 changed files with 20 additions and 6 deletions

View File

@@ -5,6 +5,13 @@ export const activeCustomerQuery = /* GraphQL */ `
firstName firstName
lastName lastName
emailAddress emailAddress
favorites{
items{
product{
id
}
}
}
} }
} }
` `

3
next-env.d.ts vendored
View File

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

View File

@@ -4,16 +4,22 @@ import React, { memo } from 'react'
import s from './ItemWishList.module.scss' import s from './ItemWishList.module.scss'
interface Props { interface Props {
id:string,
isActive?: boolean, isActive?: boolean,
onChange?: () => void onChange?: () => string
} }
const ItemWishList = memo(({isActive=false, onChange}:Props) => { const ItemWishList = memo(({id,isActive=false, onChange}:Props) => {
// function toggleFavorite(id:string):string|undefined{
// // alert(id);
// return id;
// }
return( return(
<div className={classNames({ <div className={classNames({
[s.heartToggle]: true, [s.heartToggle]: true,
[s.isToggleOn]: isActive [s.isToggleOn]: isActive
})} })}
// onClick={toggleFavorite(id)}
onChange={onChange} onChange={onChange}
> >
<IconHeart /> <IconHeart />

View File

@@ -17,6 +17,7 @@ export interface ProductCardProps extends ProductCard {
} }
const ProductCardComponent = ({ const ProductCardComponent = ({
id,
collection, collection,
name, name,
slug, slug,
@@ -34,6 +35,7 @@ const ProductCardComponent = ({
</div> </div>
} }
return ( return (
<div className={s.productCardWarpper}> <div className={s.productCardWarpper}>
<div className={s.cardTop}> <div className={s.cardTop}>
@@ -63,7 +65,7 @@ const ProductCardComponent = ({
<div className={s.cardMidBot}> <div className={s.cardMidBot}>
<div className={s.productPrice}>{price} {currencyCode}</div> <div className={s.productPrice}>{price} {currencyCode}</div>
<div className={s.wishList}> <div className={s.wishList}>
<ItemWishList /> <ItemWishList id={id}/>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -33,6 +33,8 @@ const ProductList = ({ data, total = data.length, defaultCurrentPage, onPageChan
<div className={s.list}> <div className={s.list}>
{ {
data.map((product, index) => { data.map((product, index) => {
console.log(product);
return <ProductCard {...product} key={index} /> return <ProductCard {...product} key={index} />
}) })
} }