Skip to content

Commit 28ef404

Browse files
authored
Merge pull request #9 from gmbcode/beta_l
Merge into main
2 parents b2b8ccf + 36e201a commit 28ef404

File tree

85 files changed

+5982
-3814
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+5982
-3814
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ migrate_working_dir/
1717
*.ipr
1818
*.iws
1919
.idea/
20-
20+
.vscode/
2121
# The .vscode folder contains launch configuration and tasks you configure in
2222
# VS Code which you may wish to be included in version control, so this line
2323
# is commented out by default.

android/build.gradle.kts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ allprojects {
55
}
66
}
77

8-
val newBuildDir: Directory =
9-
rootProject.layout.buildDirectory
10-
.dir("../../build")
11-
.get()
8+
// Remove ': Directory' type annotation here
9+
val newBuildDir = rootProject.layout.buildDirectory
10+
.dir("../../build")
11+
.get()
12+
1213
rootProject.layout.buildDirectory.value(newBuildDir)
1314

1415
subprojects {
15-
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
16+
// Remove ': Directory' type annotation here as well
17+
val newSubprojectBuildDir = newBuildDir.dir(project.name)
1618
project.layout.buildDirectory.value(newSubprojectBuildDir)
1719
}
20+
1821
subprojects {
1922
project.evaluationDependsOn(":app")
2023
}
2124

2225
tasks.register<Delete>("clean") {
2326
delete(rootProject.layout.buildDirectory)
24-
}
27+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3+
# Updated to version 8.11.1 as required by the error message
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
35
zipStoreBase=GRADLE_USER_HOME
4-
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip
6+
zipStorePath=wrapper/dists

