Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #856 from egovernments/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pradeepkumarcm-egov authored Jul 9, 2024
2 parents a70472f + 3595034 commit 7f351ad
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 10 deletions.
47 changes: 46 additions & 1 deletion frontend/mgramseva/lib/providers/search_connection_provider.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:mgramseva/model/connection/search_connection.dart';
Expand Down Expand Up @@ -54,7 +55,6 @@ class SearchConnectionProvider with ChangeNotifier {
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);

if (formKey.currentState!.validate()) {
searchconnection.setValues();
try {
Expand Down Expand Up @@ -105,4 +105,49 @@ class SearchConnectionProvider with ChangeNotifier {
autoValidation = true;
}
}

void fetchNonDemandGeneratedConnectionDetails(
context, String previousMeterReading) async {
FocusScope.of(context).unfocus();
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);
try {
Loaders.showLoadingDialog(context);
Map<String, dynamic> query = {
'previousMeterReading': previousMeterReading.toString(),
'tenantId': commonProvider.userDetails?.selectedtenant?.code
};
var arguments ={"Mode": "update"};
var connectionresults =
SearchConnectionRepository().getNonDemandGeneratedWC(query);
// popping the loader
connectionresults.then(
(value) => {
Navigator.pop(context),
if (value.waterConnectionData!.length > 0 ||
value.waterConnection!.length > 0)
{
waterConnections = value,
Navigator.pushNamed(context, Routes.SEARCH_CONSUMER_RESULT,
arguments: {
...query,
...arguments,
"isNameSearch": false
})
}
else
{
Notifiers.getToastMessage(context,
i18.searchWaterConnection.NO_CONNECTION_FOUND, "ERROR")
}
}, onError: (e, s) {
Navigator.pop(context);
ErrorHandler().allExceptionsHandler(context, e, s);
});
} catch (e, s) {
Navigator.pop(context);
ErrorHandler().allExceptionsHandler(context, e, s);
}
}
}
32 changes: 32 additions & 0 deletions frontend/mgramseva/lib/repository/search_connection_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,36 @@ class SearchConnectionRepository extends BaseService {
}
return waterConnections;
}

Future<WaterConnections> getNonDemandGeneratedWC(Map<String, dynamic> query) async {
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);

final requestInfo = RequestInfo(
APIConstants.API_MODULE_NAME,
APIConstants.API_VERSION,
APIConstants.API_TS,
"_search",
APIConstants.API_DID,
APIConstants.API_KEY,
APIConstants.API_MESSAGE_ID,
commonProvider.userDetails!.accessToken,
commonProvider.userDetails?.userRequest?.toJson(),
);
var res = await makeRequest(
url: Url.WATER_CONNECTION_DEMAND_NOT_GENERATED,
queryParameters: query,
method: RequestType.POST,
body: {},
requestInfo: requestInfo);

if (res != null) {
waterConnections = WaterConnections.fromJson(res);
}
return waterConnections;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:mgramseva/model/reports/WaterConnectionCount.dart';
import 'package:mgramseva/providers/search_connection_provider.dart';
import 'package:mgramseva/utils/constants/i18_key_constants.dart';
import 'package:provider/provider.dart';
import '../../../utils/date_formats.dart';
import '../../../utils/localization/application_localizations.dart';

