feat: Update certificate upload process to use signed URLs and enable fields for new certificates
This commit is contained in:
@@ -46,24 +46,20 @@ class CertificatesRepositoryImpl implements CertificatesRepository {
|
||||
// 2. Generate a signed URL for verification service to access the file
|
||||
// Wait, verification service might need this or just the URI.
|
||||
// Following DocumentRepository behavior:
|
||||
await _signedUrlService.createSignedUrl(fileUri: uploadRes.fileUri);
|
||||
final SignedUrlResponse signedUrlRes = await _signedUrlService.createSignedUrl(fileUri: uploadRes.fileUri);
|
||||
|
||||
// 3. Initiate verification
|
||||
final List<domain.StaffCertificate> allCerts = await getCertificates();
|
||||
final domain.StaffCertificate currentCert = allCerts.firstWhere(
|
||||
(domain.StaffCertificate c) => c.certificationType == certificationType,
|
||||
);
|
||||
|
||||
final String staffId = await _service.getStaffId();
|
||||
final VerificationResponse verificationRes = await _verificationService
|
||||
.createVerification(
|
||||
fileUri: uploadRes.fileUri,
|
||||
type: certificationType.value,
|
||||
category: 'certification',
|
||||
type: 'certification',
|
||||
subjectType: 'worker',
|
||||
subjectId: staffId,
|
||||
rules: <String, dynamic>{
|
||||
'certificateDescription': currentCert.description,
|
||||
'certificateName': name,
|
||||
'certificateIssuer': issuer,
|
||||
'certificateNumber': certificateNumber,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -72,7 +68,7 @@ class CertificatesRepositoryImpl implements CertificatesRepository {
|
||||
certificationType: certificationType,
|
||||
name: name,
|
||||
status: domain.StaffCertificateStatus.pending,
|
||||
fileUrl: uploadRes.fileUri,
|
||||
fileUrl: signedUrlRes.signedUrl,
|
||||
expiry: expiryDate,
|
||||
issuer: issuer,
|
||||
certificateNumber: certificateNumber,
|
||||
|
||||
@@ -35,6 +35,8 @@ class _CertificateUploadPageState extends State<CertificateUploadPage> {
|
||||
|
||||
final FilePickerService _filePicker = Modular.get<FilePickerService>();
|
||||
|
||||
bool get _isNewCertificate => widget.certificate == null;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -145,8 +147,8 @@ class _CertificateUploadPageState extends State<CertificateUploadPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider<CertificateUploadCubit>(
|
||||
create: (BuildContext _) => Modular.get<CertificateUploadCubit>(),
|
||||
return BlocProvider<CertificateUploadCubit>.value(
|
||||
value: Modular.get<CertificateUploadCubit>(),
|
||||
child: BlocConsumer<CertificateUploadCubit, CertificateUploadState>(
|
||||
listener: (BuildContext context, CertificateUploadState state) {
|
||||
if (state.status == CertificateUploadStatus.success) {
|
||||
@@ -190,7 +192,7 @@ class _CertificateUploadPageState extends State<CertificateUploadPage> {
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
TextField(
|
||||
controller: _nameController,
|
||||
enabled: false,
|
||||
enabled: _isNewCertificate,
|
||||
decoration: InputDecoration(
|
||||
hintText: t.staff_certificates.upload_modal.name_hint,
|
||||
border: OutlineInputBorder(
|
||||
@@ -208,7 +210,7 @@ class _CertificateUploadPageState extends State<CertificateUploadPage> {
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
TextField(
|
||||
controller: _issuerController,
|
||||
enabled: false,
|
||||
enabled: _isNewCertificate,
|
||||
decoration: InputDecoration(
|
||||
hintText: t.staff_certificates.upload_modal.issuer_hint,
|
||||
border: OutlineInputBorder(
|
||||
@@ -226,7 +228,7 @@ class _CertificateUploadPageState extends State<CertificateUploadPage> {
|
||||
const SizedBox(height: UiConstants.space2),
|
||||
TextField(
|
||||
controller: _numberController,
|
||||
enabled: false,
|
||||
enabled: _isNewCertificate,
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Enter number if applicable',
|
||||
border: OutlineInputBorder(
|
||||
|
||||
Reference in New Issue
Block a user