PMJJBY screen and creation done
This commit is contained in:
109
lib/api/services/yojna_service.dart
Normal file
109
lib/api/services/yojna_service.dart
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
import 'dart:developer';
|
||||||
|
import 'package:dio/dio.dart';
|
||||||
|
import 'package:kmobile/core/errors/exceptions.dart';
|
||||||
|
import 'package:kmobile/data/models/ifsc.dart';
|
||||||
|
|
||||||
|
class YojnaService {
|
||||||
|
final Dio _dio;
|
||||||
|
|
||||||
|
YojnaService(this._dio);
|
||||||
|
|
||||||
|
Future<dynamic> fetchpmydetails({
|
||||||
|
required String scheme,
|
||||||
|
required String action,
|
||||||
|
required String accountno,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final response = await _dio.post(
|
||||||
|
"/api/gov-scheme/req/PMJBY",
|
||||||
|
data: {
|
||||||
|
'scheme': scheme,
|
||||||
|
'action': action,
|
||||||
|
'accountNo': accountno,
|
||||||
|
},
|
||||||
|
options: Options(
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
log("PMY Details Response: ${response.data}");
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
return response.data;
|
||||||
|
} else {
|
||||||
|
throw Exception("INTERNAL SERVER ERROR");
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log("Error fetching PMY details: $e");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future secondvalidationPMJJBY({
|
||||||
|
String? aadharno,
|
||||||
|
String? accountno,
|
||||||
|
String? availablebalance,
|
||||||
|
String? country,
|
||||||
|
String? customerdob,
|
||||||
|
String? customername,
|
||||||
|
String? customerno,
|
||||||
|
String? dateofacctopening,
|
||||||
|
String? emailid,
|
||||||
|
String? financialyear,
|
||||||
|
String? gender,
|
||||||
|
String? ifsccode,
|
||||||
|
String? married,
|
||||||
|
String? mobileno,
|
||||||
|
String? pan,
|
||||||
|
String? pincode,
|
||||||
|
String? policynumber,
|
||||||
|
String? premiumamount,
|
||||||
|
String? state,
|
||||||
|
String? healthstatus,
|
||||||
|
String? collectionchannel,
|
||||||
|
String? nomineename,
|
||||||
|
String? nomineeaddress,
|
||||||
|
String? nomineerelationship,
|
||||||
|
String? nomineeminor,
|
||||||
|
String? ruralcategory,
|
||||||
|
}) async {
|
||||||
|
final response = await _dio.post(
|
||||||
|
'/api/gov-scheme/create/PMJBY',
|
||||||
|
options: Options(
|
||||||
|
validateStatus: (int? status) => true,
|
||||||
|
receiveDataWhenStatusError: true,
|
||||||
|
),
|
||||||
|
data: {
|
||||||
|
'aadharno': aadharno ,
|
||||||
|
'accountno': accountno,
|
||||||
|
'availablebalance': availablebalance,
|
||||||
|
'country': country,
|
||||||
|
'customerdob': customerdob,
|
||||||
|
'customername': customername,
|
||||||
|
'customerno': customerno,
|
||||||
|
'dateofacctopening': dateofacctopening,
|
||||||
|
'emailid': emailid,
|
||||||
|
'financialyear': financialyear,
|
||||||
|
'gender': gender,
|
||||||
|
'ifsccode': ifsccode,
|
||||||
|
'married': married,
|
||||||
|
'mobileno': mobileno,
|
||||||
|
'pan': pan,
|
||||||
|
'pincode': pincode,
|
||||||
|
'policynumber': policynumber,
|
||||||
|
'premiumamount': premiumamount,
|
||||||
|
'state': state,
|
||||||
|
'healthstatus': healthstatus,
|
||||||
|
'collectionchannel': collectionchannel,
|
||||||
|
'nomineename': nomineename,
|
||||||
|
'nomineeaddress': nomineeaddress,
|
||||||
|
'nomineerelationship': nomineerelationship,
|
||||||
|
'nomineeminor': nomineeminor,
|
||||||
|
'ruralcategory': ruralcategory,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return response.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import 'package:dio/dio.dart';
|
|||||||
import 'package:kmobile/api/services/beneficiary_service.dart';
|
import 'package:kmobile/api/services/beneficiary_service.dart';
|
||||||
import 'package:kmobile/api/services/payment_service.dart';
|
import 'package:kmobile/api/services/payment_service.dart';
|
||||||
import 'package:kmobile/api/services/user_service.dart';
|
import 'package:kmobile/api/services/user_service.dart';
|
||||||
|
import 'package:kmobile/api/services/yojna_service.dart';
|
||||||
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
import 'package:kmobile/data/repositories/transaction_repository.dart';
|
||||||
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
import 'package:kmobile/features/auth/controllers/theme_cubit.dart';
|
||||||
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
import 'package:kmobile/features/auth/controllers/theme_mode_cubit.dart';
|
||||||
@@ -58,6 +59,7 @@ Future<void> setupDependencies() async {
|
|||||||
getIt.registerSingleton<ImpsService>(ImpsService(getIt<Dio>()));
|
getIt.registerSingleton<ImpsService>(ImpsService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<BranchService>(BranchService(getIt<Dio>()));
|
getIt.registerSingleton<BranchService>(BranchService(getIt<Dio>()));
|
||||||
getIt.registerSingleton<ChequeService>(ChequeService(getIt<Dio>()));
|
getIt.registerSingleton<ChequeService>(ChequeService(getIt<Dio>()));
|
||||||
|
getIt.registerSingleton<YojnaService>(YojnaService(getIt<Dio>()));
|
||||||
getIt.registerLazySingleton<ChangePasswordService>(
|
getIt.registerLazySingleton<ChangePasswordService>(
|
||||||
() => ChangePasswordService(getIt<Dio>()),
|
() => ChangePasswordService(getIt<Dio>()),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import 'package:kmobile/features/auth/controllers/auth_state.dart';
|
|||||||
import 'package:kmobile/features/cheque/screens/cheque_management_screen.dart';
|
import 'package:kmobile/features/cheque/screens/cheque_management_screen.dart';
|
||||||
import 'package:kmobile/features/customer_info/screens/customer_info_screen.dart';
|
import 'package:kmobile/features/customer_info/screens/customer_info_screen.dart';
|
||||||
import 'package:kmobile/features/beneficiaries/screens/manage_beneficiaries_screen.dart';
|
import 'package:kmobile/features/beneficiaries/screens/manage_beneficiaries_screen.dart';
|
||||||
import 'package:kmobile/features/enquiry/screens/enquiry_screen.dart';
|
|
||||||
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_screen.dart';
|
import 'package:kmobile/features/fund_transfer/screens/fund_transfer_screen.dart';
|
||||||
import 'package:kmobile/features/profile/profile_screen.dart';
|
import 'package:kmobile/features/profile/profile_screen.dart';
|
||||||
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
import 'package:kmobile/features/quick_pay/screens/quick_pay_screen.dart';
|
||||||
import 'package:kmobile/features/service/screens/branch_locator_screen.dart';
|
import 'package:kmobile/features/service/screens/branch_locator_screen.dart';
|
||||||
|
import 'package:kmobile/features/yojna/screens/gov_scheme_screen.dart';
|
||||||
import 'package:kmobile/security/secure_storage.dart';
|
import 'package:kmobile/security/secure_storage.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
@@ -636,13 +636,13 @@ class _DashboardScreenState extends State<DashboardScreen>
|
|||||||
ManageBeneficiariesScreen(
|
ManageBeneficiariesScreen(
|
||||||
customerName: currAccount.name!)));
|
customerName: currAccount.name!)));
|
||||||
}, disable: false),
|
}, disable: false),
|
||||||
_buildQuickLink(Symbols.support_agent,
|
_buildQuickLink(Symbols.family_group,
|
||||||
AppLocalizations.of(context).contactUs, () {
|
"Government Schemes", () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) =>
|
builder: (context) =>
|
||||||
const EnquiryScreen()));
|
const GovSchemeScreen()));
|
||||||
}),
|
}),
|
||||||
_buildQuickLink(
|
_buildQuickLink(
|
||||||
Symbols.checkbook,
|
Symbols.checkbook,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:kmobile/features/account_opening/screens/account_opening_screen.dart';
|
import 'package:kmobile/features/account_opening/screens/account_opening_screen.dart';
|
||||||
import 'package:kmobile/features/card/screens/card_management_screen.dart';
|
import 'package:kmobile/features/card/screens/card_management_screen.dart';
|
||||||
import 'package:kmobile/features/service/screens/atm_locator_screen.dart';
|
import 'package:kmobile/features/service/screens/atm_locator_screen.dart';
|
||||||
import 'package:kmobile/features/yojna/screens/pm_main_screen.dart';
|
import 'package:kmobile/features/service/screens/enquiry_screen.dart';
|
||||||
import '../../../l10n/app_localizations.dart';
|
import '../../../l10n/app_localizations.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
import 'package:material_symbols_icons/material_symbols_icons.dart';
|
||||||
@@ -100,17 +100,17 @@ class _ServiceScreen extends State<ServiceScreen> {
|
|||||||
// ),
|
// ),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ServiceManagementTile(
|
child: ServiceManagementTile(
|
||||||
icon: Symbols.family_group,
|
icon: Symbols.support_agent,
|
||||||
label: "Pradhan Mantri Yojna",
|
label: AppLocalizations.of(context).contactUs,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => const PMMainScreen()));
|
builder: (context) => const EnquiryScreen()));
|
||||||
},
|
},
|
||||||
disabled: false,
|
disabled: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// No Spacer() needed here as Expanded children will fill space
|
// No Spacer() needed here as Expanded children will fill space
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|||||||
145
lib/features/yojna/screens/gov_scheme_screen.dart
Normal file
145
lib/features/yojna/screens/gov_scheme_screen.dart
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/features/yojna/screens/pm_main_screen.dart';
|
||||||
|
import '../../../l10n/app_localizations.dart';
|
||||||
|
|
||||||
|
class GovSchemeScreen extends StatefulWidget {
|
||||||
|
const GovSchemeScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<GovSchemeScreen> createState() => _GovSchemeScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _GovSchemeScreenState extends State<GovSchemeScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Government Schemes'),
|
||||||
|
),
|
||||||
|
body: Stack(
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: GovSchemeTile(
|
||||||
|
logoText: "PMJJBY/PMSBY",
|
||||||
|
label: "Pradhan Mantri Yojana",
|
||||||
|
subtitle: "Enroll in Pradhan Mantri Jeevan Jyoti Bima Yojana (PMJJBY) and Pradhan Mantri Suraksha Bima Yojana (PMSBY) insurance schemes",
|
||||||
|
onTap: () {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => const PMMainScreen(),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: GovSchemeTile(
|
||||||
|
logoText: "APY",
|
||||||
|
label: "Atal Pension Yojana",
|
||||||
|
subtitle: "Secure your future with Atal Pension Yojana (APY) retirement scheme",
|
||||||
|
onTap: () {
|
||||||
|
// Action for APY will be added later
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IgnorePointer(
|
||||||
|
child: Center(
|
||||||
|
child: Opacity(
|
||||||
|
opacity: 0.07,
|
||||||
|
child: ClipOval(
|
||||||
|
child: Image.asset(
|
||||||
|
'assets/images/logo.png',
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class GovSchemeTile extends StatelessWidget {
|
||||||
|
final String logoText;
|
||||||
|
final String label;
|
||||||
|
final String? subtitle;
|
||||||
|
final VoidCallback onTap;
|
||||||
|
final bool disable;
|
||||||
|
|
||||||
|
const GovSchemeTile({
|
||||||
|
super.key,
|
||||||
|
required this.logoText,
|
||||||
|
required this.label,
|
||||||
|
this.subtitle,
|
||||||
|
required this.onTap,
|
||||||
|
this.disable = false,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
return Card(
|
||||||
|
margin: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
),
|
||||||
|
elevation: 4,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: disable ? null : onTap,
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 36.0, horizontal: 16.0),
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
logoText,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: logoText.length > 5 ? 28 : 40,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: theme.colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
label,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: theme.textTheme.headlineSmall?.copyWith(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: disable
|
||||||
|
? theme.disabledColor
|
||||||
|
: theme.colorScheme.onSurface,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (subtitle != null)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 8.0),
|
||||||
|
child: Text(
|
||||||
|
subtitle!,
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: theme.textTheme.bodyMedium?.copyWith(
|
||||||
|
color: disable
|
||||||
|
? theme.disabledColor
|
||||||
|
: theme.colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/api/services/yojna_service.dart';
|
||||||
|
import 'package:kmobile/di/injection.dart';
|
||||||
|
import 'package:kmobile/features/yojna/screens/pmjjby_screen.dart';
|
||||||
import 'package:kmobile/l10n/app_localizations.dart';
|
import 'package:kmobile/l10n/app_localizations.dart';
|
||||||
|
|
||||||
class PMMainScreen extends StatefulWidget {
|
class PMMainScreen extends StatefulWidget {
|
||||||
@@ -23,6 +26,74 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
|||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _handleCreate() async {
|
||||||
|
if (_accountController.text.isEmpty) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Please enter account number')),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_selectedScheme == null) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Please select a scheme first')),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String schemeCode = _selectedScheme!.contains('PMJJBY') ? '02' : '01';
|
||||||
|
|
||||||
|
// Show loading
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Row(
|
||||||
|
children: [
|
||||||
|
CircularProgressIndicator(),
|
||||||
|
SizedBox(width: 16),
|
||||||
|
Text('Fetching details...'),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
duration: Duration(seconds: 2),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await getIt<YojnaService>().fetchpmydetails(
|
||||||
|
scheme: schemeCode,
|
||||||
|
action: 'C',
|
||||||
|
accountno: _accountController.text,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
Map<String, dynamic>? data;
|
||||||
|
if (response is Map<String, dynamic>) {
|
||||||
|
data = response;
|
||||||
|
} else if (response is List && response.isNotEmpty && response[0] is Map<String, dynamic>) {
|
||||||
|
data = response[0] as Map<String, dynamic>;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data != null && data.isNotEmpty) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => PMJJBYScreen(initialData: data),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Failed to fetch details or no data found.')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error: ${e.toString()}')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
@@ -58,23 +129,48 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Account Number',
|
labelText: 'Account Number',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(vertical: 20, horizontal: 12),
|
||||||
),
|
),
|
||||||
keyboardType: TextInputType.number,
|
keyboardType: TextInputType.number,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
DropdownButtonFormField<String>(
|
DropdownButtonFormField<String>(
|
||||||
value: _selectedScheme,
|
value: _selectedScheme,
|
||||||
|
isExpanded: true,
|
||||||
|
isDense: false,
|
||||||
|
itemHeight: null,
|
||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'Scheme',
|
labelText: 'Select Scheme',
|
||||||
border: OutlineInputBorder(),
|
border: OutlineInputBorder(),
|
||||||
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(vertical: 12, horizontal: 12),
|
||||||
),
|
),
|
||||||
|
selectedItemBuilder: (BuildContext context) {
|
||||||
|
return _schemes.map((String scheme) {
|
||||||
|
return Container(
|
||||||
|
alignment: Alignment.centerLeft,
|
||||||
|
child: Text(
|
||||||
|
scheme,
|
||||||
|
style: const TextStyle(fontSize: 14),
|
||||||
|
softWrap: true,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.visible,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}).toList();
|
||||||
|
},
|
||||||
items: _schemes.map((String scheme) {
|
items: _schemes.map((String scheme) {
|
||||||
return DropdownMenuItem<String>(
|
return DropdownMenuItem<String>(
|
||||||
value: scheme,
|
value: scheme,
|
||||||
child: Text(
|
child: Padding(
|
||||||
scheme,
|
padding: const EdgeInsets.symmetric(vertical: 12.0),
|
||||||
style: const TextStyle(fontSize: 12),
|
child: Text(
|
||||||
overflow: TextOverflow.ellipsis,
|
scheme,
|
||||||
|
style: const TextStyle(fontSize: 15),
|
||||||
|
|
||||||
|
softWrap: true,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
@@ -83,7 +179,6 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
|||||||
_selectedScheme = newValue;
|
_selectedScheme = newValue;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isExpanded: true,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -94,9 +189,7 @@ class _PMMainScreenState extends State<PMMainScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: _handleCreate,
|
||||||
// Action for Create button
|
|
||||||
},
|
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
Theme.of(context).colorScheme.primaryContainer,
|
Theme.of(context).colorScheme.primaryContainer,
|
||||||
|
|||||||
238
lib/features/yojna/screens/pmjjby_screen.dart
Normal file
238
lib/features/yojna/screens/pmjjby_screen.dart
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:kmobile/api/services/yojna_service.dart';
|
||||||
|
import 'package:kmobile/di/injection.dart';
|
||||||
|
|
||||||
|
class PMJJBYScreen extends StatefulWidget {
|
||||||
|
final Map<String, dynamic>? initialData;
|
||||||
|
const PMJJBYScreen({super.key, this.initialData});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PMJJBYScreen> createState() => _PMJJBYScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PMJJBYScreenState extends State<PMJJBYScreen> {
|
||||||
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
|
// Controllers for all requested fields
|
||||||
|
late final _aadhaarController = TextEditingController(text: widget.initialData?['aadharno']?.toString());
|
||||||
|
late final _accountNoController = TextEditingController(text: widget.initialData?['accountno']?.toString());
|
||||||
|
late final _balanceController = TextEditingController(text: widget.initialData?['availablebalance']?.toString());
|
||||||
|
late final _countryController = TextEditingController(text: widget.initialData?['country']?.toString() ?? 'IN');
|
||||||
|
late final _dobController = TextEditingController(text: widget.initialData?['customerdob']?.toString());
|
||||||
|
late final _nameController = TextEditingController(text: widget.initialData?['customername']?.toString());
|
||||||
|
late final _customerNoController = TextEditingController(text: widget.initialData?['customerno']?.toString());
|
||||||
|
late final _acctOpeningDateController = TextEditingController(text: widget.initialData?['dateofacctopening']?.toString());
|
||||||
|
late final _emailController = TextEditingController(text: widget.initialData?['emailid']?.toString());
|
||||||
|
late final _financialYearController = TextEditingController(text: widget.initialData?['financialyear']?.toString());
|
||||||
|
late final _genderController = TextEditingController(text: widget.initialData?['gender']?.toString());
|
||||||
|
late final _ifscController = TextEditingController(text: widget.initialData?['ifsccode']?.toString());
|
||||||
|
late final _marriedController = TextEditingController(text: widget.initialData?['married']?.toString());
|
||||||
|
late final _mobileController = TextEditingController(text: widget.initialData?['mobileno']?.toString());
|
||||||
|
late final _panController = TextEditingController(text: widget.initialData?['pan']?.toString());
|
||||||
|
late final _pincodeController = TextEditingController(text: widget.initialData?['pincode']?.toString());
|
||||||
|
late final _policyNumberController = TextEditingController(text: widget.initialData?['policynumber']?.toString());
|
||||||
|
late final _premiumAmountController = TextEditingController(text: widget.initialData?['premiumamount']?.toString());
|
||||||
|
late final _stateController = TextEditingController(text: widget.initialData?['state']?.toString());
|
||||||
|
final _healthStatusController = TextEditingController();
|
||||||
|
final _collectionChannelController = TextEditingController();
|
||||||
|
final _nomineeNameController = TextEditingController();
|
||||||
|
final _nomineeAddressController = TextEditingController();
|
||||||
|
final _nomineeRelationshipController = TextEditingController();
|
||||||
|
final _nomineeMinorController = TextEditingController();
|
||||||
|
final _ruralCategoryController = TextEditingController();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_aadhaarController.dispose();
|
||||||
|
_accountNoController.dispose();
|
||||||
|
_balanceController.dispose();
|
||||||
|
_countryController.dispose();
|
||||||
|
_dobController.dispose();
|
||||||
|
_nameController.dispose();
|
||||||
|
_customerNoController.dispose();
|
||||||
|
_acctOpeningDateController.dispose();
|
||||||
|
_emailController.dispose();
|
||||||
|
_financialYearController.dispose();
|
||||||
|
_genderController.dispose();
|
||||||
|
_ifscController.dispose();
|
||||||
|
_marriedController.dispose();
|
||||||
|
_mobileController.dispose();
|
||||||
|
_panController.dispose();
|
||||||
|
_pincodeController.dispose();
|
||||||
|
_policyNumberController.dispose();
|
||||||
|
_premiumAmountController.dispose();
|
||||||
|
_stateController.dispose();
|
||||||
|
_healthStatusController.dispose();
|
||||||
|
_collectionChannelController.dispose();
|
||||||
|
_nomineeNameController.dispose();
|
||||||
|
_nomineeAddressController.dispose();
|
||||||
|
_nomineeRelationshipController.dispose();
|
||||||
|
_nomineeMinorController.dispose();
|
||||||
|
_ruralCategoryController.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool _isFetched(String key) {
|
||||||
|
return widget.initialData != null &&
|
||||||
|
widget.initialData!.containsKey(key) &&
|
||||||
|
widget.initialData![key]?.toString().isNotEmpty == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _handleRegister() async {
|
||||||
|
// Show loading spinner
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => const Center(child: CircularProgressIndicator()),
|
||||||
|
);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final response = await getIt<YojnaService>().secondvalidationPMJJBY(
|
||||||
|
aadharno: _aadhaarController.text,
|
||||||
|
accountno: _accountNoController.text,
|
||||||
|
availablebalance: _balanceController.text,
|
||||||
|
country: _countryController.text,
|
||||||
|
customerdob: _dobController.text,
|
||||||
|
customername: _nameController.text,
|
||||||
|
customerno: _customerNoController.text,
|
||||||
|
dateofacctopening: _acctOpeningDateController.text,
|
||||||
|
emailid: _emailController.text,
|
||||||
|
financialyear: _financialYearController.text,
|
||||||
|
gender: _genderController.text,
|
||||||
|
ifsccode: _ifscController.text,
|
||||||
|
married: _marriedController.text,
|
||||||
|
mobileno: _mobileController.text,
|
||||||
|
pan: _panController.text,
|
||||||
|
pincode: _pincodeController.text,
|
||||||
|
policynumber: _policyNumberController.text,
|
||||||
|
premiumamount: _premiumAmountController.text,
|
||||||
|
state: _stateController.text,
|
||||||
|
healthstatus: _healthStatusController.text,
|
||||||
|
collectionchannel: _collectionChannelController.text,
|
||||||
|
nomineename: _nomineeNameController.text,
|
||||||
|
nomineeaddress: _nomineeAddressController.text,
|
||||||
|
nomineerelationship: _nomineeRelationshipController.text,
|
||||||
|
nomineeminor: _nomineeMinorController.text,
|
||||||
|
ruralcategory: _ruralCategoryController.text,
|
||||||
|
);
|
||||||
|
String x = response.toString();
|
||||||
|
if(x.contains('RECORD ALREADY EXISTS')){
|
||||||
|
x= "A record already exists for this request. Your submission has been registered previously.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
// Close loading spinner
|
||||||
|
Navigator.pop(context);
|
||||||
|
// Show response dialog
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Response'),
|
||||||
|
content: SingleChildScrollView(child: Text(x)),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||||
|
},
|
||||||
|
child: const Text('Close'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
if (mounted) {
|
||||||
|
Navigator.pop(context); // Close loading spinner
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(content: Text('Error: ${e.toString()}')),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('PMJJBY Registration'),
|
||||||
|
),
|
||||||
|
body: SingleChildScrollView(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Form(
|
||||||
|
key: _formKey,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
_buildTextField(_nameController, 'Customer Name', readOnly: _isFetched('customername')),
|
||||||
|
_buildTextField(_customerNoController, 'Customer No', readOnly: _isFetched('customerno')),
|
||||||
|
_buildTextField(_accountNoController, 'Account No', keyboardType: TextInputType.number, readOnly: _isFetched('accountno')),
|
||||||
|
_buildTextField(_balanceController, 'Available Balance', keyboardType: TextInputType.number, readOnly: _isFetched('availablebalance')),
|
||||||
|
_buildTextField(_aadhaarController, 'Aadhaar No', keyboardType: TextInputType.number, readOnly: _isFetched('aadharno')),
|
||||||
|
_buildTextField(_dobController, 'Customer DOB (DD/MM/YYYY)', readOnly: _isFetched('customerdob')),
|
||||||
|
_buildTextField(_genderController, 'Gender', readOnly: _isFetched('gender')),
|
||||||
|
_buildTextField(_marriedController, 'Married (Yes/No)', readOnly: _isFetched('married')),
|
||||||
|
_buildTextField(_mobileController, 'Mobile No', keyboardType: TextInputType.phone, readOnly: _isFetched('mobileno')),
|
||||||
|
_buildTextField(_emailController, 'Email ID', keyboardType: TextInputType.emailAddress, readOnly: _isFetched('emailid')),
|
||||||
|
_buildTextField(_panController, 'PAN', readOnly: _isFetched('pan')),
|
||||||
|
_buildTextField(_ifscController, 'IFSC Code', readOnly: _isFetched('ifsccode')),
|
||||||
|
_buildTextField(_acctOpeningDateController, 'Date of Acct Opening', readOnly: _isFetched('dateofacctopening')),
|
||||||
|
_buildTextField(_pincodeController, 'Pincode', keyboardType: TextInputType.number, readOnly: _isFetched('pincode')),
|
||||||
|
_buildTextField(_stateController, 'State', readOnly: _isFetched('state')),
|
||||||
|
_buildTextField(_countryController, 'Country', readOnly: _isFetched('country')),
|
||||||
|
_buildTextField(_ruralCategoryController, 'Rural Category'),
|
||||||
|
const Divider(height: 32),
|
||||||
|
const Text('Policy Details', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildTextField(_policyNumberController, 'Policy Number', readOnly: _isFetched('policynumber')),
|
||||||
|
_buildTextField(_premiumAmountController, 'Premium Amount', keyboardType: TextInputType.number, readOnly: _isFetched('premiumamount')),
|
||||||
|
_buildTextField(_financialYearController, 'Financial Year', readOnly: _isFetched('financialyear')),
|
||||||
|
_buildTextField(_healthStatusController, 'Health Status'),
|
||||||
|
_buildTextField(_collectionChannelController, 'Collection Channel'),
|
||||||
|
const Divider(height: 32),
|
||||||
|
const Text('Nominee Details', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
_buildTextField(_nomineeNameController, 'Nominee Name'),
|
||||||
|
_buildTextField(_nomineeAddressController, 'Nominee Address'),
|
||||||
|
_buildTextField(_nomineeRelationshipController, 'Nominee Relationship'),
|
||||||
|
_buildTextField(_nomineeMinorController, 'Nominee Minor (Yes/No)'),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
ElevatedButton(
|
||||||
|
onPressed: _handleRegister,
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
||||||
|
foregroundColor: Colors.white,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'Register',
|
||||||
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildTextField(TextEditingController controller, String label, {TextInputType keyboardType = TextInputType.text, bool readOnly = false}) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 16.0),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: controller,
|
||||||
|
readOnly: readOnly,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
labelText: label,
|
||||||
|
border: const OutlineInputBorder(),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(vertical: 16, horizontal: 12),
|
||||||
|
),
|
||||||
|
keyboardType: keyboardType,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user