import 'package:injectable/injectable.dart';
import 'package:shared_preferences/shared_preferences.dart';

import '../../../common/constant/local_storage_key.dart';

@injectable
class OutletLocalDataProvider {
  final SharedPreferences _sharedPreferences;

  OutletLocalDataProvider(this._sharedPreferences);

  Future<void> saveSelectedOutletId(String outletId) async {
    await _sharedPreferences.setString(
      LocalStorageKey.selectedOutletId,
      outletId,
    );
  }

  Future<void> saveSelectedOutletName(String outletName) async {
    await _sharedPreferences.setString(
      LocalStorageKey.selectedOutletName,
      outletName,
    );
  }

  String? getSelectedOutletId() {
    return _sharedPreferences.getString(LocalStorageKey.selectedOutletId);
  }

  String? getSelectedOutletName() {
    return _sharedPreferences.getString(LocalStorageKey.selectedOutletName);
  }

  Future<void> deleteSelectedOutletId() async {
    await _sharedPreferences.remove(LocalStorageKey.selectedOutletId);
    await _sharedPreferences.remove(LocalStorageKey.selectedOutletName);
  }
}
