diff --git a/src/app/(main)/m/admin/inventory/page.tsx b/src/app/(main)/m/admin/inventory/page.tsx index f4b403e..3e5842c 100644 --- a/src/app/(main)/m/admin/inventory/page.tsx +++ b/src/app/(main)/m/admin/inventory/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useEffect, useMemo, useState } from "react"; +import { useEffect, useMemo, useState, useCallback } from "react"; import { Plus, Search, Trash2, History, ArrowRightLeft, Package, LayoutGrid, Columns3 } from "lucide-react"; import { useRouter } from "next/navigation"; import Swal from "sweetalert2"; @@ -58,13 +58,13 @@ export default function InventoryPage() { return { items: itemList, warehouses: allWhs, cell }; }, [list, whs]); - const load = async () => { + const load = useCallback(async () => { const res = await fetch("/api/m/inventory/list", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ whObjid: whFilter || undefined, keyword: keyword || undefined }), }); setList((await res.json()).RESULTLIST ?? []); - }; + }, [whFilter, keyword]); const loadMeta = async () => { const w = await (await fetch("/api/m/warehouses/list", { method: "POST" })).json(); setWhs(w.RESULTLIST ?? []); @@ -72,7 +72,8 @@ export default function InventoryPage() { setItems(i.RESULTLIST ?? []); }; - useEffect(() => { loadMeta(); load(); }, []); // eslint-disable-line + useEffect(() => { loadMeta(); }, []); + useEffect(() => { load(); }, [load]); const addLine = () => { if (!pickItem) return; diff --git a/src/app/(main)/m/admin/orders/page.tsx b/src/app/(main)/m/admin/orders/page.tsx index 88d17b4..86e8c7f 100644 --- a/src/app/(main)/m/admin/orders/page.tsx +++ b/src/app/(main)/m/admin/orders/page.tsx @@ -115,7 +115,7 @@ export default function AdminOrdersPage() { // 최초 로드만 자동, 검색 조건 변경은 [조회] 버튼으로 // eslint-disable-next-line react-hooks/exhaustive-deps - useEffect(() => { load(); }, []); + useEffect(() => { load(); }, [load]); const reloadDetail = useCallback(async () => { if (!activeId) { setDetail(null); return; } diff --git a/src/app/(main)/m/admin/payments/page.tsx b/src/app/(main)/m/admin/payments/page.tsx index 6c906e7..378f5d3 100644 --- a/src/app/(main)/m/admin/payments/page.tsx +++ b/src/app/(main)/m/admin/payments/page.tsx @@ -49,8 +49,8 @@ export default function PaymentsPage() { } }, [dateFrom, dateTo, keyword, payFilter]); - // 최초 1회만 자동 로드. 검색 조건 변경은 [조회] 버튼으로 - useEffect(() => { load(); }, []); // eslint-disable-line + // 검색 조건 변경 시 즉시 갱신 + useEffect(() => { load(); }, [load]); const onPay = async (o: Order) => { const remain = Number(o.TOTAL_AMOUNT) - Number(o.PAID_AMOUNT || 0);