From f959ac8ea2852d167a510b61aa008c411e5bbcf5 Mon Sep 17 00:00:00 2001 From: lytrankieio123 Date: Wed, 20 Oct 2021 16:47:48 +0700 Subject: [PATCH] :bug: bug: change active step in checkout :%s --- .../modules/checkout/CheckoutInfo/CheckoutInfo.tsx | 12 ++++-------- src/utils/funtion.utils.ts | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx index 8b3267238..2a0046caf 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -1,9 +1,8 @@ import React, { useEffect, useState } from 'react' -import { ButtonCommon, Logo } from 'src/components/common' +import { Logo } from 'src/components/common' import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse' import { useActiveCustomer } from 'src/components/hooks/auth' -import { useAddProductToCart, useGetActiveOrder } from 'src/components/hooks/cart' -import { removeItem } from 'src/utils/funtion.utils' +import { useGetActiveOrder } from 'src/components/hooks/cart' import s from './CheckoutInfo.module.scss' import CustomerInfoForm from './components/CustomerInfoForm/CustomerInfoForm' import PaymentInfoForm from './components/PaymentInfoForm/PaymentInfoForm' @@ -46,21 +45,17 @@ const CheckoutInfo = ({ onViewCart }: CheckoutInfoProps) => { const onEdit = (id: CheckoutStep) => { setActiveStep(id) - setDoneSteps(removeItem(doneSteps, id)) } const updateActiveStep = (step: CheckoutStep) => { if (doneSteps.length > 0) { for (let i = step + 1; i < Object.keys(CheckoutStep).length; i++) { if (!doneSteps.includes(i)) { - // console.log("here: ", doneSteps, i) setActiveStep(i) return } } } else { - // console.log("here 2: ", doneSteps, step) - setActiveStep(step + 1) } } @@ -129,7 +124,7 @@ const CheckoutInfo = ({ onViewCart }: CheckoutInfoProps) => {
{/* TODO: remove */} {/* test create order */} - + doneSteps = {JSON.stringify(doneSteps)}
View cart
@@ -143,6 +138,7 @@ const CheckoutInfo = ({ onViewCart }: CheckoutInfoProps) => { title={item.title} onEditClick={onEdit} isEdit={doneSteps.includes(item.id)} + onClose={onConfirm} note={note} disableEdit={customer && item.id === CheckoutStep.CustomerInfo} > diff --git a/src/utils/funtion.utils.ts b/src/utils/funtion.utils.ts index 94521e072..1989bfd30 100644 --- a/src/utils/funtion.utils.ts +++ b/src/utils/funtion.utils.ts @@ -1,6 +1,6 @@ import { Collection } from '@commerce/types/collection'; import { Facet } from "@commerce/types/facet"; -import { Product, ProductCard, ProductOption, ProductOptionValues } from "@commerce/types/product"; +import { Product, ProductCard, ProductOptionValues } from "@commerce/types/product"; import { FacetValue, SearchResultSortParameter } from './../../framework/vendure/schema.d'; import { CODE_FACET_DISCOUNT, CODE_FACET_FEATURED, CODE_FACET_FEATURED_VARIANT, FACET, PRODUCT_SORT_OPTION_VALUE } from "./constanst.utils"; import { PromiseWithKey, SelectedOptions, SortOrder } from "./types.utils";