Skip to content

Commit

Permalink
[ADD/#80] 구매완료뷰 orderId intent 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchbreeze committed Aug 19, 2024
1 parent b15012a commit ad0e3c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class BuyFinishedActivity :
}

private fun getIntentInfo() {
viewModel.productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty()
viewModel.productId = intent.getStringExtra(EXTRA_ORDER_ID).orEmpty()
}

private fun setIntentUi(item: BuyInfoModel) {
Expand All @@ -65,30 +65,31 @@ class BuyFinishedActivity :
tvFinishedDeliveryName.text = item.addressInfo[0].recipient
tvFinishedDeliveryAddress.text =
getString(
R.string.address_format,
R.string.address_short_format,
item.addressInfo[0].zipCode,
item.addressInfo[0].address,
).breakLines()
tvFinishedDeliveryPhone.text = item.addressInfo[0].recipientPhone
tvFinishedTransactionMethod.text = item.paymentInfo[0].method
tvFinishedTransactionDate.text = item.paymentInfo[0].completedAt
tvFinishedPayMoney.text = item.originPrice.setNumberForm()
tvFinishedPayDiscount.text = getString(R.string.add_minus, item.discountPrice.setNumberForm())
tvFinishedPayDiscount.text =
getString(R.string.add_minus, item.discountPrice.setNumberForm())
tvFinishedPayCharge.text = getString(R.string.add_plus, item.charge.setNumberForm())
tvFinishedPayTotal.text = item.totalPrice.setNumberForm()
}
}

companion object {
private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID"
private const val EXTRA_ORDER_ID = "EXTRA_ORDER_ID"

@JvmStatic
fun createIntent(
context: Context,
productId: String,
orderId: String,
): Intent =
Intent(context, BuyFinishedActivity::class.java).apply {
putExtra(EXTRA_PRODUCT_ID, productId)
putExtra(EXTRA_ORDER_ID, orderId)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import co.orange.core.extension.toast
import co.orange.core.state.UiState
import co.orange.domain.entity.response.AddressInfoModel
import co.orange.domain.entity.response.BuyProgressModel
import co.orange.presentation.buy.finished.BuyFinishedActivity
import co.orange.presentation.buy.progress.BuyProgressViewModel.Companion.PAY_SUCCESS
import co.orange.presentation.setting.delivery.DeliveryActivity
import coil.load
Expand Down Expand Up @@ -46,6 +47,7 @@ class BuyProgressActivity :
observeGetBuyDataState()
observePostPayStartState()
observePatchPayEndState()
observePostOrderState()
}

override fun onResume() {
Expand Down Expand Up @@ -202,7 +204,13 @@ class BuyProgressActivity :
.onEach { state ->
when (state) {
is UiState.Success -> {
// TODO 추후 푸쉬알림뷰 연결
BuyFinishedActivity.createIntent(this, state.data).apply {
startActivity(this)
}
finish()
}

is UiState.Failure -> toast(stringOf(R.string.buy_order_error_msg))
else -> return@onEach
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ class BuyPushActivity : BaseActivity<ActivityPushBinding>(R.layout.activity_push
}

private fun navigateToFinishedActivity() {
val productId = intent.getStringExtra(EXTRA_PRODUCT_ID).orEmpty()
BuyFinishedActivity.createIntent(this, productId).apply {
val orderId = intent.getStringExtra(EXTRA_ORDER_ID).orEmpty()
BuyFinishedActivity.createIntent(this, orderId).apply {
startActivity(this)
}
}

companion object {
private const val EXTRA_PRODUCT_ID = "EXTRA_PRODUCT_ID"
private const val EXTRA_ORDER_ID = "EXTRA_ORDER_ID"

@JvmStatic
fun createIntent(
context: Context,
productId: String,
): Intent =
Intent(context, BuyPushActivity::class.java).apply {
putExtra(EXTRA_PRODUCT_ID, productId)
putExtra(EXTRA_ORDER_ID, productId)
}
}
}

0 comments on commit ad0e3c9

Please sign in to comment.