Harden sortie item save recovery
This commit is contained in:
@@ -991,17 +991,17 @@ function normalizeReserveTrainingSnapshot(value: unknown): CampaignReserveTraini
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeSortieItemAssignments(assignments?: CampaignSortieItemAssignments) {
|
||||
function normalizeSortieItemAssignments(assignments?: Record<string, unknown>) {
|
||||
return Object.entries(assignments ?? {}).reduce<CampaignSortieItemAssignments>((next, [unitId, stocks]) => {
|
||||
const unitStocks = Object.entries(stocks ?? {}).reduce<Record<string, number>>((nextStocks, [itemId, amount]) => {
|
||||
const normalizedAmount = Math.floor(Number(amount));
|
||||
const unitStocks = Object.entries(recordOrEmpty(stocks)).reduce<Record<string, number>>((nextStocks, [itemId, amount]) => {
|
||||
const normalizedAmount = normalizeNonNegativeInteger(amount);
|
||||
if (itemId && normalizedAmount > 0) {
|
||||
nextStocks[itemId] = normalizedAmount;
|
||||
}
|
||||
return nextStocks;
|
||||
}, {});
|
||||
|
||||
if (Object.keys(unitStocks).length > 0) {
|
||||
if (unitId && Object.keys(unitStocks).length > 0) {
|
||||
next[unitId] = unitStocks;
|
||||
}
|
||||
return next;
|
||||
|
||||
Reference in New Issue
Block a user