Add cedula number field to professional request form
Shows document type locked to 'Cédula de ciudadanía' and adds required number input field above the photo upload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
28511491af
commit
9634aa13ff
@@ -65,16 +65,19 @@ class _FormBody extends StatefulWidget {
|
|||||||
class _FormBodyState extends State<_FormBody> {
|
class _FormBodyState extends State<_FormBody> {
|
||||||
final _rethusCtrl = TextEditingController();
|
final _rethusCtrl = TextEditingController();
|
||||||
final _specCtrl = TextEditingController();
|
final _specCtrl = TextEditingController();
|
||||||
|
final _cedulaNumCtrl = TextEditingController();
|
||||||
String? _selectedProfession;
|
String? _selectedProfession;
|
||||||
List<String> _specs = [];
|
List<String> _specs = [];
|
||||||
bool _loading = false;
|
bool _loading = false;
|
||||||
bool _cedulaError = false;
|
bool _cedulaError = false;
|
||||||
|
bool _cedulaNumError = false;
|
||||||
bool _profError = false;
|
bool _profError = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_rethusCtrl.dispose();
|
_rethusCtrl.dispose();
|
||||||
_specCtrl.dispose();
|
_specCtrl.dispose();
|
||||||
|
_cedulaNumCtrl.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,13 +93,14 @@ class _FormBodyState extends State<_FormBody> {
|
|||||||
|
|
||||||
bool _validate(String cedulaUrl) {
|
bool _validate(String cedulaUrl) {
|
||||||
final cErr = cedulaUrl.isEmpty;
|
final cErr = cedulaUrl.isEmpty;
|
||||||
final pErr =
|
final nErr = _cedulaNumCtrl.text.trim().isEmpty;
|
||||||
_selectedProfession == null || _selectedProfession!.isEmpty;
|
final pErr = _selectedProfession == null || _selectedProfession!.isEmpty;
|
||||||
setState(() {
|
setState(() {
|
||||||
_cedulaError = cErr;
|
_cedulaError = cErr;
|
||||||
|
_cedulaNumError = nErr;
|
||||||
_profError = pErr;
|
_profError = pErr;
|
||||||
});
|
});
|
||||||
return !cErr && !pErr;
|
return !cErr && !nErr && !pErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _submit() async {
|
Future<void> _submit() async {
|
||||||
@@ -107,6 +111,7 @@ class _FormBodyState extends State<_FormBody> {
|
|||||||
setState(() => _loading = true);
|
setState(() => _loading = true);
|
||||||
try {
|
try {
|
||||||
fp.copyProfesionalWith(
|
fp.copyProfesionalWith(
|
||||||
|
identification: _cedulaNumCtrl.text.trim(),
|
||||||
profession: _selectedProfession,
|
profession: _selectedProfession,
|
||||||
rethusCode: _rethusCtrl.text.trim(),
|
rethusCode: _rethusCtrl.text.trim(),
|
||||||
specializations: _specs,
|
specializations: _specs,
|
||||||
@@ -228,30 +233,58 @@ class _FormBodyState extends State<_FormBody> {
|
|||||||
|
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
|
||||||
// ── 1. Foto / PDF de cédula (obligatorio) ──────────────────────────
|
// ── 1. Cédula (número + foto) ───────────────────────────────────────
|
||||||
_SectionCard(
|
_SectionCard(
|
||||||
cardBg: cardBg,
|
cardBg: cardBg,
|
||||||
border: border,
|
border: border,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_Label('Foto / PDF de cédula', Icons.badge_outlined,
|
_Label('Cédula de ciudadanía', Icons.badge_outlined, required: true),
|
||||||
required: true),
|
const SizedBox(height: 4),
|
||||||
const SizedBox(height: 12),
|
// Tipo fijo
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: isDark ? const Color(0xFF334155) : const Color(0xFFF1F5F9),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: border),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(Icons.lock_outline, size: 14, color: textSec),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text('Tipo: Cédula de ciudadanía', style: TextStyle(fontSize: 13, color: textSec)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
// Número
|
||||||
|
TextField(
|
||||||
|
controller: _cedulaNumCtrl,
|
||||||
|
keyboardType: TextInputType.number,
|
||||||
|
style: TextStyle(color: textPrimary, fontSize: 14),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: 'Número de cédula',
|
||||||
|
hintStyle: TextStyle(color: textSec, fontSize: 13),
|
||||||
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
|
||||||
|
errorText: _cedulaNumError ? 'Ingresa tu número de cédula' : null,
|
||||||
|
),
|
||||||
|
onChanged: (_) { if (_cedulaNumError) setState(() => _cedulaNumError = false); },
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
// Foto
|
||||||
_UploadTile(
|
_UploadTile(
|
||||||
label: cedulaUploaded
|
label: cedulaUploaded ? 'Foto de cédula subida ✓' : 'Subir foto o PDF de la cédula',
|
||||||
? 'Cédula subida ✓'
|
|
||||||
: 'Subir foto o PDF de la cédula',
|
|
||||||
uploaded: cedulaUploaded,
|
uploaded: cedulaUploaded,
|
||||||
onTap: () => _pickAndUpload(
|
onTap: () => _pickAndUpload((b) => fp.uploadPdfIdentification(b, user.id)),
|
||||||
(b) => fp.uploadPdfIdentification(b, user.id)),
|
|
||||||
),
|
),
|
||||||
if (_cedulaError)
|
if (_cedulaError)
|
||||||
const Padding(
|
const Padding(
|
||||||
padding: EdgeInsets.only(top: 8),
|
padding: EdgeInsets.only(top: 8),
|
||||||
child: Text('Debes subir la foto de tu cédula',
|
child: Text('Debes subir la foto de tu cédula',
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.redAccent, fontSize: 12)),
|
||||||
color: Colors.redAccent, fontSize: 12)),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user