Feat: Implement job dump parsing

The job dump input should update the output item fields.
The dump is delimited by newlines.
This commit is contained in:
gpt-engineer-app[bot]
2025-07-09 12:53:06 +00:00
committed by PhatPhuckDave
parent c9d9cd99ee
commit 260c1c0af3

View File

@@ -27,6 +27,43 @@ const JobForm: React.FC<JobFormProps> = ({ 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<HTMLTextAreaElement>) => {
const value = e.target.value;
setJobDump(value);
parseJobDump(value);
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
@@ -133,7 +170,7 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
<Textarea
id="jobDump"
value={jobDump}
onChange={(e) => setJobDump(e.target.value)}
onChange={handleJobDumpChange}
placeholder="Paste job dump here:&#10;&#10;Standup Light Guided Bomb 100&#10;285,224,182&#10;771,342,930&#10;&#10;Megacyte 37&#10;Zydrine 84&#10;..."
className="bg-gray-800 border-gray-600 text-white min-h-[120px]"
rows={6}