feat: Disable and load button while is connecting to the server

This commit is contained in:
Kevin Szuchet 2023-08-09 12:35:58 +02:00
parent d9e0082ade
commit 8ba22fa750
No known key found for this signature in database
GPG Key ID: 1E083BC33700E594

View File

@ -17,7 +17,7 @@ function ConnectToWorld(props: Props) {
const [selectedServer, setSelectedServer] = useState('')
const [error, setError] = useState<string>('')
const [availableServers, setAvailableServers] = useState<string[]>([])
const [isConnectingToServer] = useState(false)
const [isConnectingToServer, setIsConnectingToServer] = useState(false)
const { isLoading, loggedInAddress, identity, previouslyLoadedServers, worldsContentServerUrl, onSubmitConnectForm } = props
@ -96,6 +96,7 @@ function ConnectToWorld(props: Props) {
async (event: React.MouseEvent<HTMLButtonElement>) => {
event.preventDefault()
setError('')
setIsConnectingToServer(true)
try {
if (!identity) return
@ -114,7 +115,7 @@ function ConnectToWorld(props: Props) {
return (
<PageLayout>
{isLoading || isConnectingToServer ? (
{isLoading ? (
<Loader active />
) : (
<div className={styles.ConnectToWorld}>
@ -157,7 +158,14 @@ function ConnectToWorld(props: Props) {
/>
)}
</div>
<Button primary onClick={handleClick} fluid disabled={!selectedServer} type="submit">
<Button
primary
onClick={handleClick}
fluid
disabled={!selectedServer || isConnectingToServer}
type="submit"
loading={isConnectingToServer}
>
{t('connect_to_world.cta')}
</Button>
</Form>