Update combined static Vd and weight-based settings
This commit is contained in:
@@ -52,6 +52,38 @@ export const useAppState = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Migrate weightBasedVd from old {enabled, bodyWeight} to new standardVd structure
|
||||
const oldWeightBasedVd = (migratedPkParams.advanced as any).weightBasedVd;
|
||||
if (oldWeightBasedVd && typeof oldWeightBasedVd === 'object' && 'enabled' in oldWeightBasedVd) {
|
||||
// Old format detected: {enabled: boolean, bodyWeight: string}
|
||||
if (oldWeightBasedVd.enabled) {
|
||||
// Convert to new weight-based preset
|
||||
migratedPkParams.advanced.standardVd = {
|
||||
preset: 'weight-based',
|
||||
customValue: migratedPkParams.advanced.standardVd?.customValue || '377',
|
||||
bodyWeight: oldWeightBasedVd.bodyWeight || '70'
|
||||
};
|
||||
} else {
|
||||
// Keep existing standardVd, but ensure bodyWeight is present
|
||||
if (!migratedPkParams.advanced.standardVd?.bodyWeight) {
|
||||
migratedPkParams.advanced.standardVd = {
|
||||
...migratedPkParams.advanced.standardVd,
|
||||
bodyWeight: oldWeightBasedVd.bodyWeight || '70'
|
||||
};
|
||||
}
|
||||
}
|
||||
// Remove old weightBasedVd property
|
||||
delete (migratedPkParams.advanced as any).weightBasedVd;
|
||||
}
|
||||
|
||||
// Ensure bodyWeight exists in standardVd (for new installations or old formats)
|
||||
if (!migratedPkParams.advanced.standardVd?.bodyWeight) {
|
||||
migratedPkParams.advanced.standardVd = {
|
||||
...migratedPkParams.advanced.standardVd,
|
||||
bodyWeight: '70'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Validate numeric fields and replace empty/invalid values with defaults
|
||||
|
||||
Reference in New Issue
Block a user