import { useState } from 'react' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import { Trash2 } from 'lucide-react' import { getProducts, deleteProduct } from '../api/client' export default function ProductList() { const qc = useQueryClient() const [keyword, setKeyword] = useState('') const { data: products = [], isLoading } = useQuery({ queryKey: ['products', keyword], queryFn: () => getProducts({ keyword: keyword || undefined }), }) const deleteMut = useMutation({ mutationFn: deleteProduct, onSuccess: () => qc.invalidateQueries({ queryKey: ['products'] }), }) if (isLoading) return
로딩 중...
return (

상품/가격 관리

setKeyword(e.target.value)} placeholder="상품명·코드 검색" className="bg-panel border border-edge rounded px-3 py-1.5 text-sm text-gray-300 w-48" />
{['테넌트','매장','상품코드','상품명','카테고리','정가','판매가','화폐','상태','액션'].map(h => ( ))} {(products as any[]).map((p: any) => ( ))} {(products as any[]).length === 0 && ( )}
{h}
{p.tenantCode} {p.storeName || '-'} {p.productCode} {p.productName} {p.category} {p.price?.toLocaleString()} {p.salePrice?.toLocaleString()} {p.currency} {p.active ? '활성' : '비활성'}
상품이 없습니다
) }