Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
refactor(client): Ignores some type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
eluciano11 committed Dec 21, 2023
1 parent 60765e0 commit 670dd82
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/packages/practica/hooks/use-votes-count.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions src/packages/practica/hooks/use-votes-transform.ts
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -30,11 +30,12 @@ function getBallot(state) {
}
}

// @ts-ignore
export default function useVotesTransform(votes: Vote[], state) {
const [transformedVotes, setTransformedVotes] =
useState<TransformedVotes | null>(null)

useDeepCompareEffect<VotesCoordinates[]>(() => {
useDeepCompareEffect<Vote[]>(() => {
const res = getBallot(state)

if (res) {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/practica/strategies/mixed-vote-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 !(
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/practica/strategies/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function getStartAndEndPositionsForBallot(

export function getColumnForParty(
ballot: BallotConfigs,
intendedVote: VoteEvent
intendedVote: Pick<VoteEvent, "position">
) {
const columnForParty = ballot.structure.reduce((accum, currentRow) => {
const colForParty = currentRow.filter((column, columnIndex) => {
Expand Down
2 changes: 2 additions & 0 deletions src/papeleta/Form/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 670dd82

Please sign in to comment.