diff --git a/packages/hoppscotch-common/src/components/teams/Team.vue b/packages/hoppscotch-common/src/components/teams/Team.vue index 123b63e74e..76b51bf4e7 100644 --- a/packages/hoppscotch-common/src/components/teams/Team.vue +++ b/packages/hoppscotch-common/src/components/teams/Team.vue @@ -131,6 +131,7 @@ @@ -161,6 +162,8 @@ import IconMoreVertical from "~icons/lucide/more-vertical" import IconUserX from "~icons/lucide/user-x" import IconUserPlus from "~icons/lucide/user-plus" import IconTrash2 from "~icons/lucide/trash-2" +import { useService } from "dioc/vue" +import { WorkspaceService } from "~/services/workspace.service" const t = useI18n() @@ -173,6 +176,7 @@ const props = defineProps<{ const emit = defineEmits<{ (e: "edit-team"): void (e: "invite-team"): void + (e: "refetch-teams"): void }>() const toast = useToast() @@ -180,7 +184,12 @@ const toast = useToast() const confirmRemove = ref(false) const confirmExit = ref(false) +const loading = ref(false) + +const workspaceService = useService(WorkspaceService) + const deleteTeam = () => { + loading.value = true pipe( backendDeleteTeam(props.teamID), TE.match( @@ -188,9 +197,25 @@ const deleteTeam = () => { // TODO: Better errors ? We know the possible errors now toast.error(`${t("error.something_went_wrong")}`) console.error(err) + loading.value = false + confirmRemove.value = false }, () => { toast.success(`${t("team.deleted")}`) + loading.value = false + emit("refetch-teams") + + const currentWorkspace = workspaceService.currentWorkspace.value + + // If the current workspace is the deleted workspace, change the workspace to personal + if ( + currentWorkspace.type === "team" && + currentWorkspace.teamID === props.teamID + ) { + workspaceService.changeWorkspace({ type: "personal" }) + } + + confirmRemove.value = false } ) )() // Tasks (and TEs) are lazy, so call the function returned diff --git a/packages/hoppscotch-common/src/components/teams/index.vue b/packages/hoppscotch-common/src/components/teams/index.vue index 2c3972ec5e..85c7206f9e 100644 --- a/packages/hoppscotch-common/src/components/teams/index.vue +++ b/packages/hoppscotch-common/src/components/teams/index.vue @@ -4,6 +4,7 @@
@@ -16,13 +17,6 @@ :alt="`${t('empty.teams')}`" :text="`${t('empty.teams')}`" > -
@@ -76,6 +71,7 @@ import { useReadonlyStream } from "@composables/stream" import { useColorMode } from "@composables/theming" import { WorkspaceService } from "~/services/workspace.service" import { useService } from "dioc/vue" +import IconPlus from "~icons/lucide/plus" const t = useI18n()