diff --git a/src/packages/practica/hooks/use-votes-count.ts b/src/packages/practica/hooks/use-votes-count.ts index af5d530..03a72a6 100644 --- a/src/packages/practica/hooks/use-votes-count.ts +++ b/src/packages/practica/hooks/use-votes-count.ts @@ -12,6 +12,7 @@ export default function useVotesCount( useDeepCompareEffect(() => { if (transformedVotes) { const { ballotConfig, votes } = transformedVotes + // @ts-ignore this should have better classes const votesCount: VoteCounts = ballotConfig.countVotes(votes) setVotesCount(votesCount) diff --git a/src/packages/practica/hooks/use-votes-transform.ts b/src/packages/practica/hooks/use-votes-transform.ts index a56ae4e..154d8a2 100644 --- a/src/packages/practica/hooks/use-votes-transform.ts +++ b/src/packages/practica/hooks/use-votes-transform.ts @@ -1,12 +1,12 @@ import { useState } from "react" import { BallotType } from "../../../ballot-validator/types" -import { VotesCoordinates } from "../../generate-ballot/types/ballot-machine" import coordinatesToSections from "../services/coordinates-to-sections" import { TransformedVotes } from "../services/types" import { Vote } from "../services/vote-service" import useDeepCompareEffect from "./use-deep-compare-effect" +// @ts-ignore function getBallot(state) { const { ballots, ballotType: contextBallotType } = state.context @@ -30,11 +30,12 @@ function getBallot(state) { } } +// @ts-ignore export default function useVotesTransform(votes: Vote[], state) { const [transformedVotes, setTransformedVotes] = useState(null) - useDeepCompareEffect(() => { + useDeepCompareEffect(() => { const res = getBallot(state) if (res) { diff --git a/src/packages/practica/strategies/mixed-vote-strategy.ts b/src/packages/practica/strategies/mixed-vote-strategy.ts index 09df9ff..deacce4 100644 --- a/src/packages/practica/strategies/mixed-vote-strategy.ts +++ b/src/packages/practica/strategies/mixed-vote-strategy.ts @@ -84,7 +84,7 @@ export class MixedVoteStrategy implements VoteUpdateInterface { return [...prevVotes, vote] } - removeVote(intendedVote: VoteEvent, prevVotes: Vote[]) { + removeVote(intendedVote: VoteEvent, prevVotes: Vote[]): Vote[] { // Remove the vote. const filteredVotes = prevVotes.filter((vote) => { return !( @@ -126,7 +126,7 @@ export class MixedVoteStrategy implements VoteUpdateInterface { vote.position.row === PARTY_ROW ) - if (voteForParty == null) return + if (voteForParty == null) throw new Error("Vote for party not found") const columnForParty = getColumnForParty(ballot, voteForParty) const candidate = columnForParty.find((item, index) => { diff --git a/src/packages/practica/strategies/utils.ts b/src/packages/practica/strategies/utils.ts index 98fa7e0..6cf8109 100644 --- a/src/packages/practica/strategies/utils.ts +++ b/src/packages/practica/strategies/utils.ts @@ -92,7 +92,7 @@ export function getStartAndEndPositionsForBallot( export function getColumnForParty( ballot: BallotConfigs, - intendedVote: VoteEvent + intendedVote: Pick ) { const columnForParty = ballot.structure.reduce((accum, currentRow) => { const colForParty = currentRow.filter((column, columnIndex) => { diff --git a/src/papeleta/Form/machine.ts b/src/papeleta/Form/machine.ts index 37d2ff7..43a7bc9 100755 --- a/src/papeleta/Form/machine.ts +++ b/src/papeleta/Form/machine.ts @@ -62,12 +62,14 @@ export const createBallotMachine = ( const actors: { [key: string]: AllowedActors } = {} sections.forEach((s) => { + // @ts-ignore xstate magic actors[`section-${s.id}`] = spawn( createSectionMachine(s), `section-${s.id}` ) }) + // @ts-ignore xstate magic actors.parties = spawn(createPartyMachine(parties)) return { actors }