@@ -98,10 +98,7 @@ import {
9898
9999 <DropdownMenuItem
100100 class="text-red-600"
101- @click ="
102- deleteAlertDialogs [stageNumber ] = true ;
103- stageMenus [stageNumber ] = false ;
104- "
101+ @click =" openDeleteDialog (stageNumber )"
105102 >
106103 <Trash class="mr-2 h-4 w-4 inline" />
107104 {{ $t("tournament.stage.delete") }}
@@ -160,6 +157,8 @@ import {
160157 <CardContent >
161158 <TournamentStageForm
162159 :order =" tournament .stages .length + 1 "
160+ :tournament-id =" tournament .id "
161+ :tournament =" tournament "
163162 ></TournamentStageForm >
164163 </CardContent >
165164 </Card >
@@ -196,6 +195,8 @@ import {
196195 v-if =" getFirstStageForTab (stageNumber )"
197196 :stage =" getFirstStageForTab (stageNumber )"
198197 :order =" stageNumber "
198+ :tournament-id =" tournament .id "
199+ :tournament =" tournament "
199200 @updated =" editStageDialogs [stageNumber ] = false "
200201 ></TournamentStageForm >
201202 </SheetDescription >
@@ -207,10 +208,9 @@ import {
207208 <AlertDialog
208209 v-for =" stageNumber in maxStageNumber "
209210 :key =" ` delete-${stageNumber } ` "
210- :open =" deleteAlertDialogs [stageNumber ]"
211+ :open =" !! deleteAlertDialogs [stageNumber ]"
211212 @update :open =" (open ) => (deleteAlertDialogs [stageNumber ] = open ) "
212213 >
213- <AlertDialogTrigger class="w-full"> </AlertDialogTrigger >
214214 <AlertDialogContent >
215215 <AlertDialogHeader >
216216 <AlertDialogTitle >{{
@@ -221,12 +221,12 @@ import {
221221 </AlertDialogDescription >
222222 </AlertDialogHeader >
223223 <AlertDialogFooter >
224- <AlertDialogCancel >{{ $t("common.cancel") }}</AlertDialogCancel >
224+ <AlertDialogCancel @click =" deleteAlertDialogs [stageNumber ] = false " >
225+ {{ $t("common.cancel") }}
226+ </AlertDialogCancel >
225227 <AlertDialogAction
226- @click ="
227- deleteStage (getFirstStageForTab (stageNumber ));
228- deleteAlertDialogs [stageNumber ] = false ;
229- "
228+ @click =" confirmDeleteStage (stageNumber )"
229+ class="bg-destructive text-destructive-foreground hover:bg-destructive /90"
230230 >
231231 {{ $t("common.confirm") }}
232232 </AlertDialogAction >
@@ -266,6 +266,7 @@ import {
266266
267267<script lang="ts">
268268import { generateMutation } from " ~/graphql/graphqlGen" ;
269+ import { toast } from " @/components/ui/toast" ;
269270
270271export default {
271272 props: {
@@ -301,9 +302,35 @@ export default {
301302 );
302303 return stages .length > 0 ? stages [0 ] : null ;
303304 },
305+ openDeleteDialog(stageNumber : number ) {
306+ this .stageMenus [stageNumber ] = false ;
307+ this .deleteAlertDialogs [stageNumber ] = true ;
308+ },
309+ async confirmDeleteStage(stageNumber : number ) {
310+ const stage = this .getFirstStageForTab (stageNumber );
311+ if (! stage ) {
312+ this .deleteAlertDialogs [stageNumber ] = false ;
313+ return ;
314+ }
315+
316+ try {
317+ await this .deleteStage (stage );
318+ toast ({
319+ title: this .$t (" tournament.stage.deleted" ),
320+ });
321+ this .deleteAlertDialogs [stageNumber ] = false ;
322+ } catch (error ) {
323+ console .error (" Failed to delete stage:" , error );
324+ toast ({
325+ title: this .$t (" tournament.stage.delete_failed" ),
326+ variant: " destructive" ,
327+ });
328+ // Keep dialog open on error so user can try again
329+ }
330+ },
304331 async deleteStage(stage : any ) {
305332 if (! stage ) return ;
306- await this .$apollo .mutate ({
333+ await ( this as any ) .$apollo .mutate ({
307334 mutation: generateMutation ({
308335 delete_tournament_stages_by_pk: [
309336 {
0 commit comments