import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:shared/utils/log_utils.dart';

import '../../../respository/common_garage.dart';

part 'my_posts_sale_rent_item_vm.g.dart';

@riverpod
class MyPostsSaleRentItemVm extends _$MyPostsSaleRentItemVm {
  late CommonGarageRespository commonGarageRespositoryInstance;
  @override
  build(){
    // 引入数据仓库
    commonGarageRespositoryInstance = ref.read(commonGarageRespositoryProvider);
    final state = {};
    Log.d("--------------------------build---------------------");

    return state;
  }

  Future<bool> handlerGarageClickLike(int garageId, bool isLike) async{
    // 调用 fetchGarageColleciton
    try{
      Map<String, dynamic> params = {
        "id": garageId,
      };
      final result = await commonGarageRespositoryInstance.fetchGarageColleciton(params);
      if(result.isSuccess){
        return true;
      }else {
        return false;
      }
    }catch(error){
      return false;
    }
  }
}