mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
Get users on page mount
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { useActor } from "@xstate/react"
|
||||
import React, { useContext } from "react"
|
||||
import React, { useContext, useEffect } from "react"
|
||||
import { useNavigate } from "react-router"
|
||||
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
|
||||
import { XServiceContext } from "../../xServices/StateContext"
|
||||
@ -7,10 +7,17 @@ import { UsersPageView } from "./UsersPageView"
|
||||
|
||||
export const UsersPage: React.FC = () => {
|
||||
const xServices = useContext(XServiceContext)
|
||||
const [usersState] = useActor(xServices.usersXService)
|
||||
const [usersState, usersSend] = useActor(xServices.usersXService)
|
||||
const { users, pager, getUsersError } = usersState.context
|
||||
const navigate = useNavigate()
|
||||
|
||||
/**
|
||||
* Fetch users on component mount
|
||||
*/
|
||||
useEffect(() => {
|
||||
usersSend("GET_USERS")
|
||||
}, [])
|
||||
|
||||
if (usersState.matches("error")) {
|
||||
return <ErrorSummary error={getUsersError} />
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user