fix: move invitingProfile null check immediately after fetch

Co-authored-by: antontranelis <31516529+antontranelis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-12-19 06:12:21 +00:00
parent 24adbd4bf6
commit 9bde446bdf

View File

@ -98,6 +98,13 @@ export function InvitePage({ inviteApi, itemsApi }: Props) {
const invitingProfile = await itemsApi.getItem(invitingProfileId)
if (!invitingProfile) {
toast.error('Inviting profile not found')
localStorage.removeItem('inviteCode')
void navigate('/')
return
}
if (invitingProfileId === myProfile?.id) {
toast.error('You cannot invite yourself')
localStorage.removeItem('inviteCode')
@ -117,13 +124,6 @@ export function InvitePage({ inviteApi, itemsApi }: Props) {
return
}
if (!invitingProfile) {
toast.error('Inviting profile not found')
localStorage.removeItem('inviteCode')
void navigate('/')
return
}
setInvitingProfile(invitingProfile)
}