Skip to content

Commit

Permalink
auth cart and adress
Browse files Browse the repository at this point in the history
  • Loading branch information
1FarZ1 committed May 1, 2023
1 parent 0be38f0 commit 9a4b5f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions lib/features/adress/controller/adress_controller.dart
Expand Up @@ -7,13 +7,13 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
final addressControllerProvider =
StateNotifierProvider<AddressController, AsyncValue>((ref) {
return AddressController(
adressRepoImpl: ref.watch(adressRepoProvider), ref: ref);
orderRepo: ref.watch(adressRepoProvider), ref: ref);
});

class AddressController extends StateNotifier<AsyncValue> {
AddressController({required this.adressRepoImpl, required this.ref})
AddressController({required this.orderRepo, required this.ref})
: super(const AsyncData(null));
final AddressRepoImpl adressRepoImpl;
final AddressRepo orderRepo;
final StateNotifierProviderRef ref;

void saveUserAddress({required adress}) async {
Expand All @@ -22,7 +22,7 @@ class AddressController extends StateNotifier<AsyncValue> {
await ref.watch(sharedPreferenceProvider)?.then((pref) async {
token = pref.getString("x-auth-token");
});
var res = await adressRepoImpl.saveUserAdress(
var res = await orderRepo.saveUserAdress(
adress: adress ?? "",
token: token ?? "",
);
Expand All @@ -42,7 +42,7 @@ class AddressController extends StateNotifier<AsyncValue> {
token = pref.getString("x-auth-token");
});
var cart = ref.read(userStateProvider).cart;
var res = await adressRepoImpl.placeOrder(
var res = await orderRepo.placeOrder(
adress: adress ?? "", token: token ?? "", amount: amount, cart: cart);

res.fold((l) {
Expand Down
2 changes: 1 addition & 1 deletion lib/features/auth/controller/auth_controller.dart
Expand Up @@ -16,7 +16,7 @@ final authControllerProvider =
class AuthController extends StateNotifier<AsyncValue> {
AuthController({required this.authRepository, required this.ref})
: super(const AsyncData(null));
final AuthRepoImpl authRepository;
final AuthRepo authRepository;
final StateNotifierProviderRef ref;

Future<void> register({
Expand Down
8 changes: 4 additions & 4 deletions lib/features/cart/controller/cart_controller.dart
Expand Up @@ -8,13 +8,13 @@ import '../repo/cart_repo.dart';

final cartControllerProvider =
StateNotifierProvider<CartController, AsyncValue>((ref) {
return CartController(cartRepoImpl: ref.watch(cartRepoProvider), ref: ref);
return CartController(orderRepo: ref.watch(cartRepoProvider), ref: ref);
});

class CartController extends StateNotifier<AsyncValue> {
CartController({required this.cartRepoImpl, required this.ref})
CartController({required this.orderRepo, required this.ref})
: super(const AsyncData(null));
final CartRepoImpl cartRepoImpl;
final CartRepo orderRepo;
final StateNotifierProviderRef ref;

void removeFromCart({required Product product}) async {
Expand All @@ -23,7 +23,7 @@ class CartController extends StateNotifier<AsyncValue> {
await ref.watch(sharedPreferenceProvider)?.then((pref) async {
token = pref.getString("x-auth-token");
});
var res = await cartRepoImpl.removeFromCart(
var res = await orderRepo.removeFromCart(
productId: product.id ?? "",
token: token ?? "",
);
Expand Down

0 comments on commit 9a4b5f4

Please sign in to comment.