Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLM-3103:: Changes in validation messages and eligibility check nee… #289

Merged
merged 5 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ class _RecordPastDeliveryDetailsPageState
)} ${localizations.translate(
i18.beneficiaryDetails.beneficiaryDose,
)} ${doseNumber - 1} ? *",
labelStyle: theme.textTheme.displayMedium,
labelStyle: DigitTheme.instance
.mobileTheme.textTheme.headlineSmall,
formControlName:
"$_recordDoseAdministeredKey.${futureTaskList.indexOf(entry.value)}",
valueMapper: (val) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,93 +89,111 @@ class _ReferBeneficiaryPageState extends LocalizedState<ReferBeneficiaryPage> {
valueListenable: clickedStatus,
builder: (context, bool isClicked, _) {
return DigitElevatedButton(
onPressed: () {
if (form.control(_referralReason).value == null) {
clickedStatus.value = false;
form.control(_referralReason).setErrors({'': true});
}
form.markAllAsTouched();
onPressed: isClicked
? null
: () {
if (form.control(_referralReason).value ==
null) {
clickedStatus.value = false;
form
.control(_referralReason)
.setErrors({'': true});
}
form.markAllAsTouched();

if (!form.valid) {
return;
} else {
clickedStatus.value = true;
final recipient = form.control(_referredToKey).value
as FacilityModel;
final reason =
form.control(_referralReason).value as KeyValue;
final recipientType =
recipient.id == 'Community Health Worker'
? 'STAFF'
: 'FACILITY';
final recipientId =
recipient.id == 'Community Health Worker'
? context.loggedInUserUuid
: recipient.id;
final referralComment =
form.control(_referralComments).value;
if (!form.valid) {
return;
} else {
clickedStatus.value = true;
final recipient = form
.control(_referredToKey)
.value as FacilityModel;
final reason = form
.control(_referralReason)
.value as KeyValue;
final recipientType =
recipient.id == 'Community Health Worker'
? 'STAFF'
: 'FACILITY';
final recipientId =
recipient.id == 'Community Health Worker'
? context.loggedInUserUuid
: recipient.id;
final referralComment =
form.control(_referralComments).value;

final event = context.read<ReferralBloc>();
event.add(ReferralSubmitEvent(
ReferralModel(
clientReferenceId: IdGen.i.identifier,
projectId: context.projectId,
projectBeneficiaryClientReferenceId:
widget.projectBeneficiaryClientRefId,
referrerId: context.loggedInUserUuid,
recipientId: recipientId,
recipientType: recipientType,
reasons: [reason.key],
tenantId: envConfig.variables.tenantId,
rowVersion: 1,
auditDetails: AuditDetails(
createdBy: context.loggedInUserUuid,
createdTime: context.millisecondsSinceEpoch(),
lastModifiedBy: context.loggedInUserUuid,
lastModifiedTime:
context.millisecondsSinceEpoch(),
),
clientAuditDetails: ClientAuditDetails(
createdBy: context.loggedInUserUuid,
createdTime: context.millisecondsSinceEpoch(),
lastModifiedBy: context.loggedInUserUuid,
lastModifiedTime:
context.millisecondsSinceEpoch(),
),
additionalFields: ReferralAdditionalFields(
version: 1,
fields: [
if (referralComment != null)
AdditionalField(
AdditionalFieldsType.referralComments
.toValue(),
referralComment,
final event = context.read<ReferralBloc>();
event.add(ReferralSubmitEvent(
ReferralModel(
clientReferenceId: IdGen.i.identifier,
projectId: context.projectId,
projectBeneficiaryClientReferenceId:
widget.projectBeneficiaryClientRefId,
referrerId: context.loggedInUserUuid,
recipientId: recipientId,
recipientType: recipientType,
reasons: [reason.key],
tenantId: envConfig.variables.tenantId,
rowVersion: 1,
auditDetails: AuditDetails(
createdBy: context.loggedInUserUuid,
createdTime:
context.millisecondsSinceEpoch(),
lastModifiedBy:
context.loggedInUserUuid,
lastModifiedTime:
context.millisecondsSinceEpoch(),
),
],
),
),
false,
));
clientAuditDetails: ClientAuditDetails(
createdBy: context.loggedInUserUuid,
createdTime:
context.millisecondsSinceEpoch(),
lastModifiedBy:
context.loggedInUserUuid,
lastModifiedTime:
context.millisecondsSinceEpoch(),
),
additionalFields:
ReferralAdditionalFields(
version: 1,
fields: [
if (referralComment != null &&
referralComment
.toString()
.trim()
.isNotEmpty)
AdditionalField(
AdditionalFieldsType
.referralComments
.toValue(),
referralComment,
),
],
),
),
false,
));

final reloadState =
context.read<HouseholdOverviewBloc>();
final reloadState =
context.read<HouseholdOverviewBloc>();

Future.delayed(
const Duration(milliseconds: 500),
() {
reloadState.add(HouseholdOverviewReloadEvent(
projectId: context.projectId,
projectBeneficiaryType:
context.beneficiaryType,
));
Future.delayed(
const Duration(milliseconds: 500),
() {
reloadState
.add(HouseholdOverviewReloadEvent(
projectId: context.projectId,
projectBeneficiaryType:
context.beneficiaryType,
));
},
).then((value) => context.router.popAndPush(
HouseholdAcknowledgementRoute(
enableViewHousehold: true,
),
));
}
},
).then((value) => context.router.popAndPush(
HouseholdAcknowledgementRoute(
enableViewHousehold: true,
),
));
}
},
child: Center(
child: Text(
localizations
Expand Down Expand Up @@ -231,6 +249,11 @@ class _ReferBeneficiaryPageState extends LocalizedState<ReferBeneficiaryPage> {
label: localizations.translate(
i18.referBeneficiary.referredByLabel,
),
validationMessages: {
'required': (_) => localizations.translate(
i18.common.corecommonRequired,
),
},
isRequired: true,
),
DigitTextFormField(
Expand All @@ -249,7 +272,8 @@ class _ReferBeneficiaryPageState extends LocalizedState<ReferBeneficiaryPage> {
readOnly: false,
validationMessages: {
'required': (_) => localizations.translate(
i18.common.corecommonRequired,
i18.referBeneficiary
.facilityValidationMessage,
),
},
onTap: () async {
Expand Down Expand Up @@ -327,7 +351,7 @@ class _ReferBeneficiaryPageState extends LocalizedState<ReferBeneficiaryPage> {
_referredToKey:
FormControl<FacilityModel>(validators: [Validators.required]),
_referralReason: FormControl<KeyValue>(value: null),
_referralComments: FormControl<String>(value: ''),
_referralComments: FormControl<String>(value: null),
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import 'package:digit_components/digit_components.dart';
import 'package:flutter/material.dart';
import 'package:reactive_forms/reactive_forms.dart';

import '../../blocs/localization/app_localization.dart';
import '../../models/entities/facility.dart';
import '../../router/app_router.dart';
import '../../utils/i18_key_constants.dart' as i18;
import '../../widgets/header/back_navigation_help_header.dart';

class FacilitySelectionPage extends StatelessWidget {
Expand All @@ -20,6 +22,8 @@ class FacilitySelectionPage extends StatelessWidget {

@override
Widget build(BuildContext context) {
AppLocalizations localizations = AppLocalizations.of(context);

return ReactiveFormBuilder(
form: _form,
builder: (context, form, child) {
Expand All @@ -39,11 +43,12 @@ class FacilitySelectionPage extends StatelessWidget {
return ScrollableContent(
header: const BackNavigationHelpHeaderWidget(),
slivers: [
const SliverToBoxAdapter(
SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.all(16),
padding: const EdgeInsets.all(16),
child: DigitTextFormField(
label: 'Facility Search Text',
label: localizations
.translate(i18.common.facilitySearchHeaderLabel),
formControlName: _facilityName,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ class Common {
String get coreCommonRequiredItems => 'CORE_COMMON_REQUIRED_ITEMS';

String get min2CharsRequired => 'MIN_2_CHARS_REQUIRED';

String get facilitySearchHeaderLabel => 'FACILITY_SEARCH_HEADER_LABEL';
}

class AdverseEvents {
Expand Down Expand Up @@ -1012,4 +1014,5 @@ class ReferBeneficiary {
String get reasonForReferral => 'REASON_FOR_REFERRAL';
String get referralComments => 'REFERRAL_COMMENTS';
String get referralDetails => 'REFERRAL_DETAILS_HEADER';
String get facilityValidationMessage => 'PLEASE_ENTER_VALID_FACILITY';
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ class MemberCard extends StatelessWidget {
icon: Icons.info_rounded,
iconSize: 20,
iconText: localizations.translate(
isBeneficiaryReferred
isNotEligible
? i18.householdOverView
.householdOverViewBeneficiaryReferredLabel
: isNotEligible
.householdOverViewNotEligibleIconLabel
: isBeneficiaryReferred
? i18.householdOverView
.householdOverViewNotEligibleIconLabel
.householdOverViewBeneficiaryReferredLabel
: isBeneficiaryRefused
? Status.beneficiaryRefused.toValue()
// [TODO Need to update the localization]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ class DigitRadioButtonList<T> extends StatelessWidget {
if (radioListControl.hasErrors) {
return Text(
errorMessage,
style: TextStyle(color: DigitTheme.instance.colorScheme.error),
style: TextStyle(
color: DigitTheme.instance.colorScheme.error, fontSize: 12),
);
} else {
return const SizedBox.shrink();
Expand Down