parent
61ab08e13c
commit
fdd6811af8
@ -0,0 +1,50 @@
|
||||
import React from 'react'
|
||||
import {
|
||||
Button,
|
||||
Popover,
|
||||
PopoverArrow,
|
||||
PopoverBody,
|
||||
PopoverCloseButton,
|
||||
PopoverContent,
|
||||
PopoverHeader,
|
||||
PopoverTrigger,
|
||||
ButtonProps,
|
||||
Link,
|
||||
} from '@chakra-ui/react'
|
||||
|
||||
const DisconnectButton: React.FC<ButtonProps> = (props) => {
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger>
|
||||
<Button variant="ghost" color="gray.500" size="sm" {...props}>
|
||||
Desconectarse
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent>
|
||||
<PopoverArrow />
|
||||
<PopoverCloseButton />
|
||||
<PopoverHeader>Confirmación</PopoverHeader>
|
||||
<PopoverBody textAlign="center">
|
||||
¿Estás segur@ de que querés desconectarte?
|
||||
</PopoverBody>
|
||||
<Link
|
||||
href="/auth/logout"
|
||||
display="block"
|
||||
textAlign="center"
|
||||
fontWeight="bold"
|
||||
color="red.500"
|
||||
size="sm"
|
||||
py="0.5rem"
|
||||
textDecoration="none"
|
||||
_hover={{
|
||||
backgroundColor: 'red.50',
|
||||
}}
|
||||
>
|
||||
Desconectarse
|
||||
</Link>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
||||
export default DisconnectButton
|
@ -0,0 +1,24 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
function useLogin<T>(url: string) {
|
||||
const [response, setResponse] = useState<T>()
|
||||
const [error, setError] = useState(null)
|
||||
const [isLoading, setIsLoading] = useState(true)
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
setIsLoading(true)
|
||||
try {
|
||||
const res = await fetch(url)
|
||||
const json = await res.json()
|
||||
setResponse(json)
|
||||
setIsLoading(false)
|
||||
} catch (error) {
|
||||
setError(error)
|
||||
}
|
||||
}
|
||||
fetchData()
|
||||
}, [])
|
||||
return { response, error, isLoading }
|
||||
}
|
||||
|
||||
export default useLogin
|
Loading…
Reference in new issue