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;
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
final servicesAsync = ref.watch(servicesOnceProvider);
|
||||
return AlertDialog(
|
||||
shape: AppSurfaces.of(context).dialogShape,
|
||||
title: Text(office == null ? 'Create Office' : 'Edit Office'),
|
||||
|
|
|
|||
|
|
@ -394,19 +394,34 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
|
|||
final assignmentList = assignments;
|
||||
final profilesList =
|
||||
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 servicesById = {
|
||||
final servicesById = <String, dynamic>{
|
||||
for (final s in servicesAsync.valueOrNull ?? [])
|
||||
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[officeById[officeId]!
|
||||
.serviceId]
|
||||
?.name ??
|
||||
''));
|
||||
: (servicesById[officeServiceId]?.name ?? '');
|
||||
|
||||
await showTaskPdfPreview(
|
||||
context,
|
||||
task,
|
||||
|
|
@ -2973,8 +2988,9 @@ class _TaskDetailScreenState extends ConsumerState<TaskDetailScreen>
|
|||
showErrorSnackBar(context, e.toString());
|
||||
}
|
||||
} finally {
|
||||
if (context.mounted)
|
||||
if (context.mounted) {
|
||||
setState(() => isSaving = false);
|
||||
}
|
||||
}
|
||||
},
|
||||
child: isSaving
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user