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

Localization fixes and Current cycle fixes #294

Closed
wants to merge 1 commit into from
Closed
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 @@ -56,6 +56,7 @@ class SyncBloc extends Bloc<SyncEvent, SyncState> {
case DataModelType.service:
case DataModelType.complaints:
case DataModelType.sideEffect:
case DataModelType.referral:
return true;
default:
return false;
Expand All @@ -76,6 +77,7 @@ class SyncBloc extends Bloc<SyncEvent, SyncState> {
case DataModelType.stockReconciliation:
case DataModelType.complaints:
case DataModelType.sideEffect:
case DataModelType.referral:
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import '../data/repositories/remote/project_product_variant.dart';
import '../data/repositories/remote/project_resource.dart';
import '../data/repositories/remote/project_staff.dart';
import '../data/repositories/remote/project_type.dart';
import '../data/repositories/remote/referral.dart';
import '../data/repositories/remote/service.dart';
import '../data/repositories/remote/service_definition.dart';
import '../data/repositories/remote/side_effect.dart';
Expand Down Expand Up @@ -217,6 +218,8 @@ class Constants {
HouseholdMemberRemoteRepository(dio, actionMap: actions),
if (value == DataModelType.sideEffect)
SideEffectRemoteRepository(dio, actionMap: actions),
if (value == DataModelType.referral)
ReferralRemoteRepository(dio, actionMap: actions),
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ extension ContextUtilityExtensions on BuildContext {
final projectBloc = _get<ProjectBloc>();

final projectState = projectBloc.state;
final selectedCycle = projectState.selectedCycle;
final selectedCycle = projectState.projectType?.cycles
?.where(
(e) =>
(e.startDate!) < DateTime.now().millisecondsSinceEpoch &&
(e.endDate!) > DateTime.now().millisecondsSinceEpoch,
// Return null when no matching cycle is found
)
.firstOrNull;

if (selectedCycle == null) {
return const Cycle();
Expand All @@ -39,8 +46,6 @@ extension ContextUtilityExtensions on BuildContext {
return selectedCycle;
}



BoundaryModel get boundary {
final boundaryBloc = _get<BoundaryBloc>();
final boundaryState = boundaryBloc.state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ class BeneficiaryDetails {
String get beneficiaryCycle => 'BENEFICIARY_DETAILS_CYCLE';
String get currentCycleLabel => 'BENEFICIARY_DETAILS_CURRENT_CYCLE_LABEL';
String get fromCurrentLocation => 'FROM_CURRENT_LOCATION';
String get beneficiaryHeader => 'BENEFICIARY_HEADER';
String get deliveryHeader => 'DELIVERY_TABLE_HEADER';
}

class IndividualDetails {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ class _ViewBeneficiaryCardState extends LocalizedState<ViewBeneficiaryCard> {

final headerList = [
TableHeader(
'Beneficiary',
localizations.translate(i18.beneficiaryDetails.beneficiaryHeader),
cellKey: 'beneficiary',
),
TableHeader(
'Delivery',
localizations.translate(i18.beneficiaryDetails.deliveryHeader),
cellKey: 'delivery',
),
TableHeader(
'Age',
localizations.translate(i18.individualDetails.ageLabelText),
cellKey: 'age',
),
TableHeader(
'Gender',
localizations.translate(i18.common.coreCommonGender),
cellKey: 'gender',
),
];
Expand All @@ -78,8 +78,6 @@ class _ViewBeneficiaryCardState extends LocalizedState<ViewBeneficiaryCard> {
? headerList.where((element) => element.cellKey != 'delivery').toList()
: headerList;
final bloc = context.read<ProjectBloc>().state;
final validMinAge = bloc.projectType?.validMinAge;
final validMaxAge = bloc.projectType?.validMaxAge;
final currentCycle = bloc.projectType?.cycles?.firstWhereOrNull(
(e) =>
(e.startDate!) < DateTime.now().millisecondsSinceEpoch &&
Expand Down
Loading