feat: Enable pre-filling document upload page with existing document URLs and update navigation method usage.
This commit is contained in:
@@ -222,7 +222,7 @@ extension StaffNavigator on IModularNavigator {
|
||||
///
|
||||
/// Upload and manage required documents like ID and work permits.
|
||||
void toDocuments() {
|
||||
pushNamed(StaffPaths.documents);
|
||||
navigate(StaffPaths.documents);
|
||||
}
|
||||
|
||||
/// Pushes the document upload page.
|
||||
|
||||
@@ -79,6 +79,10 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.initialUrl != null) {
|
||||
_selectedFilePath = widget.initialUrl;
|
||||
}
|
||||
|
||||
return BlocProvider<DocumentUploadCubit>(
|
||||
create: (BuildContext _) => Modular.get<DocumentUploadCubit>(),
|
||||
child: BlocConsumer<DocumentUploadCubit, DocumentUploadState>(
|
||||
@@ -144,8 +148,10 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
state.status == DocumentUploadStatus.uploading,
|
||||
canSubmit: _selectedFilePath != null && state.isAttested,
|
||||
onSubmit: () {
|
||||
final String? err =
|
||||
_validatePdfFile(context, _selectedFilePath!);
|
||||
final String? err = _validatePdfFile(
|
||||
context,
|
||||
_selectedFilePath!,
|
||||
);
|
||||
if (err != null) {
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
@@ -157,7 +163,10 @@ class _DocumentUploadPageState extends State<DocumentUploadPage> {
|
||||
}
|
||||
BlocProvider.of<DocumentUploadCubit>(
|
||||
context,
|
||||
).uploadDocument(widget.document.id, _selectedFilePath!);
|
||||
).uploadDocument(
|
||||
widget.document.id,
|
||||
_selectedFilePath!,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
@@ -186,20 +195,17 @@ class _PdfFileTypesBanner extends StatelessWidget {
|
||||
vertical: UiConstants.space3,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: UiColors.tagActive,
|
||||
color: UiColors.primaryForeground,
|
||||
borderRadius: BorderRadius.circular(UiConstants.radiusBase),
|
||||
border: Border.all(color: UiColors.primary.withValues(alpha: 0.3)),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
const Icon(UiIcons.info, size: 20, color: UiColors.primary),
|
||||
const SizedBox(width: UiConstants.space3),
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
style: UiTypography.body2r.textSecondary,
|
||||
),
|
||||
child: Text(message, style: UiTypography.body2r.textSecondary),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -45,7 +45,9 @@ class DocumentsPage extends StatelessWidget {
|
||||
: t.staff_documents.list.error(
|
||||
message: state.errorMessage!,
|
||||
))
|
||||
: t.staff_documents.list.error(message: t.staff_documents.list.unknown),
|
||||
: t.staff_documents.list.error(
|
||||
message: t.staff_documents.list.unknown,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body1m.copyWith(
|
||||
color: UiColors.textSecondary,
|
||||
@@ -80,7 +82,10 @@ class DocumentsPage extends StatelessWidget {
|
||||
...state.documents.map(
|
||||
(StaffDocument doc) => DocumentCard(
|
||||
document: doc,
|
||||
onTap: () => Modular.to.toDocumentUpload(document: doc),
|
||||
onTap: () => Modular.to.toDocumentUpload(
|
||||
document: doc,
|
||||
initialUrl: doc.documentUrl,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user