diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index 56b0977..038058e 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -620,7 +620,7 @@ "languageVersion": "3.4" } ], - "generated": "2025-01-24T13:29:48.830847Z", + "generated": "2025-01-25T13:26:28.487764Z", "generator": "pub", "generatorVersion": "3.4.4", "flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter", diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index bc492ee..4427f21 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_android-2.2.10/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.2/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]}],"date_created":"2025-01-24 18:59:49.009756","version":"3.22.3"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_android-2.2.10/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.2/","native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"path_provider_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.0/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.4/","shared_darwin_source":true,"native_build":true,"dependencies":[]},{"name":"sqflite","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/sqflite-2.3.3+1/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","native_build":true,"dependencies":[]},{"name":"path_provider_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"connectivity_plus","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/connectivity_plus-6.1.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/Users/rajeevsingh/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"sqflite","dependencies":[]}],"date_created":"2025-01-25 18:56:28.677453","version":"3.22.3"} \ No newline at end of file diff --git a/lib/src/core/constant/api.dart b/lib/src/core/constant/api.dart index 261ca01..1591c83 100644 --- a/lib/src/core/constant/api.dart +++ b/lib/src/core/constant/api.dart @@ -5,8 +5,11 @@ class APIURL { static const String verifyOtp = "${BASE_URL}auth/verify-otp/customer"; static const String login = "${BASE_URL}auth/login/vendor"; static const String customerRegister = "${BASE_URL}auth/register/customer"; - static const String createStore = "${BASE_URL}stores"; - static const String getStore = "${BASE_URL}stores/"; + + static const String getStore = "${BASE_URL}stores/"; + + static const String getAllProduct = "${BASE_URL}products"; + static const String updateStore = "${BASE_URL}stores/"; static const String forgetPassword = "${BASE_URL}auth/forgot-password/vendor"; static const String verifyForgetPassword = @@ -18,7 +21,7 @@ class APIURL { static const String getMe = "${BASE_URL}auth/me"; static const String refresh_token = "${BASE_URL}auth/refresh-token"; static const String createProduct = "${BASE_URL}products"; - static const String vendorLogOut = "${BASE_URL}auth/logout/vendor"; + static const String customerLogOut = "${BASE_URL}/auth/logout/customer"; static const String uploadImage = "${BASE_URL}images/upload"; static const String deleteProduct = "${BASE_URL}products/"; static const String updateProduct = "${BASE_URL}products/"; diff --git a/lib/src/data/allProduct_model.dart b/lib/src/data/allProduct_model.dart new file mode 100644 index 0000000..8f9f5dd --- /dev/null +++ b/lib/src/data/allProduct_model.dart @@ -0,0 +1,397 @@ +// To parse this JSON data, do +// +// final allProductModel = allProductModelFromJson(jsonString); + +import 'dart:convert'; + +AllProductModel allProductModelFromJson(String str) => + AllProductModel.fromJson(json.decode(str)); + +String allProductModelToJson(AllProductModel data) => + json.encode(data.toJson()); + +class AllProductModel +{ + List? data; + Meta? meta; + + AllProductModel({ + this.data, + this.meta, + }); + + factory AllProductModel.fromJson(Map json) => + AllProductModel( + data: List.from(json["data"].map((x) => Product.fromJson(x))), + meta: Meta.fromJson(json["meta"]), + ); + + Map toJson() => { + "data": List.from(data!.map((x) => x.toJson())), + "meta": meta!.toJson(), + }; +} + +class Product { + dynamic id; + dynamic name; + dynamic description; + dynamic additionalInfo; + dynamic brand; + dynamic basePrice; + dynamic discountPrice; + dynamic stock; + dynamic quantity; + dynamic unit; + dynamic slug; + dynamic rating; + bool? isInStock; + bool? isActive; + DateTime? createdAt; + DateTime? updatedAt; + dynamic storeId; + dynamic categoryId; + dynamic productTypeId; + dynamic timeSlotId; + Store? store; + Category? category; + dynamic productType; + dynamic timeSlot; + List? productImages; + List? productTags; + List? zones; + List? productReview; + + Product({ + this.id, + this.name, + this.description, + this.additionalInfo, + this.brand, + this.basePrice, + this.discountPrice, + this.stock, + this.quantity, + this.unit, + this.slug, + this.rating, + this.isInStock, + this.isActive, + this.createdAt, + this.updatedAt, + this.storeId, + this.categoryId, + this.productTypeId, + this.timeSlotId, + this.store, + this.category, + this.productType, + this.timeSlot, + this.productImages, + this.productTags, + this.zones, + this.productReview, + }); + + factory Product.fromJson(Map json) => Product( + id: json["id"], + name: json["name"], + description: json["description"], + additionalInfo: json["additionalInfo"], + brand: json["brand"], + basePrice: json["basePrice"], + discountPrice: json["discountPrice"], + stock: json["stock"], + quantity: json["quantity"], + unit: json["unit"], + slug: json["slug"], + rating: json["rating"], + isInStock: json["isInStock"], + isActive: json["isActive"], + createdAt: DateTime.parse(json["createdAt"]), + updatedAt: DateTime.parse(json["updatedAt"]), + storeId: json["storeId"], + categoryId: json["categoryId"], + productTypeId: json["productTypeId"], + timeSlotId: json["timeSlotId"], + store: Store.fromJson(json["store"]), + category: Category.fromJson(json["category"]), + productType: json["productType"], + timeSlot: json["timeSlot"], + productImages: List.from( + json["productImages"].map((x) => ProductImage.fromJson(x))), + productTags: List.from(json["productTags"].map((x) => x)), + zones: List.from(json["zones"].map((x) => x)), + productReview: List.from( + json["ProductReview"].map((x) => ProductReview.fromJson(x))), + ); + + Map toJson() => { + "id": id, + "name": name, + "description": description, + "additionalInfo": additionalInfo, + "brand": brand, + "basePrice": basePrice, + "discountPrice": discountPrice, + "stock": stock, + "quantity": quantity, + "unit": unit, + "slug": slug, + "rating": rating, + "isInStock": isInStock, + "isActive": isActive, + "createdAt": createdAt, + "updatedAt": updatedAt, + "storeId": storeId, + "categoryId": categoryId, + "productTypeId": productTypeId, + "timeSlotId": timeSlotId, + "store": store!.toJson(), + "category": category!.toJson(), + "productType": productType, + "timeSlot": timeSlot, + "productImages": + List.from(productImages!.map((x) => x.toJson())), + "productTags": List.from(productTags!.map((x) => x)), + "zones": List.from(zones!.map((x) => x)), + "ProductReview": + List.from(productReview!.map((x) => x.toJson())), + }; +} + +class Category { + dynamic id; + dynamic name; + dynamic description; + dynamic image; + dynamic slug; + dynamic level; + bool? isActive; + DateTime? createdAt; + DateTime? updatedAt; + dynamic parentCategoryId; + dynamic path; + + Category({ + this.id, + this.name, + this.description, + this.image, + this.slug, + this.level, + this.isActive, + this.createdAt, + this.updatedAt, + this.parentCategoryId, + this.path, + }); + + factory Category.fromJson(Map json) => Category( + id: json["id"], + name: json["name"], + description: json["description"], + image: json["image"], + slug: json["slug"], + level: json["level"], + isActive: json["isActive"], + createdAt: DateTime.parse(json["createdAt"]), + updatedAt: DateTime.parse(json["updatedAt"]), + parentCategoryId: json["parentCategoryId"], + path: json["path"], + ); + + Map toJson() => { + "id": id, + "name": name, + "description": description, + "image": image, + "slug": slug, + "level": level, + "isActive": isActive, + "createdAt": createdAt, + "updatedAt": updatedAt, + "parentCategoryId": parentCategoryId, + "path": path, + }; +} + +class ProductImage { + dynamic id; + dynamic url; + bool? isDefault; + dynamic productId; + + ProductImage({ + this.id, + this.url, + this.isDefault, + this.productId, + }); + + factory ProductImage.fromJson(Map json) => ProductImage( + id: json["id"], + url: json["url"], + isDefault: json["isDefault"], + productId: json["productId"], + ); + + Map toJson() => { + "id": id, + "url": url, + "isDefault": isDefault, + "productId": productId, + }; +} + +class ProductReview { + dynamic id; + dynamic userId; + dynamic productId; + dynamic rating; + dynamic title; + dynamic description; + dynamic likes; + dynamic dislikes; + dynamic helpfulCount; + bool? isVerified; + bool? verifiedPurchase; + dynamic status; + DateTime? createdAt; + DateTime? updatedAt; + + ProductReview({ + this.id, + this.userId, + this.productId, + this.rating, + this.title, + this.description, + this.likes, + this.dislikes, + this.helpfulCount, + this.isVerified, + this.verifiedPurchase, + this.status, + this.createdAt, + this.updatedAt, + }); + + factory ProductReview.fromJson(Map json) => ProductReview( + id: json["id"], + userId: json["userId"], + productId: json["productId"], + rating: json["rating"], + title: json["title"], + description: json["description"], + likes: json["likes"], + dislikes: json["dislikes"], + helpfulCount: json["helpfulCount"], + isVerified: json["isVerified"], + verifiedPurchase: json["verifiedPurchase"], + status: json["status"], + createdAt: DateTime.parse(json["createdAt"]), + updatedAt: DateTime.parse(json["updatedAt"]), + ); + + Map toJson() => { + "id": id, + "userId": userId, + "productId": productId, + "rating": rating, + "title": title, + "description": description, + "likes": likes, + "dislikes": dislikes, + "helpfulCount": helpfulCount, + "isVerified": isVerified, + "verifiedPurchase": verifiedPurchase, + "status": status, + "createdAt": createdAt, + "updatedAt": updatedAt, + }; +} + +class Store { + dynamic id; + dynamic storeName; + dynamic storeDescription; + dynamic officialPhoneNumber; + dynamic storeAddress; + dynamic gstNumber; + dynamic gumastaNumber; + dynamic storePicture; + DateTime? createdAt; + DateTime? updatedAt; + dynamic vendorId; + bool? isActive; + + Store({ + this.id, + this.storeName, + this.storeDescription, + this.officialPhoneNumber, + this.storeAddress, + this.gstNumber, + this.gumastaNumber, + this.storePicture, + this.createdAt, + this.updatedAt, + this.vendorId, + this.isActive, + }); + + factory Store.fromJson(Map json) => Store( + id: json["id"], + storeName: json["storeName"], + storeDescription: json["storeDescription"], + officialPhoneNumber: json["officialPhoneNumber"], + storeAddress: json["storeAddress"], + gstNumber: json["gstNumber"], + gumastaNumber: json["gumastaNumber"], + storePicture: json["storePicture"], + createdAt: DateTime.parse(json["createdAt"]), + updatedAt: DateTime.parse(json["updatedAt"]), + vendorId: json["vendorId"], + isActive: json["isActive"], + ); + + Map toJson() => { + "id": id, + "storeName": storeName, + "storeDescription": storeDescription, + "officialPhoneNumber": officialPhoneNumber, + "storeAddress": storeAddress, + "gstNumber": gstNumber, + "gumastaNumber": gumastaNumber, + "storePicture": storePicture, + "createdAt": createdAt, + "updatedAt": updatedAt, + "vendorId": vendorId, + "isActive": isActive, + }; +} + +class Meta { + dynamic total; + dynamic page; + dynamic lastPage; + + Meta({ + this.total, + this.page, + this.lastPage, + }); + + factory Meta.fromJson(Map json) => Meta( + total: json["total"], + page: json["page"], + lastPage: json["lastPage"], + ); + + Map toJson() => { + "total": total, + "page": page, + "lastPage": lastPage, + }; +} diff --git a/lib/src/data/registration_response.dart b/lib/src/data/registration_response.dart new file mode 100644 index 0000000..39b1d60 --- /dev/null +++ b/lib/src/data/registration_response.dart @@ -0,0 +1,128 @@ +// To parse this JSON data, do +// +// final registrationResponse = registrationResponseFromJson(jsonString?); + +import 'dart:convert'; + +RegistrationResponse registrationResponseFromJson(String str) => + RegistrationResponse.fromJson(json.decode(str)); + +String? registrationResponseToJson(RegistrationResponse data) => + json.encode(data.toJson()); + +class RegistrationResponse { + Customer? customer; + String? accessToken; + String? refreshToken; + + RegistrationResponse({ + this.customer, + this.accessToken, + this.refreshToken, + }); + + factory RegistrationResponse.fromJson(Map json) => + RegistrationResponse( + customer: Customer.fromJson(json["customer"]), + accessToken: json["access_token"], + refreshToken: json["refresh_token"], + ); + + Map toJson() => { + "customer": customer!.toJson(), + "access_token": accessToken, + "refresh_token": refreshToken, + }; +} + +class Customer { + String? id; + String? email; + String? firstName; + String? lastName; + dynamic name; + dynamic img; + String? authType; + String? role; + String? phone; + dynamic password; + bool? isPhoneVerified; + dynamic vendorType; + dynamic businessId; + bool? isVendorAccountCreated; + bool? isVendorAccountActive; + bool? vendorTermsAccepted; + DateTime? createdAt; + DateTime? updatedAt; + dynamic resetToken; + dynamic resetTokenExpiresAt; + + Customer({ + this.id, + this.email, + this.firstName, + this.lastName, + this.name, + this.img, + this.authType, + this.role, + this.phone, + this.password, + this.isPhoneVerified, + this.vendorType, + this.businessId, + this.isVendorAccountCreated, + this.isVendorAccountActive, + this.vendorTermsAccepted, + this.createdAt, + this.updatedAt, + this.resetToken, + this.resetTokenExpiresAt, + }); + + factory Customer.fromJson(Map json) => Customer( + id: json["id"], + email: json["email"], + firstName: json["firstName"], + lastName: json["lastName"], + name: json["name"], + img: json["img"], + authType: json["authType"], + role: json["role"], + phone: json["phone"], + password: json["password"], + isPhoneVerified: json["isPhoneVerified"], + vendorType: json["vendorType"], + businessId: json["businessId"], + isVendorAccountCreated: json["isVendorAccountCreated"], + isVendorAccountActive: json["isVendorAccountActive"], + vendorTermsAccepted: json["vendorTermsAccepted"], + createdAt: DateTime.parse(json["createdAt"]), + updatedAt: DateTime.parse(json["updatedAt"]), + resetToken: json["resetToken"], + resetTokenExpiresAt: json["resetTokenExpiresAt"], + ); + + Map toJson() => { + "id": id, + "email": email, + "firstName": firstName, + "lastName": lastName, + "name": name, + "img": img, + "authType": authType, + "role": role, + "phone": phone, + "password": password, + "isPhoneVerified": isPhoneVerified, + "vendorType": vendorType, + "businessId": businessId, + "isVendorAccountCreated": isVendorAccountCreated, + "isVendorAccountActive": isVendorAccountActive, + "vendorTermsAccepted": vendorTermsAccepted, + "createdAt": createdAt, + "updatedAt": updatedAt, + "resetToken": resetToken, + "resetTokenExpiresAt": resetTokenExpiresAt, + }; +} diff --git a/lib/src/logic/provider/auth_provider.dart b/lib/src/logic/provider/auth_provider.dart index e708be5..a467a8c 100644 --- a/lib/src/logic/provider/auth_provider.dart +++ b/lib/src/logic/provider/auth_provider.dart @@ -121,15 +121,12 @@ class AuthProvider extends ChangeNotifier { // //vendorRegister - Future vendorRegister(BuildContext context) async { + Future customerRegister(BuildContext context) async { context.showLoader(show: true); var data = { - "firstName": await SharedPrefUtils.getFirstName(), - "lastName": await SharedPrefUtils.getLastName(), - "email": await SharedPrefUtils.getEmail(), - "password": await SharedPrefUtils.getPassword(), - "vendorType": "individual", - + "firstName": name.text, + "lastName": lastName.text, + "email": email.text, }; try { diff --git a/lib/src/logic/provider/home_provider.dart b/lib/src/logic/provider/home_provider.dart index 1e72bcf..16e5a86 100644 --- a/lib/src/logic/provider/home_provider.dart +++ b/lib/src/logic/provider/home_provider.dart @@ -1,61 +1,21 @@ -// import 'package:flutter/material.dart'; -// import 'package:vendor_app/src/core/network_services/service_locator.dart'; -// import 'package:vendor_app/src/core/utiils_lib/shared_pref_utils.dart'; -// import 'package:vendor_app/src/logic/repo/home_repo.dart'; +import 'package:flutter/material.dart'; +import 'package:grocery_app/src/core/network_services/service_locator.dart'; +import 'package:grocery_app/src/logic/repo/home_repo.dart'; -// class HomeProvider extends ChangeNotifier { -// final _homeRepo = getIt(); +class ProductProvider extends ChangeNotifier { + final _homeRepo = getIt(); -// Future refreshToken(BuildContext context) async { -// var data = {"refresh_token": "${await SharedPrefUtils.getRefreshToken()}"}; + Future gettAllProduct(BuildContext context) async { + var data = {}; -// var result = await _homeRepo.refreshToken(data, context); -// return result.fold( -// (error) { -// print("dkjhsfgjkdfkg"); -// return true; -// }, -// (response) { -// print("dkjhssfdgdfgdfgfgjkdfkg"); -// return true; -// }, -// ); -// } - -// String _userName = ''; -// String _phone = ''; - -// String get userName => _userName; -// String get phone => _phone; - -// void setUserName(String name) { -// _userName = name; -// notifyListeners(); -// } - -// void setPhone(String phoneNumber) { -// _phone = phoneNumber; -// notifyListeners(); -// } - -// Future getMe() async { -// var data = {}; - -// try { -// var result = await _homeRepo.getMe(data); - -// return result.fold( -// (error) {}, -// (response) { -// setUserName(response.firstName); -// setPhone(response.phone); - -// SharedPrefUtils.USER_NAME = -// response.firstName + " " + response.lastName; -// SharedPrefUtils.PHONE = response.phone; -// notifyListeners(); -// }, -// ); -// } catch (e) {} -// } -// } + var result = await _homeRepo.getAllProduct(data, context); + return result.fold( + (error) { + return true; + }, + (response) { + return true; + }, + ); + } +} diff --git a/lib/src/logic/repo/auth_repo.dart b/lib/src/logic/repo/auth_repo.dart index 0efa82c..65d0cef 100644 --- a/lib/src/logic/repo/auth_repo.dart +++ b/lib/src/logic/repo/auth_repo.dart @@ -5,11 +5,11 @@ import 'package:fpdart/fpdart.dart'; import 'package:grocery_app/src/core/utils/custom_dio_exception.dart'; import 'package:grocery_app/src/core/utils/response_type_def.dart'; import 'package:grocery_app/src/data/OTPResponseModel.dart'; +import 'package:grocery_app/src/data/registration_response.dart'; import 'package:grocery_app/src/data/vendor_otpModel.dart'; import 'package:grocery_app/src/logic/services/auth_service_locator.dart'; import 'package:grocery_app/utils/constants/shared_pref_utils.dart'; - class AuthRepo { final AuthServices _authServices; @@ -21,7 +21,7 @@ class AuthRepo { final String model = response.toString(); // OtpResponseModel otpResponseModel = // otpResponseModelFromJson(response.toString()); - + return right(model); } on DioException catch (e) { print("dhfgfdgjdhfgfgh ${e}"); @@ -30,8 +30,6 @@ class AuthRepo { } } - - FutureResult verifyOtp(data) async { try { var response = await _authServices.verifyOtp(data); @@ -39,8 +37,7 @@ class AuthRepo { final VendorOtpModel vendorOtpModel = vendorOtpModelFromJson(response.toString()); - if (vendorOtpModel.data != null) - { + if (vendorOtpModel.data != null) { await SharedPrefUtils.setToken( authToken: vendorOtpModel.data!.accessToken ?? ""); } @@ -95,6 +92,15 @@ class AuthRepo { FutureResult customerRegister(data) async { try { var response = await _authServices.userRegister(data); + + RegistrationResponse registrationResponse = + registrationResponseFromJson(response.toString()); + await SharedPrefUtils.setToken( + authToken: registrationResponse.accessToken ?? ""); + if (response.statCode) { + print("dsfklgjkfgbfgkfdgjkhkfdjg"); + } + final String model = response.toString(); return right(model); } on DioException catch (e) { @@ -143,7 +149,4 @@ class AuthRepo { // return left(error); // } // } - - - } diff --git a/lib/src/logic/repo/home_repo.dart b/lib/src/logic/repo/home_repo.dart index a8797e7..df04651 100644 --- a/lib/src/logic/repo/home_repo.dart +++ b/lib/src/logic/repo/home_repo.dart @@ -1,68 +1,63 @@ -// import 'package:dio/dio.dart'; -// import 'package:flutter/material.dart'; -// import 'package:fpdart/fpdart.dart'; -// import 'package:vendor_app/src/core/routes/routes.dart'; -// import 'package:vendor_app/src/core/utiils_lib/custom_dio_exception.dart'; -// import 'package:vendor_app/src/core/utiils_lib/extensions.dart'; -// import 'package:vendor_app/src/core/utiils_lib/response_type_def.dart'; -// import 'package:vendor_app/src/core/utiils_lib/shared_pref_utils.dart'; -// import 'package:vendor_app/src/data/login_response.dart'; -// import 'package:vendor_app/src/data/vendor_model.dart'; -// import 'package:vendor_app/src/logic/services/home_locator.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/material.dart'; +import 'package:fpdart/fpdart.dart'; +import 'package:grocery_app/src/core/utils/custom_dio_exception.dart'; +import 'package:grocery_app/src/core/utils/response_type_def.dart'; +import 'package:grocery_app/src/data/allProduct_model.dart'; +import 'package:grocery_app/src/logic/services/home_locator.dart'; -// class HomeRepo { -// final HomeService _homeService; -// HomeRepo(this._homeService); +class ProductRepo { + final ProductService _productService; -// FutureResult refreshToken(data, BuildContext context) async { -// try { -// var response = await _homeService.refresh_token(data); -// LoginResponse loginResponse = loginResponseFromJson(response.toString()); + ProductRepo(this._productService); -// if (loginResponse.accessToken != null) { -// print("chwckData ${loginResponse.accessToken}"); -// await SharedPrefUtils.setToken( -// authToken: loginResponse.accessToken ?? ""); -// await SharedPrefUtils.setRefreshToken( -// refresh_token: loginResponse.refreshToken ?? ""); -// } + FutureResult getAllProduct(data, BuildContext context) async { + try { + var response = await _productService.getAllProduct(data); + + AllProductModel loginResponse = allProductModelFromJson(response.toString()); -// final String model = response.toString(); + -// return right(model); -// } on DioException catch (e) -// { -// context.clearAndPush(routePath: MyRoutes.SELECTACCOUNT); + final String model = response.toString(); -// var error = CustomDioExceptions.handleError(e); -// return left(error); -// } -// } - -// FutureResult getMe(data) async { -// try { -// var response = await _homeService.getMe(data); - -// final VendorModel vendorModel = vendorModelFromJson(response.toString()); - -// if (vendorModel != null) -// { -// SharedPrefUtils.USER_NAME = -// vendorModel.firstName + " " + vendorModel.lastName; -// SharedPrefUtils.PHONE = vendorModel.phone; - -// print("dkfjhdkfhkfk ${SharedPrefUtils.USER_NAME}"); -// await SharedPrefUtils.setStoreId(storeId: vendorModel.storeId ?? ""); + return right(model); + } on DioException catch (e) + { -// } -// final String model = response.toString(); + var error = CustomDioExceptions.handleError(e); + return left(error); + } + } -// return right(vendorModel); -// } on DioException catch (e) { -// var error = CustomDioExceptions.handleError(e); -// return left(error); -// } -// } -// } + // FutureResult getMe(data) async { + // try { + // var response = await _homeService.getMe(data); + + // final VendorModel vendorModel = vendorModelFromJson(response.toString()); + + // if (vendorModel != null) + // { + // SharedPrefUtils.USER_NAME = + // vendorModel.firstName + " " + vendorModel.lastName; + // SharedPrefUtils.PHONE = vendorModel.phone; + + // print("dkfjhdkfhkfk ${SharedPrefUtils.USER_NAME}"); + // await SharedPrefUtils.setStoreId(storeId: vendorModel.storeId ?? ""); + + // } + + // final String model = response.toString(); + + // return right(vendorModel); + // } on DioException catch (e) { + // var error = CustomDioExceptions.handleError(e); + // return left(error); + // } + // } + + + +} diff --git a/lib/src/logic/services/home_locator.dart b/lib/src/logic/services/home_locator.dart index 28f357f..2d6f40f 100644 --- a/lib/src/logic/services/home_locator.dart +++ b/lib/src/logic/services/home_locator.dart @@ -1,27 +1,34 @@ -// import 'dart:convert'; +import 'dart:convert'; -// import 'package:vendor_app/src/core/constant/api.dart'; -// import 'package:vendor_app/src/core/network_services/api_services.dart'; +import 'package:grocery_app/src/core/constant/api.dart'; +import 'package:grocery_app/src/core/network_services/api_services.dart'; -// class HomeService extends ApiService { -// Future getMe(data) async { -// var response = await api.get(APIURL.getMe, data: jsonEncode(data)); -// //response.statusCode +class ProductService extends ApiService { -// return response; -// } + Future getMe(data) async { + var response = await api.get(APIURL.getMe, data: jsonEncode(data)); + //response.statusCode -// Future refresh_token(data) async -// { -// var response = await api.post(APIURL.refresh_token, data: jsonEncode(data)); -// //response.statusCode + return response; + } -// return response; -// } + Future refresh_token(data) async + { + var response = await api.post(APIURL.refresh_token, data: jsonEncode(data)); + + + return response; + } + + Future getAllProduct(data) async { + var response = await api.get(APIURL.getAllProduct, data: jsonEncode(data)); + + return response; + } -// } +} diff --git a/lib/src/ui/entername/enter_fullname_screen.dart b/lib/src/ui/entername/enter_fullname_screen.dart index 90a26e1..0bd51a2 100644 --- a/lib/src/ui/entername/enter_fullname_screen.dart +++ b/lib/src/ui/entername/enter_fullname_screen.dart @@ -20,12 +20,9 @@ class EnterFullNameScreen extends StatefulWidget { } class _EnterFullNameScreenState extends State { - - final _formKey = GlobalKey(); @override Widget build(BuildContext context) { - final pageNotifier = Provider.of(context, listen: false); return Scaffold( @@ -60,8 +57,8 @@ class _EnterFullNameScreenState extends State { AppTextFieldWidget( controller: pageNotifier.name, hintText: APPSTRING.firstNameHint, - onValidate: (value){ - if (value == null || value.isEmpty) { + onValidate: (value) { + if (value == null || value.isEmpty) { return 'Please Enter first Name'; } return null; @@ -70,15 +67,14 @@ class _EnterFullNameScreenState extends State { AppTextFieldWidget( controller: pageNotifier.lastName, hintText: APPSTRING.lastNameHint, - onValidate: (value){ - if (value == null || value.isEmpty) { + onValidate: (value) { + if (value == null || value.isEmpty) { return 'Please Enter last Name'; } return null; }, ), - - AppTextFieldWidget( + AppTextFieldWidget( controller: pageNotifier.email, hintText: APPSTRING.emailHint, onValidate: (value) { @@ -88,17 +84,16 @@ class _EnterFullNameScreenState extends State { return null; }, ), - AppTextFieldWidget( - controller: pageNotifier.address, - hintText: APPSTRING.addressHint, - onValidate: (value) { - if (value == null || value.isEmpty) - { - return 'Please Enter address'; - } - return null; - }, - ), + // AppTextFieldWidget( + // controller: pageNotifier.address, + // hintText: APPSTRING.addressHint, + // onValidate: (value) { + // if (value == null || value.isEmpty) { + // return 'Please Enter address'; + // } + // return null; + // }, + // ), ], ), ) @@ -115,15 +110,14 @@ class _EnterFullNameScreenState extends State { padding: context.bodyAllPadding.copyWith(bottom: 20), child: Center( child: InkWell( - onTap: () - { + onTap: () async { + if (_formKey.currentState?.validate() ?? false) { + final success = await pageNotifier.customerRegister(context); - if (_formKey.currentState?.validate() ?? false) - { - context.clearAndPush( routePath: MyRoutes.BOTTOMNAV); + if (success) { + context.clearAndPush(routePath: MyRoutes.BOTTOMNAV); } - - + } // Navigator.of(context).push(MaterialPageRoute( // builder: (context) { diff --git a/lib/src/ui/home/home_screen.dart b/lib/src/ui/home/home_screen.dart index 17971d2..fab08e3 100644 --- a/lib/src/ui/home/home_screen.dart +++ b/lib/src/ui/home/home_screen.dart @@ -158,7 +158,8 @@ class _HomeScreenState extends State { mainAxisSpacing: 5, childAspectRatio: MediaQuery.of(context).size.width / (MediaQuery.of(context).size.height / 1.2), ), - itemBuilder: (context, index) { + itemBuilder: (context, index) + { return InkWell( onTap: () {}, child: SizedBox( diff --git a/lib/src/ui/onboarding/on_boarding_screen.dart b/lib/src/ui/onboarding/on_boarding_screen.dart index 4940c6f..cfe1337 100644 --- a/lib/src/ui/onboarding/on_boarding_screen.dart +++ b/lib/src/ui/onboarding/on_boarding_screen.dart @@ -27,7 +27,7 @@ class _OnBoardingScreenState extends State { skipFunction() { SharedPrefUtils.setFreshInstall(isFresh: false).then( - (value) => context.clearAndPush(routePath: MyRoutes.BOTTOMNAV, args: 0), + (value) => context.clearAndPush(routePath: MyRoutes.LOGIN, args: 0), ); // Navigator.pushReplacement(context, MaterialPageRoute( @@ -221,10 +221,11 @@ class _OnBoardingScreenState extends State { ), Stack( children: [ + Image.asset(APPASSETS.onBoardMan), Positioned( - top: 10, + top: 20, right: 0, - child: InkWell( + child: GestureDetector( onTap: () { skipFunction(); }, @@ -236,15 +237,14 @@ class _OnBoardingScreenState extends State { style: context.customMedium(APPCOLOR.appGreen, 14), ), - const SizedBox( - width: 10, - ), + const SizedBox(width: 10), Container( height: 35, width: 35, decoration: BoxDecoration( - color: APPCOLOR.appGreen, - borderRadius: BorderRadius.circular(90)), + color: APPCOLOR.appGreen, + borderRadius: BorderRadius.circular(90), + ), child: const Center( child: Icon( Icons.arrow_forward, @@ -257,7 +257,6 @@ class _OnBoardingScreenState extends State { ), ), ), - Image.asset(APPASSETS.onBoardMan), Positioned( bottom: 100, right: 0, diff --git a/lib/src/ui/otp/otp_screen.dart b/lib/src/ui/otp/otp_screen.dart index 845e538..14b2f33 100644 --- a/lib/src/ui/otp/otp_screen.dart +++ b/lib/src/ui/otp/otp_screen.dart @@ -73,13 +73,13 @@ class _OtpScreenState extends State { OTPTextField( length: 6, onChanged: (c) { - if (c.length == 6) { - Navigator.push(context, MaterialPageRoute( - builder: (context) { - return const EnterFullNameScreen(); - }, - )); - } + // if (c.length == 6) { + // Navigator.push(context, MaterialPageRoute( + // builder: (context) { + // return const EnterFullNameScreen(); + // }, + // )); + // } }, width: MediaQuery.of(context).size.width, fieldWidth: 50, @@ -92,15 +92,16 @@ class _OtpScreenState extends State { onCompleted: (pin) async { final success = await pageNotifier.verifiOtp(pin, context); - if (success) { + if (success) + { context.push(MyRoutes.FULLNAME); } else { - // ScaffoldMessenger.of(context).showSnackBar( - // SnackBar( - // backgroundColor: Colors.grey, - // content: Text("Failed to send OTP. Please try again."), - // ), - // ); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: Colors.grey, + content: Text("Failed to send OTP. Please try again."), + ), + ); } }, ), diff --git a/lib/src/ui/splash/splash_screen.dart b/lib/src/ui/splash/splash_screen.dart index 362a681..77d2e1c 100644 --- a/lib/src/ui/splash/splash_screen.dart +++ b/lib/src/ui/splash/splash_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:grocery_app/src/core/routes/routes.dart'; import 'package:grocery_app/src/ui/onboarding/on_boarding_screen.dart'; import 'package:grocery_app/utils/constants/assets_constant.dart'; +import 'package:grocery_app/utils/constants/shared_pref_utils.dart'; import 'package:grocery_app/utils/extensions/extensions.dart'; import 'package:grocery_app/utils/extensions/uicontext.dart'; @@ -25,7 +26,20 @@ class _SplashScreenState extends State { @override void initState() { - // couting(); + Future.delayed(const Duration(seconds: 2), () async { + if (await SharedPrefUtils.isFreshInstall()) { + context.clearAndPush(routePath: MyRoutes.ONBOARDING); + } else + { + print("kdsbfjhdkjfdfghv ${await SharedPrefUtils.getToken()}"); + if (await SharedPrefUtils.getToken() == "1" || + await SharedPrefUtils.getToken() == null) { + // context.clearAndPush(routePath: MyRoutes.SELECTACCOUNT); + } else { + context.clearAndPush(routePath: MyRoutes.BOTTOMNAV); + } + } + }); Future.delayed(const Duration(seconds: 2), () async { context.clearAndPush(routePath: MyRoutes.ONBOARDING);