logout button
This commit is contained in:
@@ -17,7 +17,7 @@ interface ProfileProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Profile({ onBack }: ProfileProps) {
|
export default function Profile({ onBack }: ProfileProps) {
|
||||||
const { currentUser, loading, error, token, refreshAuthors, updateProfile } = useAuth();
|
const { currentUser, loading, error, logout, updateProfile } = useAuth();
|
||||||
const [formData, setFormData] = React.useState({
|
const [formData, setFormData] = React.useState({
|
||||||
username: currentUser?.username || '',
|
username: currentUser?.username || '',
|
||||||
name: currentUser?.name || '',
|
name: currentUser?.name || '',
|
||||||
@@ -56,6 +56,10 @@ export default function Profile({ onBack }: ProfileProps) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleLogout = async () => {
|
||||||
|
logout()
|
||||||
|
}
|
||||||
|
|
||||||
if (!currentUser) {
|
if (!currentUser) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
@@ -161,6 +165,15 @@ export default function Profile({ onBack }: ProfileProps) {
|
|||||||
>
|
>
|
||||||
{saving ? <CircularProgress size={24} color="inherit" /> : 'Save Changes'}
|
{saving ? <CircularProgress size={24} color="inherit" /> : 'Save Changes'}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
fullWidth
|
||||||
|
variant="contained"
|
||||||
|
color="error"
|
||||||
|
sx={{ mt: 3 }}
|
||||||
|
onClick={handleLogout}
|
||||||
|
>
|
||||||
|
Logout
|
||||||
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user