'use client'; import { useRouter } from 'next/navigation'; import { FoxButton } from '@fox/core/components/fox-button'; import { FoxButtonGroup } from '@fox/core/components/fox-button-group'; import { useBlockingAction } from '@/app/_hooks/use-blocking-action'; import { useFeedback } from '@/app/_hooks/use-feedback'; import { merchantProductPath } from '@/lib/domain/merchant-detail-query'; import type { MerchantProduct } from '@/lib/domain/merchant-product'; import { deleteMerchantProductAction, updateMerchantProductVisibilityAction, } from '../_actions'; interface MerchantProductRowActionsProps { product: MerchantProduct; } /** 기획 BO-MAL-002 ⑥ — 메뉴 행의 [수정] [숨김|노출] [삭제]. 수정은 메뉴 화면으로 간다. */ export function MerchantProductRowActions({ product }: MerchantProductRowActionsProps) { const router = useRouter(); const { showAlert, hideAlert, showToast } = useFeedback(); const [isBusy, startAction] = useBlockingAction(); function toggleVisibility() { const next = !product.isVisible; startAction(async () => { const result = await updateMerchantProductVisibilityAction( product.frcsNo, product.id, next ); showToast( result.status === 'error' ? { variant: 'danger', message: result.message } : { variant: 'success', message: next ? '노출로 바꿨습니다.' : '숨겼습니다.' } ); }); } function runDelete() { hideAlert(); startAction(async () => { const result = await deleteMerchantProductAction(product.frcsNo, product.id); showToast( result.status === 'error' ? { variant: 'danger', message: result.message } : { variant: 'success', message: '메뉴를 삭제했습니다.' } ); }); } function confirmDelete() { showAlert({ variant: 'danger', title: '메뉴를 삭제하시겠습니까?', message: `"${product.name}" 메뉴를 삭제합니다. 삭제 후에는 되돌릴 수 없습니다.`, actions: ( ), }); } return ( router.push(merchantProductPath(product.frcsNo, product.id))} /> ); }