import 'package:shared_preferences/shared_preferences.dart';
import '../../../Helper/Constants/Apiconstants.dart';
import '../../../Model/Request/User/Updateuser/Updateuserrequest.dart';
import '../../../Model/Response/User/Updateuser/Updateuserresponse.dart';
import '../../../Model/Response/User/Usermodelresponse.dart';
import '../../Provider/Users/user_provider.dart';


class UserRepository {
  UserProvider userProvider = UserProvider();
  int? userId;
  int? locationId;

  Future<UserModelResponse?> getUser(token) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();
    userId = prefs.getInt('userId');
    locationId = prefs.getInt('locationId')??0;

    return await userProvider.getUser('${ApiConstants.user}/getusers?userid=$userId&locationid=$locationId',token);
  }

  Future<UserUpdateResponse?> updateUser(UserUpdateRequest data) async {
    SharedPreferences prefs = await SharedPreferences.getInstance();

    userId = prefs.getInt('userId');

    return await userProvider.updateUser(data,ApiConstants.userUpdate,);
  }


}