fix with reflection of tags and assignees in details screen after creating job
This commit is contained in:
parent
d453ec40fc
commit
c6fbee7083
@ -62,27 +62,39 @@ class AddServiceProjectJobController extends GetxController {
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final assigneeIds = selectedAssignees.map((e) => e.id).toList();
|
||||
|
||||
|
||||
isLoading.value = true;
|
||||
|
||||
final success = await ApiService.createServiceProjectJobApi(
|
||||
final jobId = await ApiService.createServiceProjectJobApi(
|
||||
title: titleCtrl.text.trim(),
|
||||
description: descCtrl.text.trim(),
|
||||
projectId: projectId,
|
||||
branchId: selectedBranch.value?.id,
|
||||
assignees: assigneeIds.map((id) => {"id": id}).toList(),
|
||||
branchId: selectedBranch.value?.id,
|
||||
assignees: selectedAssignees // payload mapping
|
||||
.map((e) => {"employeeId": e.id, "isActive": true})
|
||||
.toList(),
|
||||
startDate: startDate.value!,
|
||||
dueDate: dueDate.value!,
|
||||
tags: enteredTags.map((tag) => {"name": tag}).toList(),
|
||||
tags: enteredTags
|
||||
.map((tag) => {
|
||||
"id": null,
|
||||
"name": tag,
|
||||
"isActive": true
|
||||
})
|
||||
.toList(),
|
||||
);
|
||||
|
||||
isLoading.value = false;
|
||||
|
||||
if (success) {
|
||||
if (jobId != null) {
|
||||
if (Get.isRegistered<ServiceProjectDetailsController>()) {
|
||||
Get.find<ServiceProjectDetailsController>().refreshJobsAfterAdd();
|
||||
final detailsCtrl = Get.find<ServiceProjectDetailsController>();
|
||||
|
||||
// 🔥 1. Refresh job LIST
|
||||
detailsCtrl.refreshJobsAfterAdd();
|
||||
|
||||
// 🔥 2. Refresh job DETAILS (FULL DATA - including tags and assignees)
|
||||
await detailsCtrl.fetchJobDetail(jobId);
|
||||
}
|
||||
|
||||
Get.back();
|
||||
|
||||
@ -595,8 +595,7 @@ class ApiService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Create a new Service Project Job
|
||||
static Future<bool> createServiceProjectJobApi({
|
||||
static Future<String?> createServiceProjectJobApi({
|
||||
required String title,
|
||||
required String description,
|
||||
required String projectId,
|
||||
@ -623,32 +622,22 @@ class ApiService {
|
||||
try {
|
||||
final response = await _postRequest(endpoint, body);
|
||||
|
||||
if (response == null) {
|
||||
logSafe("Create Service Project Job failed: null response",
|
||||
level: LogLevel.error);
|
||||
return false;
|
||||
}
|
||||
|
||||
logSafe(
|
||||
"Create Service Project Job response status: ${response.statusCode}");
|
||||
logSafe("Create Service Project Job response body: ${response.body}");
|
||||
if (response == null) return null;
|
||||
|
||||
final json = jsonDecode(response.body);
|
||||
|
||||
if (json['success'] == true) {
|
||||
logSafe("Service Project Job created successfully: ${json['data']}");
|
||||
return true;
|
||||
} else {
|
||||
logSafe(
|
||||
"Failed to create Service Project Job: ${json['message'] ?? 'Unknown error'}",
|
||||
level: LogLevel.warning,
|
||||
);
|
||||
return false;
|
||||
final jobId = json['data']?['id'];
|
||||
logSafe("Service Project Job created successfully: $jobId");
|
||||
return jobId;
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (e, stack) {
|
||||
logSafe("Exception during createServiceProjectJobApi: $e",
|
||||
level: LogLevel.error);
|
||||
logSafe("StackTrace: $stack", level: LogLevel.debug);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -671,8 +660,7 @@ class ApiService {
|
||||
'pageNumber': pageNumber.toString(),
|
||||
'pageSize': pageSize.toString(),
|
||||
'isActive': isActive.toString(),
|
||||
if (isArchive)
|
||||
'isArchive': 'true',
|
||||
if (isArchive) 'isArchive': 'true',
|
||||
};
|
||||
|
||||
final response = await _getRequest(endpoint, queryParams: queryParams);
|
||||
|
||||
@ -248,6 +248,44 @@ class _UserProfileBarState extends State<UserProfileBar>
|
||||
final tenants = tenantSwitchController.tenants;
|
||||
if (tenants.isEmpty) return _noTenantContainer();
|
||||
|
||||
// If only one organization, don't show switch option
|
||||
if (tenants.length == 1) {
|
||||
final selectedTenant = tenants.first;
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: Colors.grey.shade300, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
ClipRRect(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Container(
|
||||
width: 20,
|
||||
height: 20,
|
||||
color: Colors.grey.shade200,
|
||||
child: TenantLogo(logoImage: selectedTenant.logoImage),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
selectedTenant.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: contentTheme.primary),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.check_circle, color: Colors.green, size: 18),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
final selectedTenant = TenantService.currentTenant;
|
||||
|
||||
final sortedTenants = List.of(tenants);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user