Skip to content

Commit

Permalink
fix: also convert simulation poll and group attr
Browse files Browse the repository at this point in the history
  • Loading branch information
Clemog committed Jun 11, 2024
1 parent bb18d60 commit 0bdc1eb
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/publicodes-state/helpers/migrateSimulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Migration, migrateSituation } from '@publicodes/tools/migration'
import { Simulation } from '../types'

export function migrateSimulation(
simulation: Simulation,
simulation: Simulation & { group?: string; poll?: string },
migrationInstructions: Migration
): Simulation {
simulation.situation = migrateSituation(
Expand All @@ -21,5 +21,15 @@ export function migrateSimulation(
)
)

// If group or poll is defined, we convert it to groups or polls and delete it
if (simulation.group) {
simulation.groups = [simulation.group]
delete simulation.group
}
if (simulation.poll) {
simulation.polls = [simulation.poll]
delete simulation.poll
}

return simulation
}

0 comments on commit 0bdc1eb

Please sign in to comment.