From f1de5e3b3aa6603f45665669aa97aa337d39d237 Mon Sep 17 00:00:00 2001
From: Jake Barnby
Date: Wed, 25 Jan 2023 13:50:28 +1300
Subject: [PATCH] Delete projects when deleting an organisation
---
.../deleteOrganization.svelte | 35 ++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/routes/console/organization-[organization]/deleteOrganization.svelte b/src/routes/console/organization-[organization]/deleteOrganization.svelte
index 8f6be48cc..65b28e4ef 100644
--- a/src/routes/console/organization-[organization]/deleteOrganization.svelte
+++ b/src/routes/console/organization-[organization]/deleteOrganization.svelte
@@ -8,12 +8,26 @@
import { base } from '$app/paths';
import { Dependencies } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
+ import { Query } from "@aw-labs/appwrite-console";
+ import { FormList, InputPassword, InputText } from "$lib/elements/forms/index.js";
export let showDelete = false;
+ let password: string = null;
+ let name: string = null;
+
const deleteOrg = async () => {
try {
await sdkForConsole.teams.delete($organization.$id);
+
+ const projectList = await sdkForConsole.projects.list([
+ Query.equal('teamId', $organization.$id),
+ ])
+
+ await Promise.all(projectList.projects.map(async (project) => {
+ await sdkForConsole.projects.delete(project.$id, password);
+ }));
+
addNotification({
type: 'success',
message: `${$organization.name} has been deleted`
@@ -42,8 +56,27 @@
Are you sure you want to delete {$organization.name}? All projects ({$organization.total})
and data associated with this organization will be deleted. This action is irreversible.
+
+
+
+
+
-
+