feat: Refactor group deletion logic to use tripId and add reset trips functionality
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:travel_mate/blocs/group/group_bloc.dart';
|
||||
import 'package:travel_mate/blocs/group/group_event.dart';
|
||||
import 'package:travel_mate/blocs/trip/trip_bloc.dart';
|
||||
import 'package:travel_mate/blocs/trip/trip_event.dart';
|
||||
import 'package:travel_mate/components/home/create_trip_content.dart';
|
||||
import 'package:travel_mate/data/models/trip.dart';
|
||||
|
||||
@@ -92,8 +97,8 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => CreateTripContent(
|
||||
tripToEdit: widget.trip,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -117,6 +122,54 @@ class _ShowTripDetailsContentState extends State<ShowTripDetailsContent> {
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
height: 50,
|
||||
child: ElevatedButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: Text('Confirmer la suppression'),
|
||||
content: Text(
|
||||
'Êtes-vous sûr de vouloir supprimer ce voyage ? Cette action est irréversible.'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text('Annuler'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.read<TripBloc>().add(TripDeleteRequested(tripId: widget.trip.id!));
|
||||
context.read<GroupBloc>().add(DeleteGroup(widget.trip.id!));
|
||||
Navigator.pop(context); // Fermer le dialogue
|
||||
},
|
||||
child: Text(
|
||||
'Supprimer',
|
||||
style: TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.red,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'Supprimer le voyage',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user