fix chat
This commit is contained in:
+36
-16
@@ -236,23 +236,43 @@ class _CitaScreenState extends State<CitaScreen> {
|
||||
const SizedBox(width: 20),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await FirebaseFirestore.instance
|
||||
.collection('chats')
|
||||
.doc(widget.evento.id)
|
||||
.set({
|
||||
'professional_id': widget.evento.professionalId,
|
||||
'user_id': widget.evento.userId
|
||||
}, SetOptions(merge: true)).catchError((error) =>
|
||||
print('Error al crear el documento: $error'));
|
||||
if (widget.evento.status != 'pendiente') {
|
||||
await FirebaseFirestore.instance
|
||||
.collection('chats')
|
||||
.doc(widget.evento.id)
|
||||
.set({
|
||||
'professional_id': widget.evento.professionalId,
|
||||
'user_id': widget.evento.userId,
|
||||
'message': [],
|
||||
}, SetOptions(merge: true)).catchError((error) =>
|
||||
print('Error al crear el documento: $error'));
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return ChatScreen(eventoId: widget.evento.id);
|
||||
},
|
||||
),
|
||||
);
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute(
|
||||
builder: (BuildContext context) {
|
||||
return ChatScreen(eventoId: widget.evento.id);
|
||||
},
|
||||
),
|
||||
);
|
||||
} else {
|
||||
final snackBar = SnackBar(
|
||||
backgroundColor: Colors.blue,
|
||||
content: const Text(
|
||||
'Primero acepta la solicitud',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
elevation: 8.0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
},
|
||||
style: ElevatedButton.styleFrom(
|
||||
foregroundColor: const Color(0xFF2BA4EC),
|
||||
|
||||
Reference in New Issue
Block a user