Skip to content

Commit 9682bd2

Browse files
committed
fix: fix race condition during retro creation block
1 parent bac8bb7 commit 9682bd2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/app/dashboard/retros/retros.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function Retros({ userId }: RetrosProps) {
2121
const { toast } = useToast()
2222
const [isLimitReached, setIsLimitReached] = useState(false)
2323
const { data: user } = api.user.getLoggedIn.useQuery()
24-
const accountType = getAccountType(user?.stripeSubscriptionStatus || null) || AccountType.Standard
24+
const accountType = getAccountType(user?.stripeSubscriptionStatus || null)
2525

2626
const {
2727
data: retrospectives,
@@ -57,7 +57,10 @@ export function Retros({ userId }: RetrosProps) {
5757
}
5858

5959
useEffect(() => {
60-
if (retrospectives && retrospectives.length >= 3 && accountType === AccountType.Standard) {
60+
if (!retrospectives) return
61+
if (!accountType) return
62+
63+
if (retrospectives.length >= 3 && accountType === AccountType.Standard) {
6164
setIsLimitReached(true)
6265
}
6366
}, [retrospectives, accountType])
@@ -67,9 +70,11 @@ export function Retros({ userId }: RetrosProps) {
6770
<div className='flex flex-row items-baseline justify-between'>
6871
<CardTitle className='p-5 text-center'>RETROS</CardTitle>
6972

70-
<div className='flex w-full justify-end'>
71-
<AddRetro handleAddRetro={handleAddRetro} isLimitReached={isLimitReached} />
72-
</div>
73+
{!isLoading && (
74+
<div className='flex w-full justify-end'>
75+
<AddRetro handleAddRetro={handleAddRetro} isLimitReached={isLimitReached} />
76+
</div>
77+
)}
7378
</div>
7479

7580
{isLoading && <Loader isLoading={isLoading} />}

0 commit comments

Comments
 (0)