Files
sam-react-prod/src/components/accounting/BillManagement/sections/DiscountInfoSection.tsx
권혁성 a4f99ae339 feat: [출하/배차/회계] 배차 다중행 + 어음 리팩토링 + 출고관리
- 배차차량관리 목업→API 연동, 배차정보 다중 행
- ShipmentManagement 출고관리 API 매핑
- BillManagement 리팩토링 (섹션 분리, hooks, constants)
- 상품권 actions/types 확장
- 출하관리 캘린더 기본 뷰 week-time
2026-03-07 03:03:27 +09:00

57 lines
2.7 KiB
TypeScript

'use client';
import { useMemo } from 'react';
import { Input } from '@/components/ui/input';
import { DatePicker } from '@/components/ui/date-picker';
import { Label } from '@/components/ui/label';
import { CurrencyInput } from '@/components/ui/currency-input';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import type { SectionProps } from './types';
export function DiscountInfoSection({ formData, updateField, isViewMode }: SectionProps) {
const calcNetReceived = useMemo(() => {
if (formData.amount > 0 && formData.discountAmount > 0) return formData.amount - formData.discountAmount;
return 0;
}, [formData.amount, formData.discountAmount]);
return (
<Card className="mb-6 border-purple-200">
<CardHeader>
<CardTitle className="text-lg"> </CardTitle>
</CardHeader>
<CardContent>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<div className="space-y-2">
<Label> <span className="text-red-500">*</span></Label>
<DatePicker value={formData.discountDate} onChange={(d) => updateField('discountDate', d)} disabled={isViewMode} />
</div>
<div className="space-y-2">
<Label> () <span className="text-red-500">*</span></Label>
<Input value={formData.discountBank} onChange={(e) => updateField('discountBank', e.target.value)} placeholder="예: 국민은행 강남지점" disabled={isViewMode} />
</div>
<div className="space-y-2">
<Label> (%)</Label>
<Input type="number" step="0.01" min={0} max={100} value={formData.discountRate || ''} onChange={(e) => {
const rate = parseFloat(e.target.value) || 0;
updateField('discountRate', rate);
if (formData.amount > 0 && rate > 0) updateField('discountAmount', Math.round(formData.amount * rate / 100));
}} placeholder="예: 3.5" disabled={isViewMode} />
</div>
<div className="space-y-2">
<Label></Label>
<CurrencyInput value={formData.discountAmount} onChange={(v) => updateField('discountAmount', v ?? 0)} disabled={isViewMode} />
</div>
<div className="space-y-2">
<Label> ()</Label>
<div className="h-10 flex items-center px-3 border rounded-md bg-gray-50 text-sm font-semibold">
{calcNetReceived > 0
? <span className="text-green-700"> {calcNetReceived.toLocaleString()}</span>
: <span className="text-gray-400"> - </span>}
</div>
</div>
</div>
</CardContent>
</Card>
);
}