go back to team settings on team delete

This commit is contained in:
Francis Cao 2024-02-07 11:43:00 -08:00
parent 0016a9f4e1
commit 8969a010e8
2 changed files with 13 additions and 5 deletions

View File

@ -1,9 +1,17 @@
import { ActionForm, Button, Modal, ModalTrigger } from 'react-basics';
import { useMessages } from 'components/hooks';
import { useRouter } from 'next/navigation';
import { ActionForm, Button, Modal, ModalTrigger } from 'react-basics';
import TeamDeleteForm from './TeamDeleteForm';
import { touch } from 'store/modified';
export function TeamAdmin({ teamId }: { teamId: string }) {
const { formatMessage, labels, messages } = useMessages();
const router = useRouter();
const handleLeave = async () => {
touch('teams');
router.push('/settings/teams');
};
return (
<ActionForm
@ -13,7 +21,9 @@ export function TeamAdmin({ teamId }: { teamId: string }) {
<ModalTrigger>
<Button variant="danger">{formatMessage(labels.delete)}</Button>
<Modal title={formatMessage(labels.deleteTeam)}>
{(close: () => void) => <TeamDeleteForm teamId={teamId} onClose={close} />}
{(close: () => void) => (
<TeamDeleteForm teamId={teamId} onSave={handleLeave} onClose={close} />
)}
</Modal>
</ModalTrigger>
</ActionForm>

View File

@ -1,6 +1,5 @@
import { useApi, useMessages } from 'components/hooks';
import { touch } from 'store/modified';
import TypeConfirmationForm from 'components/common/TypeConfirmationForm';
import { useApi, useMessages } from 'components/hooks';
const CONFIRM_VALUE = 'DELETE';
@ -22,7 +21,6 @@ export function TeamDeleteForm({
const handleConfirm = async () => {
mutate(null, {
onSuccess: async () => {
touch('teams');
onSave?.();
onClose?.();
},