import 'dart:io'; /// This class holds all the data collected across the multi-step tarball sampling form. /// It acts as a temporary data container that is passed between screens. class TarballSamplingData { // --- Step 1 Data: Collected in TarballSamplingStep1 --- String? firstSampler; int? firstSamplerUserId; Map? secondSampler; // Holds the full user map for the 2nd sampler String? samplingDate; String? samplingTime; String? selectedStateName; String? selectedCategoryName; Map? selectedStation; // Holds the full station map String? stationLatitude; String? stationLongitude; String? currentLatitude; String? currentLongitude; double? distanceDifference; // --- Step 2 Data: Collected in TarballSamplingStep2 --- int? classificationId; // CORRECTED: Only the ID is needed. File? leftCoastalViewImage; File? rightCoastalViewImage; File? verticalLinesImage; File? horizontalLineImage; File? optionalImage1; String? optionalRemark1; File? optionalImage2; String? optionalRemark2; File? optionalImage3; String? optionalRemark3; File? optionalImage4; String? optionalRemark4; // --- Step 3 Data: For handling the submission response --- String? reportId; String? submissionStatus; String? submissionMessage; /// Converts the form's text and selection data into a Map suitable for JSON encoding. /// This map will be sent as the body of the first API request. Map toFormData() { final Map data = { // Required fields 'station_id': selectedStation?['station_id']?.toString() ?? '', 'sampling_date': samplingDate ?? '', 'sampling_time': samplingTime ?? '', // User ID fields 'first_sampler_user_id': firstSamplerUserId?.toString() ?? '', 'second_sampler_user_id': secondSampler?['user_id']?.toString() ?? '', // Foreign Key ID for classification 'classification_id': classificationId?.toString() ?? '', // Other nullable fields 'current_latitude': currentLatitude ?? '', 'current_longitude': currentLongitude ?? '', 'distance_difference': distanceDifference?.toString() ?? '', 'optional_photo_remark_01': optionalRemark1 ?? '', 'optional_photo_remark_02': optionalRemark2 ?? '', 'optional_photo_remark_03': optionalRemark3 ?? '', 'optional_photo_remark_04': optionalRemark4 ?? '', }; return data; } /// Gathers all non-null image files into a Map. /// This map is used to build the multipart request for the second API call (image upload). Map toImageFiles() { return { 'left_side_coastal_view': leftCoastalViewImage, 'right_side_coastal_view': rightCoastalViewImage, 'drawing_vertical_lines': verticalLinesImage, 'drawing_horizontal_line': horizontalLineImage, 'optional_photo_01': optionalImage1, 'optional_photo_02': optionalImage2, 'optional_photo_03': optionalImage3, 'optional_photo_04': optionalImage4, }; } }