import 'package:dio/dio.dart'; import 'package:eatvio_app/features/create_plan/repositories/create_plan_repository.dart'; import 'package:eatvio_app/features/create_plan/services/create_plan_service.dart'; class FixtureCreatePlanRepository extends CreatePlanRepository { FixtureCreatePlanRepository() : super(createPlanService: _NoopCreatePlanService()); final List> createPlanRequests = >[]; @override Future createPlan({required Map model}) async { // Normalize request to match fixture format final normalized = { 'name': model['name'], 'description': model['description_md'], 'duration': model['duration'], 'status': model['state'] == 'active' ? 'active' : 'draft', }; // Extract options if present if (model.containsKey('packets_count')) { final options = >[]; final packetsCount = model['packets_count'] as int; for (int i = 1; i <= packetsCount; i++) { final packetKey = 'packet${i}_options'; if (model.containsKey(packetKey)) { final packet = model[packetKey] as Map; options.add({ 'title': packet['short'], 'price': packet['price'], 'description': packet['description_md'], }); } } if (options.isNotEmpty) { normalized['options'] = options; } } createPlanRequests.add(normalized); } } class _NoopCreatePlanService implements CreatePlanService { @override Future createPlan({required FormData formData}) { throw UnimplementedError('Not used in fixture tests'); } }