Refresh job when pasting BOM
This commit is contained in:
@@ -231,10 +231,14 @@ export class DataService {
|
|||||||
[type]: [...currentIds, createdBillItem.id]
|
[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);
|
const jobIndex = this.jobs.findIndex(j => j.id === jobId);
|
||||||
if (jobIndex !== -1) {
|
if (jobIndex !== -1) {
|
||||||
this.jobs[jobIndex][type].push(createdBillItem);
|
this.jobs[jobIndex] = updatedJob;
|
||||||
this.notifyListeners();
|
this.notifyListeners();
|
||||||
return this.jobs[jobIndex];
|
return this.jobs[jobIndex];
|
||||||
}
|
}
|
||||||
@@ -268,10 +272,14 @@ export class DataService {
|
|||||||
[type]: newIds // Replace instead of append
|
[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);
|
const jobIndex = this.jobs.findIndex(j => j.id === jobId);
|
||||||
if (jobIndex !== -1) {
|
if (jobIndex !== -1) {
|
||||||
this.jobs[jobIndex][type] = createdBillItems; // Replace instead of append
|
this.jobs[jobIndex] = updatedJob;
|
||||||
this.notifyListeners();
|
this.notifyListeners();
|
||||||
return this.jobs[jobIndex];
|
return this.jobs[jobIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user