class CountTableWidget extends StatefulWidget {
final List<WaterConnectionCount>? waterConnectionCount;
final bool? isWCDemandNotGenerated;

const CountTableWidget({Key? key, this.waterConnectionCount})
const CountTableWidget({Key? key, this.waterConnectionCount, this.isWCDemandNotGenerated})
: super(key: key);

@override
Expand Down Expand Up @@ -61,7 +64,7 @@ class _CountTableWidgetState extends State<CountTableWidget> {
borderRadius: BorderRadius.all(Radius.circular(5)),
color: Colors.grey, // Set border color to grey
),// Set heading row background color to grey
headingTextStyle: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), // Set heading text color to black and bold
headingTextStyle: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), // Set heading text color to black and bold
columns: [
DataColumn(
label: FittedBox(
Expand All @@ -84,10 +87,31 @@ class _CountTableWidgetState extends State<CountTableWidget> {
);
}

Widget buildLinkText(int count, bool isWCDemandNotGenerated, {VoidCallback? onTap, Uri? launchUri}) {
final Color linkColor = isWCDemandNotGenerated ? Colors.blue : Colors.black;
final MouseCursor? hoverCursor = SystemMouseCursors.click; // Optional hand cursor

return GestureDetector(
onTap: () {
// onTap?.call();

// if (launchUri != null) {
// }
},
child: Text(
count.toString(),
style: TextStyle(
color: linkColor,
decoration: TextDecoration.underline, // Optional underline
),
),
);
}

DataRow _buildDataRow(WaterConnectionCount count) {
final bool isEvenRow = widget.waterConnectionCount!.indexOf(count) % 2 == 0;
final Color? rowColor = isEvenRow ? Colors.grey[100] : Colors.white; // Set alternate row background color to grey

final status = widget.isWCDemandNotGenerated == true;
return DataRow(
color: MaterialStateColor.resolveWith((states) => rowColor!), // Apply alternate row background color

Expand All @@ -100,7 +124,25 @@ class _CountTableWidgetState extends State<CountTableWidget> {
),
),
DataCell(
Text(count.count.toString()),
MouseRegion(
cursor: status ? SystemMouseCursors.click : SystemMouseCursors.basic,
child: GestureDetector(
child:
Text(count.count.toString(),
style: TextStyle(
decoration: status ? TextDecoration.underline :TextDecoration.none ,
color: status ? Colors.blue : Colors.black
),
),
onTap: () {
if(status){
var searchConnectionProvider =
Provider.of<SearchConnectionProvider>(context, listen: false);
searchConnectionProvider.fetchNonDemandGeneratedConnectionDetails(context,"${count.taxperiodto!}");
}
},
),
),
),
],
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:mgramseva/model/reports/WaterConnectionCount.dart';
import 'package:mgramseva/providers/reports_provider.dart';
Expand Down Expand Up @@ -66,6 +68,7 @@ class _WaterConnectionCountWidgetState
"${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_DEMAND_GENERATED)}",
waterConnectionCount
.waterConnectionsDemandGenerated,

),
if (waterConnectionCount.waterConnectionsDemandGenerated !=
null &&
Expand All @@ -79,6 +82,7 @@ class _WaterConnectionCountWidgetState
"${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_DEMAND_GENERATED)}",
waterConnectionCount
.waterConnectionsDemandGenerated,

),
SizedBox(height: 20),
if (waterConnectionCount.waterConnectionsDemandNotGenerated !=
Expand All @@ -93,6 +97,8 @@ class _WaterConnectionCountWidgetState
"${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_DEMAND_NOT_GENERATED)}",
waterConnectionCount
.waterConnectionsDemandNotGenerated,
isWCDemandNotGenerated: true

),
if (waterConnectionCount.waterConnectionsDemandNotGenerated !=
null &&
Expand All @@ -106,6 +112,7 @@ class _WaterConnectionCountWidgetState
"${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_DEMAND_NOT_GENERATED)}",
waterConnectionCount
.waterConnectionsDemandNotGenerated,
isWCDemandNotGenerated: true
),
],
);
Expand All @@ -121,33 +128,38 @@ class _WaterConnectionCountWidgetState
}

Widget _buildDataTableRow(BuildContext context, String title,
List<WaterConnectionCount>? waterConnections) {
List<WaterConnectionCount>? waterConnections,{bool isWCDemandNotGenerated = false}) {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(

alignment: Alignment.centerLeft,
width: MediaQuery.of(context).size.width / 3,
padding: EdgeInsets.only(top: 18, bottom: 3),
child: Text(title),
child: Text(title ),
),
Container(
width: MediaQuery.of(context).size.width / 2.5,
padding: EdgeInsets.only(top: 18, bottom: 3),
child: CountTableWidget(waterConnectionCount: waterConnections),
child: CountTableWidget(waterConnectionCount: waterConnections,
isWCDemandNotGenerated: isWCDemandNotGenerated,
),
),
],
);
}

Widget _buildDataTableColumn(BuildContext context, String title,
List<WaterConnectionCount>? waterConnections) {
List<WaterConnectionCount>? waterConnections,{bool isWCDemandNotGenerated = false}) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title),
SizedBox(height: 10),
CountTableWidget(waterConnectionCount: waterConnections),
CountTableWidget(waterConnectionCount: waterConnections,
isWCDemandNotGenerated: isWCDemandNotGenerated,
),
],
);
}
Expand Down
2 changes: 2 additions & 0 deletions frontend/mgramseva/lib/services/urls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ class Url {
'echallan-services/eChallan/v1/_expenseBillReport';
static const String WATER_CONNECTION_COUNT =
'ws-services/wc/_countWCbyDemandGenerationDate';
static const String WATER_CONNECTION_DEMAND_NOT_GENERATED =
'ws-services/wc/consumers/demand-not-generated';
}

class UserUrl {
Expand Down

0 comments on commit 7f351ad

Please sign in to comment.