Fix remove acquisiton

This commit is contained in:
2024-05-17 23:44:11 +02:00
parent 717eaa6ed8
commit 94992afbe3

View File

@@ -36,9 +36,13 @@ export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
return; return;
} }
const item = {
...found,
remaining: Math.max(0, found.remaining - quantity)
};
if (found.remaining <= 0) { if (found.remaining <= 0) {
acquiredTypes.value = acquiredTypes.value.filter(i => i.type !== type); acquiredTypes.value = acquiredTypes.value.filter(i => i.type !== type);
} else { } else {
acquiredTypes.value = acquiredTypes.value.map(i => { acquiredTypes.value = acquiredTypes.value.map(i => {
if (i.type === item.type) { if (i.type === item.type) {
@@ -48,12 +52,6 @@ export const useAcquiredTypesStore = defineStore('market-acquisition', () => {
} }
}); });
} }
const item = {
...found,
remaining: found.remaining - quantity
};
await marbasAxiosInstance.put(`${endpoint}${item.id}`, item); await marbasAxiosInstance.put(`${endpoint}${item.id}`, item);
}; };