fixed date pickering issue
This commit is contained in:
parent
502bb1e2d9
commit
8d688f2575
@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:marco/controller/finance/add_payment_request_controller.dart';
|
||||
import 'package:marco/helpers/utils/mixins/ui_mixin.dart';
|
||||
import 'package:marco/helpers/utils/base_bottom_sheet.dart';
|
||||
@ -57,14 +58,22 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
||||
if (widget.isEdit && widget.existingData != null) {
|
||||
final data = widget.existingData!;
|
||||
|
||||
// 🧩 Prefill basic text fields
|
||||
// Prefill text fields
|
||||
controller.titleController.text = data["title"] ?? "";
|
||||
controller.amountController.text = data["amount"]?.toString() ?? "";
|
||||
controller.descriptionController.text = data["description"] ?? "";
|
||||
controller.dueDateController.text =
|
||||
data["dueDate"]?.toString().split(" ")[0] ?? "";
|
||||
|
||||
// 🧩 Prefill dropdowns & toggles
|
||||
// Prefill due date
|
||||
if (data["dueDate"] != null && data["dueDate"].toString().isNotEmpty) {
|
||||
DateTime? dueDate = DateTime.tryParse(data["dueDate"].toString());
|
||||
if (dueDate != null) {
|
||||
controller.selectedDueDate.value = dueDate;
|
||||
controller.dueDateController.text =
|
||||
DateFormat('dd MMM yyyy').format(dueDate);
|
||||
}
|
||||
}
|
||||
|
||||
// Prefill dropdowns & toggles
|
||||
controller.selectedProject.value = {
|
||||
'id': data["projectId"],
|
||||
'name': data["projectName"],
|
||||
@ -72,7 +81,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
||||
controller.selectedPayee.value = data["payee"] ?? "";
|
||||
controller.isAdvancePayment.value = data["isAdvancePayment"] ?? false;
|
||||
|
||||
// 🕒 Wait until categories & currencies are loaded before setting them
|
||||
// Categories & currencies
|
||||
everAll([controller.categories, controller.currencies], (_) {
|
||||
controller.selectedCategory.value = controller.categories
|
||||
.firstWhereOrNull((c) => c.id == data["expenseCategoryId"]);
|
||||
@ -80,7 +89,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
||||
.firstWhereOrNull((c) => c.id == data["currencyId"]);
|
||||
});
|
||||
|
||||
// 🖇 Attachments
|
||||
// Attachments
|
||||
final attachmentsData = data["attachments"];
|
||||
if (attachmentsData != null &&
|
||||
attachmentsData is List &&
|
||||
@ -88,13 +97,13 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
||||
final attachments = attachmentsData
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map((a) => {
|
||||
"id": a["documentId"] ?? a["id"], // map documentId to id
|
||||
"id": a["documentId"] ?? a["id"],
|
||||
"fileName": a["fileName"],
|
||||
"url": a["url"],
|
||||
"thumbUrl": a["thumbUrl"],
|
||||
"fileSize": a["fileSize"] ?? 0,
|
||||
"contentType": a["contentType"] ?? "",
|
||||
"isActive": true, // ensure active by default
|
||||
"isActive": true,
|
||||
})
|
||||
.toList();
|
||||
controller.existingAttachments.assignAll(attachments);
|
||||
@ -104,6 +113,7 @@ class _PaymentRequestBottomSheetState extends State<_PaymentRequestBottomSheet>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Obx(() => Form(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user