validation changes
This commit is contained in:
parent
872b4e4649
commit
7ff6c82a9c
File diff suppressed because one or more lines are too long
@ -5,12 +5,13 @@ class Env {
|
||||
);
|
||||
static const String apiUrl = String.fromEnvironment(
|
||||
'API_URL',
|
||||
// defaultValue: 'https://partner.nhanceindia.in/partner_api/api/',
|
||||
defaultValue: 'https://venbait.in/nhance/partner/dev/api/',
|
||||
);
|
||||
static const String baseUrl = String.fromEnvironment(
|
||||
'BASE_URL',
|
||||
defaultValue: '/nhance/partner/app',
|
||||
);
|
||||
// static const String baseUrl = String.fromEnvironment(
|
||||
// 'BASE_URL',
|
||||
// defaultValue: '/nhance/partner/app',
|
||||
// );
|
||||
static const String App_Signature = String.fromEnvironment(
|
||||
'App_Signature',
|
||||
defaultValue: 'nhance-partner-2025-signature-35468846JRhH551HK',
|
||||
|
||||
@ -340,13 +340,15 @@ class ApiService {
|
||||
final url;
|
||||
|
||||
if (role == 'staff') {
|
||||
url = Uri.parse(
|
||||
'https://venbait.in/nhance/partner/dev/api/staff/changeStaffStatus',
|
||||
);
|
||||
// url = Uri.parse(
|
||||
// 'https://venbait.in/nhance/partner/dev/api/staff/changeStaffStatus',
|
||||
// );
|
||||
url = Uri.parse('${Env.apiUrl}staff/changeStaffStatus');
|
||||
} else {
|
||||
url = Uri.parse(
|
||||
'https://venbait.in/nhance/partner/dev/api/agent/changeAgentStatus',
|
||||
);
|
||||
// url = Uri.parse(
|
||||
// 'https://venbait.in/nhance/partner/dev/api/agent/changeAgentStatus',
|
||||
// );
|
||||
url = Uri.parse('${Env.apiUrl}/api/agent/changeAgentStatus');
|
||||
}
|
||||
|
||||
// final token = await getToken(); // Fetch token
|
||||
|
||||
@ -117,4 +117,25 @@ class Validators {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String? nonReqemail(String? value, String label) {
|
||||
// ✅ Skip validation if empty
|
||||
if (value == null || value.trim().isEmpty) return null;
|
||||
|
||||
final emailRegex = r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$';
|
||||
if (!RegExp(emailRegex).hasMatch(value.trim())) {
|
||||
return "Invalid $label";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String? nonReqphone(String? value, String label) {
|
||||
// ✅ Skip validation if empty
|
||||
if (value == null || value.trim().isEmpty) return null;
|
||||
|
||||
if (!RegExp(r'^[0-9]{10}$').hasMatch(value.trim())) {
|
||||
return "Enter a valid 10-digit phone number";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:nhance_partner/presentation/layouts/responsive_layout.dart';
|
||||
import 'package:nhance_partner/presentation/providers/userRoleProvider.dart';
|
||||
@ -770,10 +771,10 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
|
||||
Widget buildEmail(BuildContext context) {
|
||||
return buildResponsiveField(
|
||||
label: "Email *",
|
||||
label: "Email",
|
||||
field: ThemedFormField(
|
||||
controller: controllers['email']!,
|
||||
validator: (value) => Validators.email(value, "email"),
|
||||
validator: (value) => Validators.nonReqemail(value, "email"),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z0-9_@.]')),
|
||||
],
|
||||
@ -786,10 +787,10 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
|
||||
Widget buildPhNumber(BuildContext context) {
|
||||
return buildResponsiveField(
|
||||
label: "Phone Number *",
|
||||
label: "Phone Number",
|
||||
field: ThemedFormField(
|
||||
controller: controllers['mobile']!,
|
||||
validator: (value) => Validators.phone(value, "phNumber"),
|
||||
validator: (value) => Validators.nonReqphone(value, "phone"),
|
||||
inputFormatters: [FilteringTextInputFormatter.allow(RegExp(r'[ 0-9]'))],
|
||||
txtwidth: ResponsiveLayout.isMobile(context)
|
||||
? null
|
||||
@ -873,6 +874,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
hintText: "Search Vehicle Type...",
|
||||
hintStyle: GoogleFonts.inter(fontSize: 12, color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
@ -886,7 +888,18 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// constraints: BoxConstraints(),
|
||||
itemBuilder: (context, item, isDisabled, isSelected) {
|
||||
return Container(
|
||||
// color: isSelected ? Colors.blue.withOpacity(0.1) : null,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
child: Text(
|
||||
item['vehicle_type'].toString(),
|
||||
style: GoogleFonts.inter(fontSize: 13, color: Colors.black),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
onChanged: (val) {
|
||||
@ -1043,6 +1056,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
hintText: "Search Partner...",
|
||||
hintStyle: GoogleFonts.inter(fontSize: 12, color: Colors.black),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
@ -1056,7 +1070,33 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// constraints: BoxConstraints(),
|
||||
itemBuilder: (context, item, isDisabled, isSelected) {
|
||||
return Container(
|
||||
// color: isSelected ? Colors.blue.withOpacity(0.1) : null,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
item['name'].toString(),
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 13,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
item['agent_code'].toString(),
|
||||
style: GoogleFonts.inter(
|
||||
fontSize: 13,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
onChanged: (val) {
|
||||
|
||||
@ -608,6 +608,7 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.remove('enqAgentDataId');
|
||||
ref.read(enquiryIdProvider.notifier).state = null;
|
||||
context.go(AppRoutes.tabEnquiry);
|
||||
// print('Export');
|
||||
},
|
||||
|
||||
@ -802,6 +802,7 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.remove('enqAgentDataId');
|
||||
ref.read(enquiryIdProvider.notifier).state = null;
|
||||
context.go(AppRoutes.tabEnquiry);
|
||||
// print('Export');
|
||||
},
|
||||
|
||||
@ -57,11 +57,10 @@ class _SplashScreenState extends State<SplashScreen> {
|
||||
const SizedBox(height: 10),
|
||||
|
||||
// Environment Label (Optional)
|
||||
Text(
|
||||
"Environment: ${Env.envName.toUpperCase()}",
|
||||
style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||
),
|
||||
|
||||
// Text(
|
||||
// "Environment: ${Env.envName.toUpperCase()}",
|
||||
// style: const TextStyle(fontSize: 14, color: Colors.grey),
|
||||
// ),
|
||||
const SizedBox(height: 30),
|
||||
|
||||
// Loading Indicator
|
||||
|
||||
@ -262,7 +262,6 @@ class _DateFilterRowState extends ConsumerState<DateFilterRow> {
|
||||
controller: widget.startController,
|
||||
onDateSelected: (date) {
|
||||
print("Picked Date: $date");
|
||||
|
||||
widget.startController.text = DateFormat('dd-MM-yyyy').format(date);
|
||||
// controllers['date']?.text = date as String;
|
||||
},
|
||||
@ -526,7 +525,6 @@ class _DateFilterRowState extends ConsumerState<DateFilterRow> {
|
||||
),
|
||||
|
||||
itemBuilder: (context, item, isDisabled, isSelected) {
|
||||
// ✅ 4 parameters
|
||||
return Container(
|
||||
// color: isSelected ? Colors.blue.withOpacity(0.1) : null,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@ -1,15 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:http/http.dart' as ref;
|
||||
// import 'package:http/http.dart' as ref;
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:nhance_partner/presentation/providers/userRoleProvider.dart';
|
||||
|
||||
import '../../core/routing/routes.dart';
|
||||
import '../layouts/responsive_layout.dart';
|
||||
import '../providers/manager_provider.dart';
|
||||
import '../providers/userRoleProvider.dart';
|
||||
|
||||
class TopBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
class TopBar extends ConsumerStatefulWidget implements PreferredSizeWidget {
|
||||
final String title;
|
||||
final bool isMobile;
|
||||
final VoidCallback? onLogout;
|
||||
@ -28,13 +31,15 @@ class TopBar extends StatefulWidget implements PreferredSizeWidget {
|
||||
});
|
||||
|
||||
@override
|
||||
State<TopBar> createState() => _TopBarState();
|
||||
ConsumerState<TopBar> createState() => _TopBarState();
|
||||
// State<TopBar> createState() => _TopBarState();
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||
}
|
||||
|
||||
class _TopBarState extends State<TopBar> {
|
||||
// class _TopBarState extends State<TopBar>
|
||||
class _TopBarState extends ConsumerState<TopBar> {
|
||||
String? role;
|
||||
|
||||
@override
|
||||
@ -109,6 +114,7 @@ class _TopBarState extends State<TopBar> {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
await prefs.remove('enqAgentDataId');
|
||||
ref.read(enquiryIdProvider.notifier).state = null;
|
||||
context.go(AppRoutes.tabEnquiry);
|
||||
// print('Export');
|
||||
},
|
||||
@ -145,10 +151,13 @@ class _TopBarState extends State<TopBar> {
|
||||
child: Tooltip(
|
||||
message: 'Notifications',
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.notifications_none, color: Colors.black87),
|
||||
icon: const Icon(
|
||||
Icons.notifications_none,
|
||||
color: Colors.black87,
|
||||
),
|
||||
onPressed: widget.onNotifications,
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
if (!widget.isMobile) ...[
|
||||
SizedBox(width: 10),
|
||||
@ -159,12 +168,16 @@ class _TopBarState extends State<TopBar> {
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(50.0),
|
||||
),
|
||||
child : Tooltip( message: 'Profile',
|
||||
child: GestureDetector(
|
||||
onTapDown: (details) => widget.onProfile!(details),
|
||||
child: const Icon(Icons.person_outline, color: Colors.black87),
|
||||
child: Tooltip(
|
||||
message: 'Profile',
|
||||
child: GestureDetector(
|
||||
onTapDown: (details) => widget.onProfile!(details),
|
||||
child: const Icon(
|
||||
Icons.person_outline,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
|
||||
// IconButton(
|
||||
@ -180,13 +193,13 @@ class _TopBarState extends State<TopBar> {
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(50.0),
|
||||
),
|
||||
child: Tooltip(
|
||||
message: 'Logout',
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.logout, color: Colors.black87),
|
||||
onPressed: widget.onLogout,
|
||||
),
|
||||
)
|
||||
child: Tooltip(
|
||||
message: 'Logout',
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.logout, color: Colors.black87),
|
||||
onPressed: widget.onLogout,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
the `--base-href` argument provided to `flutter build`.
|
||||
-->
|
||||
<!-- <base href="$FLUTTER_BASE_HREF">-->
|
||||
<!-- <base href="/partner/">-->
|
||||
<base href="/nhance/partner/app/">
|
||||
|
||||
<meta charset="UTF-8">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user