From 9b45d372fa058a8430b18cce6d8930338af16a7d Mon Sep 17 00:00:00 2001 From: Pijus Kamandulis Date: Fri, 11 Oct 2024 20:47:24 +0300 Subject: [PATCH] Fix issues with newly created estimation --- src/lib/context/estimation.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/context/estimation.tsx b/src/lib/context/estimation.tsx index cb81b51..a2da560 100644 --- a/src/lib/context/estimation.tsx +++ b/src/lib/context/estimation.tsx @@ -36,13 +36,17 @@ const mapEstimationSession = ( data: DatabaseModels.EstimationSession, { userId }: { userId?: string }, ) => { - const sessionState = JSON.parse( - data.sessionState, - ) as EntityModels.SessionState; + const sessionState: EntityModels.SessionState = data.sessionState + ? JSON.parse(data.sessionState) + : { + votes: [], + }; - const tickets = data.tickets.map( - (ticket) => JSON.parse(ticket), - ); + const tickets = data.tickets + ? data.tickets.map((ticket) => + JSON.parse(ticket), + ) + : []; const result: EntityModels.EstimationSession = { id: data.$id,