Files
web/src/app/admin/_client/profile.tsx

28 lines
712 B
TypeScript

'use client'
import {Button} from '@/components/ui/button'
import {logout} from '@/actions/auth'
import {useProfileStore} from '@/components/providers/StoreProvider'
import {useRouter} from 'next/navigation'
export type ProfileProps = {}
export default function Profile(props: ProfileProps) {
const router = useRouter()
const refreshProfile = useProfileStore(store => store.refreshProfile)
const doLogout = async () => {
const resp = await logout()
if (resp.success) {
refreshProfile().then()
router.replace('/')
}
}
return (
<div className="flex gap-2 items-center">
<Button theme={`fail`} onClick={doLogout}>
退
</Button>
</div>
)
}