import 'package:flutter/material.dart';
import 'package:rasadyar_auth/data/models/local/user_local/user_local_model.dart';
import 'package:rasadyar_auth/presentation/routes/pages.dart';
import 'package:rasadyar_core/core.dart';

void handleGeneric(DioException error,[void Function()? onError]) {
  Get.showSnackbar(_errorSnackBar('اعتبار توکن شما منقضی شده است لطفا دوباره وارد شوید'));

  Get.offAllNamed(AuthPaths.auth, arguments: Module.chicken);
}

GetSnackBar _errorSnackBar(String message) {
  return GetSnackBar(
    titleText: Text('خطا', style: AppFonts.yekan14.copyWith(color: Colors.white)),
    messageText: Text(message, style: AppFonts.yekan12.copyWith(color: Colors.white)),
    backgroundColor: AppColor.error,
    margin: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
    borderRadius: 12,
    duration: Duration(milliseconds: 3500),
    snackPosition: SnackPosition.TOP,
  );
}