File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
(dashboard)/projects/[projectId]/configuration Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,15 @@ export default function ProjectConfigurationPage({ params }: PageProps) {
66
66
}
67
67
} ;
68
68
69
+ const handleDeleteProject = async ( ) => {
70
+ const { data } = await axios . delete ( `/api/projects?team_id=${ teamId } ` ) ;
71
+ if ( data . success ) {
72
+ router . push ( `/projects` ) ;
73
+ } else {
74
+ console . log ( "Error deleting project" ) ;
75
+ }
76
+ } ;
77
+
69
78
const handleCalculate = async ( ) => {
70
79
const { data } = await axios . get ( `/api/credmanager?team_id=${ team ! . id } ` ) ;
71
80
if ( data && data . success ) {
@@ -108,6 +117,15 @@ export default function ProjectConfigurationPage({ params }: PageProps) {
108
117
>
109
118
Save
110
119
</ Button >
120
+ < Button
121
+ variant = { "destructive" }
122
+ className = "ml-3"
123
+ onClick = { ( ) => {
124
+ handleDeleteProject ( ) ;
125
+ } }
126
+ >
127
+ Delete Project
128
+ </ Button >
111
129
</ div >
112
130
</ >
113
131
) }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { fetchUserTeam } from "../teams/fetchTeam";
5
5
import { fetchUserTeams } from "../teams/fetchUserTeams" ;
6
6
import { ProjectRegisterDto } from "./types/project.dto" ;
7
7
import { registerUserTeam } from "../teams/registerUserTeam" ;
8
+ import { deleteTeam } from "../teams/deleteTeam" ;
8
9
9
10
export async function GET ( req : NextRequest ) {
10
11
const session = await getServerSession ( options ) ;
@@ -26,6 +27,20 @@ export async function GET(req: NextRequest) {
26
27
}
27
28
}
28
29
30
+ export async function DELETE ( req : NextRequest ) {
31
+ try {
32
+ const session = await getServerSession ( options ) ;
33
+ const teamId = req . nextUrl . searchParams . get ( "team_id" ) ;
34
+ if ( teamId && session ?. userId ) {
35
+ await deleteTeam ( teamId , session . userId ) ;
36
+ return NextResponse . json ( { success : true } ) ;
37
+ }
38
+ } catch ( error ) {
39
+ console . log ( error ) ;
40
+ return NextResponse . json ( { success : false } ) ;
41
+ }
42
+ }
43
+
29
44
export async function POST ( req : NextRequest ) {
30
45
try {
31
46
const session = await getServerSession ( options ) ;
You can’t perform that action at this time.
0 commit comments