File tree Expand file tree Collapse file tree 3 files changed +27
-12
lines changed
pages/DeploySettingsPage/TeamsSettingsPage Expand file tree Collapse file tree 3 files changed +27
-12
lines changed Original file line number Diff line number Diff line change @@ -513,6 +513,12 @@ class ApiMethods {
513
513
return response . data ;
514
514
} ;
515
515
516
+ deleteOrganization = async ( orgId : string ) => {
517
+ await this . axios . delete < TypesGen . Organization > (
518
+ `/api/v2/organizations/${ orgId } ` ,
519
+ ) ;
520
+ } ;
521
+
516
522
getOrganization = async (
517
523
organizationId : string ,
518
524
) : Promise < TypesGen . Organization > => {
@@ -748,12 +754,10 @@ class ApiMethods {
748
754
return response . data ;
749
755
} ;
750
756
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 > (
753
759
`/api/v2/templates/${ templateId } ` ,
754
760
) ;
755
-
756
- return response . data ;
757
761
} ;
758
762
759
763
getWorkspace = async (
Original file line number Diff line number Diff line change @@ -14,3 +14,14 @@ export const createOrganization = (queryClient: QueryClient) => {
14
14
} ,
15
15
} ;
16
16
} ;
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
+ } ;
Original file line number Diff line number Diff line change 1
1
import Button from "@mui/material/Button" ;
2
2
import { type FC , useState } from "react" ;
3
3
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" ;
5
8
import { myOrganizations } from "api/queries/users" ;
6
9
import { TextField } from "@mui/material" ;
7
10
8
11
const TeamsSettingsPage : FC = ( ) => {
9
12
const queryClient = useQueryClient ( ) ;
10
13
const addTeamMutation = useMutation ( createOrganization ( queryClient ) ) ;
14
+ const deleteTeamMutation = useMutation ( deleteOrganization ( queryClient ) ) ;
11
15
const organizationsQuery = useQuery ( myOrganizations ( ) ) ;
12
16
const [ newOrgName , setNewOrgName ] = useState ( "" ) ;
13
17
return (
@@ -21,16 +25,12 @@ const TeamsSettingsPage: FC = () => {
21
25
add new team
22
26
</ Button >
23
27
28
+ < div > { String ( deleteTeamMutation . error ) } </ div >
29
+
24
30
{ organizationsQuery . data ?. map ( ( org ) => (
25
31
< div key = { org . id } >
26
32
{ 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 ) } >
34
34
Delete
35
35
</ Button >
36
36
</ div >
You can’t perform that action at this time.
0 commit comments