
import 'package:fluro/fluro.dart';
import 'package:liftmanager/internal/team/page/team_auth_page.dart';
import 'package:liftmanager/internal/team/page/team_auth_upload_page.dart';
import 'package:liftmanager/internal/team/page/team_card_page.dart';
import 'package:liftmanager/internal/team/page/team_create_page.dart';
import 'package:liftmanager/internal/team/page/team_detail_page.dart';
import 'package:liftmanager/internal/team/page/team_list_page.dart';
import 'package:liftmanager/internal/team/page/team_search_page.dart';
import 'package:liftmanager/internal/team/page/team_user_detail_page.dart';
import 'package:liftmanager/internal/team/page/team_user_page.dart';
import 'package:liftmanager/routers/router_init.dart';

class TeamRouter implements IRouterProvider{

  static String teamListPage = "/team/list";
  static String teamSearchPage = "/team/search";
  static String teamCreatePage = "/team/create";
  static String teamDetailPage = "/team/detail";
  static String teamCardPage = "/team/card";
  static String teamAuthPage = "/team/auth";
  static String teamAuthUploadPage = "/team/auth/upload";
  static String teamUserPage = "/team/user";
  static String teamUserDetailPage = "/team/user/detail";

  @override
  void initRouter(Router router) {
    router.define(teamListPage, handler: Handler(handlerFunc: (_, params) => TeamListPage()));
    router.define(teamSearchPage, handler: Handler(handlerFunc: (_, params) => TeamSearchPage()));
    router.define(teamCreatePage, handler: Handler(handlerFunc: (_, params) => TeamCreatePage()));
    router.define(teamDetailPage, handler: Handler(handlerFunc: (_, params){
      String id = params['id']?.first;
      String name = params['name']?.first;
      String logoImg = params['logoImg']?.first;
      String corporator = params['corporator']?.first;
      String telephone = params['telephone']?.first;
      String userNum = params['userNum']?.first;
      String createDate = params['createDate']?.first;
      String remarks = params['remarks']?.first;
      String isCertificated = params['isCertificated']?.first;
      return TeamDetailPage(id,name,logoImg,corporator,telephone,int.parse(userNum),createDate,remarks,int.parse(isCertificated));
    }));
    router.define(teamCardPage, handler: Handler(handlerFunc: (_,params)=>TeamCardPage()));
    router.define(teamAuthPage, handler: Handler(handlerFunc: (_,params)=>TeamAuthPage()));
    router.define(teamAuthUploadPage, handler: Handler(handlerFunc: (_,params)=>TeamAuthUploadPage()));
    router.define(teamUserPage, handler: Handler(handlerFunc: (_,params)=>TeamUserPage()));
    router.define(teamUserDetailPage, handler: Handler(handlerFunc: (_,params){
      String name = params['name']?.first;
      String remark = params['remark']?.first;
      String role = params['role']?.first;
      String logoImg = params['logoImg']?.first;
      String isCertificated = params['isCertificated']?.first;
      String certificateType = params['certificateType']?.first;
      String expirationDate = params['expirationDate']?.first;
      String issuanceAgency = params['issuanceAgency']?.first;
      return TeamUserDetailPage(name,remark,role,logoImg,isCertificated,certificateType,expirationDate,issuanceAgency);
    }));
  }
}