blob: 2cca76f86d7f42c2ed56562676f60a429c8d1a92 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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>
);
}
|