import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:supplier_new/common/settings.dart';

class AuthManager {

  static final FlutterSecureStorage storage = FlutterSecureStorage(
    aOptions: AndroidOptions(
      resetOnError: true,
      encryptedSharedPreferences: true,
    ),
  );

  static Future<String> decideStartScreen() async {

    String? token = await storage.read(key: 'authToken');

    if(token == null){
      return "login";
    }

    await AppSettings.loadDataFromMemory();

    String? onboarding = await storage.read(key: 'onboardingCompleted');

    if(onboarding == null){
      await storage.write(
        key: 'onboardingCompleted',
        value: 'true',
      );

      return "resources";
    }

    return "dashboard";
  }

}