diff options
| author | Fuwn <[email protected]> | 2026-01-24 13:09:50 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-24 13:09:50 +0000 |
| commit | 396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b (patch) | |
| tree | b9df4ca6a70db45cfffbae6fdd7252e20fb8e93c /src/app/(main)/teams/TeamLeaveButton.tsx | |
| download | umami-main.tar.xz umami-main.zip | |
Created from https://vercel.com/new
Diffstat (limited to 'src/app/(main)/teams/TeamLeaveButton.tsx')
| -rw-r--r-- | src/app/(main)/teams/TeamLeaveButton.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/app/(main)/teams/TeamLeaveButton.tsx b/src/app/(main)/teams/TeamLeaveButton.tsx new file mode 100644 index 0000000..2cca76f --- /dev/null +++ b/src/app/(main)/teams/TeamLeaveButton.tsx @@ -0,0 +1,41 @@ +import { Button, Dialog, DialogTrigger, Icon, Modal, Text } from '@umami/react-zen'; +import { useRouter } from 'next/navigation'; +import { useLoginQuery, useMessages, useModified } from '@/components/hooks'; +import { LogOut } from '@/components/icons'; +import { TeamLeaveForm } from './TeamLeaveForm'; + +export function TeamLeaveButton({ teamId, teamName }: { teamId: string; teamName: string }) { + const { formatMessage, labels } = useMessages(); + const router = useRouter(); + const { user } = useLoginQuery(); + const { touch } = useModified(); + + const handleLeave = async () => { + touch('teams'); + router.push('/settings/teams'); + }; + + return ( + <DialogTrigger> + <Button> + <Icon> + <LogOut /> + </Icon> + <Text>{formatMessage(labels.leave)}</Text> + </Button> + <Modal> + <Dialog title={formatMessage(labels.leaveTeam)} style={{ width: 400 }}> + {({ close }) => ( + <TeamLeaveForm + teamId={teamId} + userId={user.id} + teamName={teamName} + onSave={handleLeave} + onClose={close} + /> + )} + </Dialog> + </Modal> + </DialogTrigger> + ); +} |