@@ -11,7 +11,7 @@ import { TeamResponse } from "generatedApi";
1111import { Sheet } from "@ui/Sheet" ;
1212import { Button } from "@ui/Button" ;
1313import { ConfirmationDialog } from "@ui/ConfirmationDialog" ;
14- import { useState } from "react" ;
14+ import { useCallback , useState } from "react" ;
1515import startCase from "lodash/startCase" ;
1616import { OpenInVercel } from "components/OpenInVercel" ;
1717import { TeamForm } from "./TeamForm" ;
@@ -23,8 +23,15 @@ export function TeamSettings({ team }: { team: TeamResponse }) {
2323 const teamMembers = useTeamMembers ( team . id ) ;
2424 const projects = useProjects ( team . id ) ;
2525 const [ showDeleteTeamModal , setShowDeleteTeamModal ] = useState ( false ) ;
26- const deleteTeam = useDeleteTeam ( team . id ) ;
2726 const { subscription } = useTeamOrbSubscription ( team . id ) ;
27+
28+ const deleteTeam = useDeleteTeam ( team . id ) ;
29+ const deleteTeamAndRedirect = useCallback ( async ( ) => {
30+ await deleteTeam ( ) ;
31+ // Completely reload the page to avoid race conditions
32+ window . location . href = "/" ;
33+ } , [ deleteTeam ] ) ;
34+
2835 return (
2936 < >
3037 < h2 > Team Settings</ h2 >
@@ -93,7 +100,7 @@ export function TeamSettings({ team }: { team: TeamResponse }) {
93100 { showDeleteTeamModal && (
94101 < ConfirmationDialog
95102 onClose = { ( ) => setShowDeleteTeamModal ( false ) }
96- onConfirm = { deleteTeam }
103+ onConfirm = { deleteTeamAndRedirect }
97104 validationText = { team . slug }
98105 confirmText = "Delete"
99106 dialogTitle = "Delete Team"
0 commit comments