Skip to content

Commit

Permalink
Fix redirection from incident dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Oct 18, 2023
1 parent 022498c commit 4510785
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion hooks/useUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const UserProvider = ({ children }) => {
const [user, setUser] = useState()
const [error, setError] = useState()
const [loading, setLoading] = useState(true)
// const [loadingInitial, setLoadingInitial] = useState(true)

const getUser = () => {
return getAPI(apiEndpoints.ACCOUNT_METADATA)
Expand Down
6 changes: 3 additions & 3 deletions pages/incidents/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const StyledRow = styled.tr`

const IncidentsDashboard = () => {
const intl = useIntl()
const { user } = useUser()
const { user, loading } = useUser()
const router = useRouter()

const { data, error } = useSWR(apiEndpoints.SEARCH_INCIDENTS, fetcher)
Expand All @@ -45,8 +45,8 @@ const IncidentsDashboard = () => {

// redirect non-admin users
useEffect(() => {
if (user && user?.role !== 'admin') router.replace('/incidents')
}, [user, router])
if (!loading && user?.role !== 'admin') router.replace('/incidents')
}, [user, loading, router])

const columns = useMemo(
() => [
Expand Down

1 comment on commit 4510785

@vercel
Copy link

@vercel vercel bot commented on 4510785 Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer – ./

explorer-one.vercel.app
explorer-git-master-ooni1.vercel.app
explorer-ooni1.vercel.app

Please sign in to comment.