From 3a5e627bdd6be4a350932b51c63d3f9b5125eb3b Mon Sep 17 00:00:00 2001 From: camilovegag Date: Thu, 2 May 2024 10:42:30 -0500 Subject: [PATCH 1/3] Check for open cycles --- packages/berlin/src/pages/Cycle.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/berlin/src/pages/Cycle.tsx b/packages/berlin/src/pages/Cycle.tsx index bfbf2fa8..6f9282b8 100644 --- a/packages/berlin/src/pages/Cycle.tsx +++ b/packages/berlin/src/pages/Cycle.tsx @@ -42,7 +42,7 @@ function Cycle() { const { user } = useUser(); const { eventId, cycleId } = useParams(); const { data: cycle } = useQuery({ - queryKey: ['cycles', cycleId], + queryKey: ['cycle', cycleId], queryFn: () => fetchCycle(cycleId || ''), enabled: !!cycleId, }); @@ -111,7 +111,7 @@ function Cycle() { } else if (body?.data.length) { queryClient.invalidateQueries({ queryKey: ['votes', cycleId] }); // this is to update the plural scores in each option - queryClient.invalidateQueries({ queryKey: ['cycles', cycleId] }); + queryClient.invalidateQueries({ queryKey: ['cycle', cycleId] }); toast.success('Votes saved successfully!'); } }, @@ -126,7 +126,11 @@ function Cycle() { }; const handleSaveVotesWrapper = () => { - handleSaveVotes(userVotes, localUserVotes, mutateVotes); + if (cycle?.status === 'OPEN') { + handleSaveVotes(userVotes, localUserVotes, mutateVotes); + } else { + toast.error('Cycle is not open'); + } }; const currentCycle = cycle?.forumQuestions[0]; From 4c4c98807ba57df7269b7ef0636fdfef304bd679 Mon Sep 17 00:00:00 2001 From: camilovegag Date: Thu, 2 May 2024 10:42:40 -0500 Subject: [PATCH 2/3] Update again disabled styles --- packages/berlin/src/components/button/Button.styled.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/berlin/src/components/button/Button.styled.tsx b/packages/berlin/src/components/button/Button.styled.tsx index 36a45645..dd6fc262 100644 --- a/packages/berlin/src/components/button/Button.styled.tsx +++ b/packages/berlin/src/components/button/Button.styled.tsx @@ -13,10 +13,10 @@ export const StyledButton = styled.button` text-transform: uppercase; &:disabled { - background-color: var(--color-gray); + opacity: 0.5; cursor: not-allowed; &:hover { - opacity: 1; + opacity: 0.5; } } @@ -69,9 +69,10 @@ export const StyledButton = styled.button` &:disabled { background-color: transparent; user-select: none; - cursor: pointer; + opacity: 0.5; + cursor: default; &:hover { - opacity: 1; + opacity: 0.5; } } `} From 7fb1dc3b068e79189ff25812e9ef59a9276deb00 Mon Sep 17 00:00:00 2001 From: camilovegag Date: Thu, 2 May 2024 11:00:56 -0500 Subject: [PATCH 3/3] Go back to cycles on query key --- packages/berlin/src/pages/Cycle.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/berlin/src/pages/Cycle.tsx b/packages/berlin/src/pages/Cycle.tsx index 6f9282b8..14284c59 100644 --- a/packages/berlin/src/pages/Cycle.tsx +++ b/packages/berlin/src/pages/Cycle.tsx @@ -42,7 +42,7 @@ function Cycle() { const { user } = useUser(); const { eventId, cycleId } = useParams(); const { data: cycle } = useQuery({ - queryKey: ['cycle', cycleId], + queryKey: ['cycles', cycleId], queryFn: () => fetchCycle(cycleId || ''), enabled: !!cycleId, }); @@ -111,7 +111,7 @@ function Cycle() { } else if (body?.data.length) { queryClient.invalidateQueries({ queryKey: ['votes', cycleId] }); // this is to update the plural scores in each option - queryClient.invalidateQueries({ queryKey: ['cycle', cycleId] }); + queryClient.invalidateQueries({ queryKey: ['cycles', cycleId] }); toast.success('Votes saved successfully!'); } },