feat: sugerencias como diálogo in-app con JWT en lugar de abrir browser
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
4951f82621
commit
a2bcc8d86d
@@ -1,5 +1,6 @@
|
||||
import 'package:prosapp_web_app/models/setting.dart';
|
||||
import 'package:prosapp_web_app/providers/settings_provider.dart';
|
||||
import 'package:prosapp_web_app/services/api_service.dart';
|
||||
import 'package:prosapp_web_app/ui/cards/white_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:prosapp_web_app/ui/labels/custom_labels.dart';
|
||||
@@ -34,9 +35,81 @@ class SupportView extends StatelessWidget {
|
||||
await _launchURL(url);
|
||||
}
|
||||
|
||||
Future<void> _goSugerencias() async {
|
||||
const url = 'https://admin.prosapp.co/sugerencias';
|
||||
await _launchURL(url);
|
||||
Future<void> _goSugerencias(BuildContext context) async {
|
||||
final controller = TextEditingController();
|
||||
final api = ApiService.instance;
|
||||
bool sending = false;
|
||||
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (ctx) => StatefulBuilder(
|
||||
builder: (ctx, setState) => AlertDialog(
|
||||
title: const Text('Enviar sugerencia'),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Text(
|
||||
'Cuéntanos cómo podemos mejorar ProsApp',
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextField(
|
||||
controller: controller,
|
||||
maxLines: 4,
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Escribe tu sugerencia aquí...',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: sending ? null : () => Navigator.pop(ctx),
|
||||
child: const Text('Cancelar'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: sending
|
||||
? null
|
||||
: () async {
|
||||
final msg = controller.text.trim();
|
||||
if (msg.isEmpty) return;
|
||||
setState(() => sending = true);
|
||||
try {
|
||||
await api.post('/suggestions', {'message': msg});
|
||||
if (ctx.mounted) {
|
||||
Navigator.pop(ctx);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('¡Gracias por tu sugerencia!'),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (_) {
|
||||
setState(() => sending = false);
|
||||
if (ctx.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('Error al enviar. Intenta de nuevo.'),
|
||||
backgroundColor: Colors.red,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: sending
|
||||
? const SizedBox(
|
||||
width: 16,
|
||||
height: 16,
|
||||
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
|
||||
)
|
||||
: const Text('Enviar'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _goPoliticas(String urlText) async {
|
||||
@@ -137,7 +210,7 @@ class SupportView extends StatelessWidget {
|
||||
context,
|
||||
icon: Icons.feedback,
|
||||
text: 'Sugerencias',
|
||||
onPressed: _goSugerencias,
|
||||
onPressed: () => _goSugerencias(context),
|
||||
),
|
||||
_buildGridButton(
|
||||
context,
|
||||
|
||||
Reference in New Issue
Block a user