diff --git a/src/components/JobForm.tsx b/src/components/JobForm.tsx index 570ff26..72a541d 100644 --- a/src/components/JobForm.tsx +++ b/src/components/JobForm.tsx @@ -27,6 +27,43 @@ const JobForm: React.FC = ({ job, onSubmit, onCancel }) => { const [jobDump, setJobDump] = useState(''); + const parseJobDump = (dumpText: string) => { + if (!dumpText.trim()) return; + + const lines = dumpText.trim().split('\n').filter(line => line.trim()); + + if (lines.length >= 3) { + // Parse first line: "Item Name Quantity" + const firstLine = lines[0].trim(); + const lastSpaceIndex = firstLine.lastIndexOf(' '); + + if (lastSpaceIndex > 0) { + const itemName = firstLine.substring(0, lastSpaceIndex).trim(); + const quantity = parseInt(firstLine.substring(lastSpaceIndex + 1).trim()) || 0; + + // Parse cost (second line) + const cost = parseISKAmount(lines[1].replace(/,/g, '')); + + // Parse revenue (third line) + const revenue = parseISKAmount(lines[2].replace(/,/g, '')); + + setFormData(prev => ({ + ...prev, + outputItem: itemName, + outputQuantity: quantity, + projectedCost: cost, + projectedRevenue: revenue + })); + } + } + }; + + const handleJobDumpChange = (e: React.ChangeEvent) => { + const value = e.target.value; + setJobDump(value); + parseJobDump(value); + }; + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); @@ -133,7 +170,7 @@ const JobForm: React.FC = ({ job, onSubmit, onCancel }) => {