Skip to content

Commit e6882c4

Browse files
committed
delete works now
1 parent 3f7aa47 commit e6882c4

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

site/src/api/api.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,12 @@ class ApiMethods {
513513
return response.data;
514514
};
515515

516+
deleteOrganization = async (orgId: string) => {
517+
await this.axios.delete<TypesGen.Organization>(
518+
`/api/v2/organizations/${orgId}`,
519+
);
520+
};
521+
516522
getOrganization = async (
517523
organizationId: string,
518524
): Promise<TypesGen.Organization> => {
@@ -748,12 +754,10 @@ class ApiMethods {
748754
return response.data;
749755
};
750756

751-
deleteTemplate = async (templateId: string): Promise<TypesGen.Template> => {
752-
const response = await this.axios.delete<TypesGen.Template>(
757+
deleteTemplate = async (templateId: string) => {
758+
await this.axios.delete<TypesGen.Template>(
753759
`/api/v2/templates/${templateId}`,
754760
);
755-
756-
return response.data;
757761
};
758762

759763
getWorkspace = async (

site/src/api/queries/organizations.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ export const createOrganization = (queryClient: QueryClient) => {
1414
},
1515
};
1616
};
17+
18+
export const deleteOrganization = (queryClient: QueryClient) => {
19+
return {
20+
mutationFn: (orgId: string) => API.deleteOrganization(orgId),
21+
22+
onSuccess: async () => {
23+
await queryClient.invalidateQueries(meKey);
24+
await queryClient.invalidateQueries(myOrganizationsKey);
25+
},
26+
};
27+
};

site/src/pages/DeploySettingsPage/TeamsSettingsPage/TeamsSettingsPage.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import Button from "@mui/material/Button";
22
import { type FC, useState } from "react";
33
import { useMutation, useQuery, useQueryClient } from "react-query";
4-
import { createOrganization } from "api/queries/organizations";
4+
import {
5+
createOrganization,
6+
deleteOrganization,
7+
} from "api/queries/organizations";
58
import { myOrganizations } from "api/queries/users";
69
import { TextField } from "@mui/material";
710

811
const TeamsSettingsPage: FC = () => {
912
const queryClient = useQueryClient();
1013
const addTeamMutation = useMutation(createOrganization(queryClient));
14+
const deleteTeamMutation = useMutation(deleteOrganization(queryClient));
1115
const organizationsQuery = useQuery(myOrganizations());
1216
const [newOrgName, setNewOrgName] = useState("");
1317
return (
@@ -21,16 +25,12 @@ const TeamsSettingsPage: FC = () => {
2125
add new team
2226
</Button>
2327

28+
<div>{String(deleteTeamMutation.error)}</div>
29+
2430
{organizationsQuery.data?.map((org) => (
2531
<div key={org.id}>
2632
{org.name}{" "}
27-
<Button
28-
onClick={() =>
29-
console.log(
30-
"I tried to delete an org and all I got was this log message",
31-
)
32-
}
33-
>
33+
<Button onClick={() => deleteTeamMutation.mutate(org.id)}>
3434
Delete
3535
</Button>
3636
</div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy