Fixed IT Job showing without Service
This commit is contained in:
parent
e75d61ac64
commit
9bad41a5ee
|
|
@ -178,7 +178,6 @@ class _OfficesScreenState extends ConsumerState<OfficesScreen> {
|
||||||
bool saving = false;
|
bool saving = false;
|
||||||
return StatefulBuilder(
|
return StatefulBuilder(
|
||||||
builder: (context, setState) {
|
builder: (context, setState) {
|
||||||
final servicesAsync = ref.watch(servicesOnceProvider);
|
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
shape: AppSurfaces.of(context).dialogShape,
|
shape: AppSurfaces.of(context).dialogShape,
|
||||||
title: Text(office == null ? 'Create Office' : 'Edit Office'),
|
title: Text(office == null ? 'Create Office' : 'Edit Office'),
|
||||||
|
|
|
||||||
|
|
@ -394,19 +394,34 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
|
||||||
final assignmentList = assignments;
|
final assignmentList = assignments;
|
||||||
final profilesList =
|
final profilesList =
|
||||||
profilesAsync.valueOrNull ?? <Profile>[];
|
profilesAsync.valueOrNull ?? <Profile>[];
|
||||||
|
|
||||||
|
// Read the services stream; if the office is linked to a service
|
||||||
|
// but the stream hasn't yielded yet, fetch once and await it
|
||||||
final servicesAsync = ref.read(servicesProvider);
|
final servicesAsync = ref.read(servicesProvider);
|
||||||
final servicesById = {
|
final servicesById = <String, dynamic>{
|
||||||
for (final s in servicesAsync.valueOrNull ?? [])
|
for (final s in servicesAsync.valueOrNull ?? [])
|
||||||
s.id: s,
|
s.id: s,
|
||||||
};
|
};
|
||||||
final serviceName = officeId == null
|
|
||||||
|
final officeServiceId = officeId == null
|
||||||
|
? null
|
||||||
|
: officeById[officeId]?.serviceId;
|
||||||
|
|
||||||
|
if (officeServiceId != null &&
|
||||||
|
(servicesAsync.valueOrNull == null ||
|
||||||
|
(servicesAsync.valueOrNull?.isEmpty ?? true))) {
|
||||||
|
final servicesOnce = await ref.read(
|
||||||
|
servicesOnceProvider.future,
|
||||||
|
);
|
||||||
|
for (final s in servicesOnce) {
|
||||||
|
servicesById[s.id] = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final serviceName = officeServiceId == null
|
||||||
? ''
|
? ''
|
||||||
: (officeById[officeId]?.serviceId == null
|
: (servicesById[officeServiceId]?.name ?? '');
|
||||||
? ''
|
|
||||||
: (servicesById[officeById[officeId]!
|
|
||||||
.serviceId]
|
|
||||||
?.name ??
|
|
||||||
''));
|
|
||||||
await showTaskPdfPreview(
|
await showTaskPdfPreview(
|
||||||
context,
|
context,
|
||||||
task,
|
task,
|
||||||
|
|
@ -2973,9 +2988,10 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
|
||||||
showErrorSnackBar(context, e.toString());
|
showErrorSnackBar(context, e.toString());
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (context.mounted)
|
if (context.mounted) {
|
||||||
setState(() => isSaving = false);
|
setState(() => isSaving = false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: isSaving
|
child: isSaving
|
||||||
? SizedBox(
|
? SizedBox(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user