import 'package:cashier_reserve/common/request/request_manager.dart';
import 'package:cashier_reserve/data_model/reserve/table_area_model.dart';
import 'package:cashier_reserve/data_model/reserve/table_model.dart';

/// ReserveModel 台桌预定相关请求
class ReserveModel {
  /// getShopTableAreaList 获取店铺桌台区域列表
  static Future<List<TableAreaModel?>> getShopTableAreaList() async {
    final r = await RequestManager.get("/api/booking/shop-table/area");
    if (r == null) {
      return [];
    }
    List<TableAreaModel?> list = [];
    for (var item in r as List) {
      list.add(TableAreaModel.fromJson(item));
    }
    return list;
  }

  /// getAreaTableList 获取区域桌台列表
  static Future<List<TableModel?>> getAreaTableList(num areaId, String date, String type) async {
    Map<String, dynamic> paramData = {
      "bookingDate": date,
      "bookingType": type,
    };
    if (areaId > 0) {
      paramData["areaId"] = areaId;
    }
    final r = await RequestManager.get("/api/booking/shop-table/list", params: paramData);
    if (r == null) {
      return [];
    }
    List<TableModel?> list = [];
    for (var item in r as List) {
      list.add(TableModel.fromJson(item));
    }
    return list;
  }
}