mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
🐛 bug: change active step in checkout
:%s
This commit is contained in:
@@ -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<number>(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) => {
|
||||
<div className={s.warpper}>
|
||||
{/* TODO: remove */}
|
||||
{/* <ButtonCommon onClick={createOrder}>test create order</ButtonCommon> */}
|
||||
|
||||
doneSteps = {JSON.stringify(doneSteps)}
|
||||
<div className={s.title}>
|
||||
<Logo />
|
||||
<div className={s.viewCart} onClick={onViewCart}>View cart</div>
|
||||
@@ -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}
|
||||
>
|
||||
|
@@ -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";
|
||||
|
Reference in New Issue
Block a user