diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt index 76189c2b66c..db60e627df1 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/WooShippingLabelCreationViewModel.kt @@ -26,6 +26,7 @@ import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.onStart import kotlinx.coroutines.launch import javax.inject.Inject +import kotlinx.coroutines.flow.update @HiltViewModel class WooShippingLabelCreationViewModel @Inject constructor( @@ -191,7 +192,15 @@ class WooShippingLabelCreationViewModel @Inject constructor( } fun onPackageSelected(packageData: PackageData) { - + selectedPackage.update { content -> + when (content) { + is NotAvailable -> PackageSelectionState.Data( + selectedPackage = packageData, + totalWeight = packageData.weight + ) + is PackageSelectionState.Data -> content.copy(selectedPackage = packageData) + } + } } data object StartPackageSelection : Event() diff --git a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/packages/WooShippingLabelPackageCreationFragment.kt b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/packages/WooShippingLabelPackageCreationFragment.kt index 6e3751ea82f..fcdffb3796d 100644 --- a/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/packages/WooShippingLabelPackageCreationFragment.kt +++ b/WooCommerce/src/main/kotlin/com/woocommerce/android/ui/orders/wooshippinglabels/packages/WooShippingLabelPackageCreationFragment.kt @@ -17,7 +17,6 @@ import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground import com.woocommerce.android.ui.orders.wooshippinglabels.packages.WooShippingLabelPackageCreationViewModel.PackageSelected import com.woocommerce.android.ui.orders.wooshippinglabels.packages.WooShippingLabelPackageCreationViewModel.PackageType import com.woocommerce.android.ui.orders.wooshippinglabels.packages.WooShippingLabelPackageCreationViewModel.ShowPackageTypeDialog -import com.woocommerce.android.ui.orders.wooshippinglabels.packages.ui.PackageData import dagger.hilt.android.AndroidEntryPoint @AndroidEntryPoint