Refresh job when pasting BOM

This commit is contained in:
2025-07-07 16:37:44 +02:00
parent b83e94f462
commit 8dd6630e8d

View File

@@ -231,10 +231,14 @@ export class DataService {
[type]: [...currentIds, createdBillItem.id]
});
// Update local state
// Fetch fresh job data from the server
const updatedJob = await jobService.getJob(jobId);
if (!updatedJob) throw new Error(`Job with id ${jobId} not found after update`);
// Update local state with fresh data
const jobIndex = this.jobs.findIndex(j => j.id === jobId);
if (jobIndex !== -1) {
this.jobs[jobIndex][type].push(createdBillItem);
this.jobs[jobIndex] = updatedJob;
this.notifyListeners();
return this.jobs[jobIndex];
}
@@ -268,10 +272,14 @@ export class DataService {
[type]: newIds // Replace instead of append
});
// Update local state
// Fetch fresh job data from the server
const updatedJob = await jobService.getJob(jobId);
if (!updatedJob) throw new Error(`Job with id ${jobId} not found after update`);
// Update local state with fresh data
const jobIndex = this.jobs.findIndex(j => j.id === jobId);
if (jobIndex !== -1) {
this.jobs[jobIndex][type] = createdBillItems; // Replace instead of append
this.jobs[jobIndex] = updatedJob;
this.notifyListeners();
return this.jobs[jobIndex];
}