Skip to content

Commit

Permalink
Add back loading spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
DinerIsmail committed Oct 9, 2024
1 parent 0d56531 commit ccab1ef
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useSearchParams, redirect } from 'next/navigation'
import { useSession } from 'next-auth/react'
import { useEffect, useMemo } from 'react'
import posthog from 'posthog-js'
import { Center, Spinner } from '@chakra-ui/react'
import { driver } from 'driver.js'
import 'driver.js/dist/driver.css'

Expand Down Expand Up @@ -70,7 +71,7 @@ export default function AdminPage() {
const { data: session } = useSession()
const { selectedWebId } = useAppContext()
const isOwnerOfCurrentWeb = useIsOwnerOfCurrentWeb()
const { allowedWebs } = useAllowedWebs()
const { allowedWebs, isLoadingWebs } = useAllowedWebs()
const { listings, isPending: isLoadingListings } = useListings()
const { permissions, isPending: isLoadingPermissions } = usePermissions()
const { mutate: deleteListing } = useDeleteListing()
Expand Down Expand Up @@ -118,6 +119,14 @@ export default function AdminPage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [firstTime])

if (isLoadingWebs || isLoadingListings || isLoadingPermissions) {
return (
<Center height="50vh">
<Spinner size="xl" />
</Center>
)
}

if (allowedWebs.length === 0) {
redirect('/admin/welcome')
}
Expand Down

0 comments on commit ccab1ef

Please sign in to comment.