Skip to content

Commit 4e1c6d7

Browse files
committed
refactor: advacned 리팩토링
1 parent a3fc154 commit 4e1c6d7

File tree

15 files changed

+496
-475
lines changed

15 files changed

+496
-475
lines changed

src/advanced/atoms/cartActionsAtom.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

src/advanced/atoms/couponActionsAtom.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

src/advanced/atoms/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
// State atoms
21
export { cartAtom } from "./cartAtom";
3-
export { productsAtom } from "./productAtom";
42
export { couponsAtom, selectedCouponAtom } from "./couponAtom";
5-
export { isAdminAtom, searchTermAtom } from "./uiAtom";
3+
export { productsAtom } from "./productAtom";
64
export { notificationsAtom, notificationActionsAtom } from "./notificationAtom";
7-
8-
// Action atoms
9-
export { cartActionsAtom, completeOrderAtom } from "./cartActionsAtom";
10-
export { productActionsAtom } from "./productActionsAtom";
11-
export { couponActionsAtom } from "./couponActionsAtom";
5+
export { isAdminAtom, searchTermAtom } from "./uiAtom";

src/advanced/atoms/productActionsAtom.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

src/advanced/components/cart/Cart.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface CartProps {
1313
removeFromCart: (productId: string) => void;
1414
updateQuantity: (productId: string, newQuantity: number) => void;
1515
calculateItemTotal: (item: CartItem, cart: CartItem[]) => number;
16-
applyCoupon: (coupon: Coupon) => void;
16+
applyCoupon: (coupon: Coupon, cart: CartItem[]) => void;
1717
clearSelectedCoupon: () => void;
1818
completeOrder: () => void;
1919
}
@@ -35,6 +35,11 @@ export default function Cart({
3535
selectedCoupon,
3636
});
3737

38+
// applyCoupon을 래핑하여 cart를 전달
39+
const handleApplyCoupon = (coupon: Coupon) => {
40+
applyCoupon(coupon, cart);
41+
};
42+
3843
return (
3944
<div className="sticky top-24 space-y-4">
4045
<CartHeader>
@@ -51,7 +56,7 @@ export default function Cart({
5156
<CouponSection
5257
coupons={coupons}
5358
selectedCoupon={selectedCoupon}
54-
applyCoupon={applyCoupon}
59+
applyCoupon={handleApplyCoupon}
5560
clearSelectedCoupon={clearSelectedCoupon}
5661
/>
5762
<PaymentSection

src/advanced/hooks/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
export { useAdminMode } from "./useAdminMode";
1+
export { useCart } from "./useCart";
2+
export { useCoupon } from "./useCoupon";
3+
export { useProduct } from "./useProduct";
4+
export { useSearch } from "./useSearch";
5+
export { useNotification } from "./useNotification";
26
export { useTab } from "./useTab";
3-
export { useDebouncedSearch } from "./useDebouncedSearch";

src/advanced/hooks/useAdminMode.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)