lib/features/auth/presentation/pages/roleselection/customer_role.dart

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// lib/features/auth/presentation/pages/roleselection/customer_role.dart
2+
13
import 'package:azt/features/auth/presentation/components/my_button.dart';
24
import 'package:azt/features/auth/presentation/components/my_textfield.dart';
35
import 'package:azt/features/auth/presentation/cubits/auth_cubit.dart';
@@ -31,18 +33,19 @@ class _customerRoleState extends State<customerRole> {
3133
if(address.isEmpty || pincode.isEmpty){
3234
ScaffoldMessenger.of(context).showSnackBar(
3335
const SnackBar(content: Text("Please enter all Fields!")));
36+
return; // Add return to stop execution
3437
}
3538

3639
if (!isPincodeValid) {
3740
ScaffoldMessenger.of(context).showSnackBar(
38-
SnackBar(content: Text("Pincode must be exactly 6 digits!!")),
41+
const SnackBar(content: Text("Pincode must be exactly 6 digits!!")),
3942
);
4043
return;
4144
}
4245

4346
if(address.length>200){
4447
ScaffoldMessenger.of(context).showSnackBar(
45-
SnackBar(content: Text("Address is too Long!")),
48+
const SnackBar(content: Text("Address is too Long!")),
4649
);
4750
return;
4851
}
@@ -52,11 +55,16 @@ class _customerRoleState extends State<customerRole> {
5255
try{
5356
final authCubit = context.read<AuthCubit>();
5457
await authCubit.saveRoleSelection('customer', address, pincode);
58+
5559
if(mounted){
5660
ScaffoldMessenger.of(context).showSnackBar(
5761
const SnackBar(content: Text("Customer profile created successfully!")),
5862
);
5963
setState(() => _isLoading = false);
64+
65+
//Navigate to home by popping it if profile creation sucessful
66+
Navigator.of(context).pop();
67+
6068
}
6169
} catch(e){
6270
if (mounted) {
@@ -80,10 +88,8 @@ class _customerRoleState extends State<customerRole> {
8088
@override
8189
Widget build(BuildContext context) {
8290
return Scaffold(
83-
8491
//body
8592
body: Center(
86-
8793
child: Padding(
8894
padding: const EdgeInsets.symmetric(horizontal: 100.0),
8995
child: Column(
@@ -128,12 +134,8 @@ class _customerRoleState extends State<customerRole> {
128134
),
129135
GestureDetector(
130136
onTap: (){
131-
Navigator.pushReplacement(
132-
context,
133-
MaterialPageRoute(
134-
builder: (context) => const RoleSelectionpage(),
135-
),
136-
);
137+
// Use pop instead of pushReplacement to correctly go back
138+
Navigator.pop(context);
137139
},
138140
child: Text(
139141
" Click Here to Go Back",
@@ -151,4 +153,4 @@ class _customerRoleState extends State<customerRole> {
151153
)
152154
);
153155
}
154-
}
156+
}

lib/features/auth/presentation/pages/roleselection/retailer_role.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class _retailerRoleState extends State<retailerRole> {
6565
const SnackBar(content: Text("Retailer profile created successfully!")),
6666
);
6767
setState(() => _isLoading = false);
68+
Navigator.of(context).pop();
6869
}
6970
} catch (e) {
7071
if (mounted) {

lib/features/auth/presentation/pages/roleselection/wholesaler_role.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class _wholesalerRoleState extends State<wholesalerRole > {
7272
const SnackBar(content: Text("Wholesaler profile created successfully!")),
7373
);
7474
setState(() => _isLoading = false);
75+
Navigator.of(context).pop();
7576
}
7677
} catch (e) {
7778
if (mounted) {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
class CustomerCartItemModel {
2+
final String productId;
3+
final String retailerId;
4+
final String inventoryItemId;
5+
final String name;
6+
final double price;
7+
final String imageUrl;
8+
final int qty;
9+
10+
CustomerCartItemModel({
11+
required this.productId,
12+
required this.retailerId,
13+
required this.inventoryItemId,
14+
required this.name,
15+
required this.price,
16+
required this.imageUrl,
17+
required this.qty,
18+
});
19+
20+
// --- ADD THIS FACTORY ---
21+
factory CustomerCartItemModel.fromMap(Map<dynamic, dynamic> map) {
22+
return CustomerCartItemModel(
23+
productId: map['id']?.toString() ?? '',
24+
retailerId: map['retailerId']?.toString() ?? '', // Ensure we save this key
25+
inventoryItemId: map['inventoryItemId']?.toString() ?? '',
26+
name: map['name']?.toString() ?? 'Unknown',
27+
price: double.tryParse(map['price'].toString()) ?? 0.0,
28+
imageUrl: map['imageUrl']?.toString() ?? '',
29+
qty: int.tryParse(map['qty'].toString()) ?? 0,
30+
);
31+
}
32+
33+
CustomerCartItemModel copyWith({int? qty}) {
34+
return CustomerCartItemModel(
35+
productId: productId,
36+
retailerId: retailerId,
37+
inventoryItemId: inventoryItemId,
38+
name: name,
39+
price: price,
40+
imageUrl: imageUrl,
41+
qty: qty ?? this.qty,
42+
);
43+
}
44+
45+
Map<String, dynamic> toMap() {
46+
return {
47+
'id': productId,
48+
'retailerId': retailerId, // Important: Add this to the map so we can retrieve it later
49+
'inventoryItemId': inventoryItemId,
50+
'name': name,
51+
'price': price,
52+
'imageUrl': imageUrl,
53+
'qty': qty,
54+
};
55+
}
56+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
class CustomerProductModel {
2+
final String id;
3+
final String retailerId;
4+
final String inventoryItemId;
5+
final String name;
6+
final double price;
7+
final int availableQty;
8+
final String imageUrl;
9+
final String category;
10+
11+
CustomerProductModel({
12+
required this.id,
13+
required this.retailerId,
14+
required this.inventoryItemId,
15+
required this.name,
16+
required this.price,
17+
required this.availableQty,
18+
required this.imageUrl,
19+
required this.category,
20+
});
21+
22+
factory CustomerProductModel.fromMap(String id, Map<dynamic, dynamic> map) {
23+
return CustomerProductModel(
24+
id: id,
25+
retailerId: map['retailerId']?.toString() ?? '',
26+
inventoryItemId: map['inventoryItemId']?.toString() ?? '',
27+
name: map['name']?.toString() ?? 'Unknown Product',
28+
29+
// ROBUST PARSING: Handle String or Number for Price
30+
price: _parseDouble(map['price']),
31+
32+
// ROBUST PARSING: Handle String or Number for Qty
33+
availableQty: _parseInt(map['available_listed_qty']),
34+
35+
imageUrl: map['imageUrl']?.toString() ?? 'https://placehold.co/400?text=No+Image',
36+
category: map['category']?.toString() ?? 'General',
37+
);
38+
}
39+
40+
static double _parseDouble(dynamic value) {
41+
if (value == null) return 0.0;
42+
if (value is num) return value.toDouble();
43+
if (value is String) return double.tryParse(value) ?? 0.0;
44+
return 0.0;
45+
}
46+
47+
static int _parseInt(dynamic value) {
48+
if (value == null) return 0;
49+
if (value is num) return value.toInt();
50+
if (value is String) return int.tryParse(value) ?? 0;
51+
return 0;
52+
}
53+
}

0 commit comments

Comments
 (0)