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:
@@ -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: Standup Light Guided Bomb 100 285,224,182 771,342,930 Megacyte 37 Zydrine 84 ..."
|
||||
className="bg-gray-800 border-gray-600 text-white min-h-[120px]"
|
||||
rows={6}
|
||||
|
Reference in New Issue
Block a user