refactor shipping attachments and changed shipment to shipping for coherence

This commit is contained in:
2026-05-18 12:00:07 +02:00
parent b06a655bc3
commit 5e99324201
15 changed files with 359 additions and 152 deletions

View File

@@ -41,6 +41,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
add(LoadAttachmentsEvent(parentId: parentId));
}
}
FutureOr<void> _onParentEntitySaved(
ParentEntitySavedEvent event,
Emitter<AttachmentsState> emit,
@@ -67,6 +68,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
parentType: state.parentType,
pickedFile: fakePlatformFile,
companyId: companyId!,
bucket: _getBucketForParentType,
);
}).toList();
@@ -156,6 +158,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
parentType: state.parentType,
pickedFile: file,
companyId: companyId!,
bucket: _getBucketForParentType,
);
}).toList();
@@ -192,6 +195,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
parentType: state.parentType,
pickedFile: file,
companyId: event.companyId,
bucket: _getBucketForParentType,
),
);
}
@@ -218,6 +222,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
parentType: state.parentType,
pickedFile: fakePlatformFile,
companyId: event.companyId,
bucket: _getBucketForParentType,
),
);
}
@@ -242,6 +247,7 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
await _repository.deleteFiles(
files: state.selectedFiles,
currentContextType: state.parentType,
bucket: _getBucketForParentType,
);
emit(state.copyWith(status: AttachmentsStatus.ready, selectedFiles: []));
} catch (e) {
@@ -298,6 +304,8 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
return file.copyWith(ticketId: event.targetId);
case AttachmentParentType.operation:
return file.copyWith(operationId: event.targetId);
case AttachmentParentType.shippingDocument:
return file.copyWith(shippingDocumentId: event.targetId);
}
}
return file;
@@ -386,4 +394,17 @@ class AttachmentsBloc extends Bloc<AttachmentsEvent, AttachmentsState> {
emit(state.copyWith(localFiles: updatedLocalFiles));
}
}
Bucket get _getBucketForParentType {
switch (state.parentType) {
case AttachmentParentType.customer:
return Bucket.documents;
case AttachmentParentType.ticket:
return Bucket.documents;
case AttachmentParentType.operation:
return Bucket.documents;
case AttachmentParentType.shippingDocument:
return Bucket.companyDocuments;
}
}
}