import 'package:hmg_patient_app/config/shared_pref_kay.dart';
import 'package:hmg_patient_app/models/Authentication/authenticated_user.dart';
import 'package:hmg_patient_app/uitl/app_shared_preferences.dart';

class AuthenticatedUserObject {
  AuthenticatedUser user = AuthenticatedUser();
  AppSharedPreferences sharedPref = AppSharedPreferences();
  bool isLogin = false;

  AuthenticatedUserObject() {
    getUser();
  }

  Future<void> getUser({bool getUser = false}) async {
    if (getUser) {
      var userData = await sharedPref.getObject(USER_PROFILE);
      if (userData != null) {
        user = AuthenticatedUser.fromJson(userData);
      }
    } else if (user == null) {
      var userData = await sharedPref.getObject(USER_PROFILE);
      if (userData != null) {
        // user = AuthenticatedUser.fromJson(userData);
        user = AuthenticatedUser(
          patientID: 1,
        );
      }
    }
  }

  void logout() {
    isLogin = false;
  }
}
