Skip to content

Commit

Permalink
feat : [선물하기] 결제 실패 시 팝업 띄우기
Browse files Browse the repository at this point in the history
  • Loading branch information
HamBP committed Jun 24, 2024
1 parent 63626ed commit c482abf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import com.nexters.boolti.presentation.component.MainButton
import com.nexters.boolti.presentation.screen.ticketing.Header
import com.nexters.boolti.presentation.screen.ticketing.InputRow
import com.nexters.boolti.presentation.screen.ticketing.OrderAgreementSection
import com.nexters.boolti.presentation.screen.ticketing.PaymentFailureDialog
import com.nexters.boolti.presentation.screen.ticketing.RefundPolicySection
import com.nexters.boolti.presentation.screen.ticketing.Section
import com.nexters.boolti.presentation.screen.ticketing.TicketInfoSection
Expand All @@ -83,7 +84,9 @@ fun GiftScreen(
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
val uriHandler = LocalUriHandler.current
val context = LocalContext.current
var showDialog by remember { mutableStateOf(false) }
var showConfirmDialog by remember { mutableStateOf(false) }
var showTicketSoldOutDialog by remember { mutableStateOf(false) }
var showPaymentFailureDialog by remember { mutableStateOf(false) }

val paymentLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
Expand All @@ -99,8 +102,8 @@ fun GiftScreen(
navigateToComplete(reservationId, giftId)
}

RESULT_SOLD_OUT -> TODO("품절 다이얼로그")
RESULT_FAIL -> TODO("실패 다이얼로그")
RESULT_SOLD_OUT -> showTicketSoldOutDialog = true
RESULT_FAIL -> showPaymentFailureDialog = true
}
}

Expand Down Expand Up @@ -132,10 +135,13 @@ fun GiftScreen(
imageId = uiState.selectedImage,
)
)
showDialog = false
showConfirmDialog = false
}

GiftEvent.NoRemainingQuantity -> {}
GiftEvent.NoRemainingQuantity -> {
showConfirmDialog = false
showTicketSoldOutDialog = true
}
}
}
}
Expand Down Expand Up @@ -269,14 +275,14 @@ fun GiftScreen(
uiState.totalPrice
),
onClick = {
showDialog = true
showConfirmDialog = true
},
)
}
}
}

if (showDialog) {
if (showConfirmDialog) {
GiftConfirmDialog(
receiverName = uiState.receiverName,
receiverContact = uiState.receiverContact,
Expand All @@ -286,9 +292,20 @@ fun GiftScreen(
ticketCount = uiState.ticketCount,
totalPrice = uiState.totalPrice,
onClick = viewModel::pay,
onDismiss = { showDialog = false },
onDismiss = { showConfirmDialog = false },
)
}
if (showPaymentFailureDialog) {
PaymentFailureDialog {
showPaymentFailureDialog = false
}
}
if (showTicketSoldOutDialog) {
PaymentFailureDialog {
showTicketSoldOutDialog = false
popBackStack()
}
}
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ class GiftViewModel @Inject constructor(
}

fun pay() {
// TODO : 무료 케이스 처리

ticketingRepository.requestOrderId(OrderIdRequest(showId, salesTicketTypeId, ticketCount))
.onStart { _uiState.update { it.copy(loading = true) } }
.onEach { orderId ->
Expand Down

0 comments on commit c482abf

Please sign in to comment.