Skip to content

Commit

Permalink
refactor:(useOrder): api 성공시에만 후행로직이 실행되도록 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
Creative-Lee committed Jun 9, 2023
1 parent ef488dc commit 425dd52
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/CheckOutPriceSection/CheckOutPriceSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useCartCheckBox from 'hooks/useCartCheckBox';
import useCheckOutPriceText from './hooks/useCheckOutPriceText';

const CheckOutPriceSection = () => {
const { handleCreateOrder } = useOrder();
const { createOrder } = useOrder();
const { checkedCartProductIds } = useCartCheckBox();
const {
productTotalPriceText,
Expand Down Expand Up @@ -45,7 +45,7 @@ const CheckOutPriceSection = () => {
</Box>
</PriceSection>
<ConfirmButtonBox sizing={{ width: '100%' }}>
<OrderConfirmButton onClick={handleCreateOrder} isActive={isCheckedProductsExist}>
<OrderConfirmButton onClick={createOrder} isActive={isCheckedProductsExist}>
{orderConfirmButtonText}
</OrderConfirmButton>
</ConfirmButtonBox>
Expand Down
5 changes: 1 addition & 4 deletions src/components/CheckOutPriceSection/hooks/useOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ const useOrder = () => {
alert('상품을 주문하지 못했어요. 다시 시도해주세요');
return;
}
};

const handleCreateOrder = async () => {
await createOrder();
setCartProducts(await getCartProducts());
navigate(ROUTE_PATH.ORDER_LIST);
};

return { handleCreateOrder };
return { createOrder };
};

export default useOrder;

0 comments on commit 425dd52

Please sign in to comment.