import 'package:flutter/material.dart';
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
import 'package:rasadyar_auth/data/services/token_storage_service.dart';
import 'package:rasadyar_core/core.dart';

import '../../presentation/routes/pages.dart';

class AuthMiddleware extends GetMiddleware {
  var tokenService = Get.find<TokenStorageService>();

  @override
  RouteSettings? redirect(String? route) {
    final refreshToken = tokenService.refreshToken.value;
    final accessToken = tokenService.accessToken.value;

    if (refreshToken == null || accessToken == null) {
      return RouteSettings(name: AuthPaths.auth, arguments: Module.chicken);
    }
    return super.redirect(route);
  }
}
