Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ data class ConsumerMatchingRequestSummary(
val resort: ConsumerMatchingResort,
val sport: String,
val lessonLevel: String,
val requesterName: String,
val headcount: Int,
val participants: List<ConsumerMatchingSummaryParticipant>,
)

data class ConsumerMatchingSummaryParticipant(
val name: String?,
val age: Int,
val gender: String,
)

data class ConsumerMatchingResort(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ internal data class ConsumerMatchingActiveResponse(
@SerialName("resort") val resort: Resort,
@SerialName("sport") val sport: String,
@SerialName("lessonLevel") val lessonLevel: String,
@SerialName("requesterName") val requesterName: String,
@SerialName("headcount") val headcount: Int,
@SerialName("participants") val participants: List<Participant> = emptyList(),
)

@Serializable
internal data class Participant(
@SerialName("name") val name: String? = null,
@SerialName("age") val age: Int,
@SerialName("gender") val gender: String,
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.ssing.data.matching.consumermatching.model.ConsumerMatchingProgressSu
import com.ssing.data.matching.consumermatching.model.ConsumerMatchingRequestResult
import com.ssing.data.matching.consumermatching.model.ConsumerMatchingRequestSummary
import com.ssing.data.matching.consumermatching.model.ConsumerMatchingResort
import com.ssing.data.matching.consumermatching.model.ConsumerMatchingSummaryParticipant
import com.ssing.data.matching.consumermatching.remote.datasource.api.ConsumerMatchingRemoteDataSource
import com.ssing.data.matching.consumermatching.remote.dto.request.ConsumerMatchingConditionRequest
import com.ssing.data.matching.consumermatching.remote.dto.request.ConsumerMatchingConfirmationRequest
Expand Down Expand Up @@ -130,7 +131,15 @@ internal class ConsumerMatchingRepositoryImpl @Inject constructor(
),
sport = requestSummary.sport,
lessonLevel = requestSummary.lessonLevel,
requesterName = requestSummary.requesterName,
headcount = requestSummary.headcount,
participants = requestSummary.participants.map {
ConsumerMatchingSummaryParticipant(
name = it.name,
age = it.age,
gender = it.gender,
)
},
),
lessonSummary = lessonSummary?.let {
ConsumerMatchingLessonSummary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,30 +77,33 @@ internal class ConsumerHomeViewModel @Inject constructor(
}.toImmutableList()
}

private fun ConsumerLessonCard.toReservation(): Reservation =
Reservation(
private fun ConsumerLessonCard.toReservation(): Reservation {
val status = toCardStatus()
return Reservation(
lessonId = lessonId,
chip = toChipText(),
chip = toChipText(status),
displayText = title,
location = resort.displayName,
date = runCatching { OffsetDateTime.parse(scheduledAt).toLocalDateTime() }.getOrNull(),
imageRes = toImageRes(),
status = toCardStatus(),
status = status,
)
}
Comment thread
doyeon0307 marked this conversation as resolved.

private fun ConsumerLessonCard.toImageRes(): Int = when (sport) {
"SKI" -> R.drawable.img_ski_86
"SNOWBOARD" -> R.drawable.img_snowboard_86
else -> R.drawable.img_ski_86
}

private fun ConsumerLessonCard.toChipText(): String = when {
displayStatus == IN_PROGRESS -> "진행중"
remainingDays == 0 -> "Now"
else -> "D-$remainingDays"
}
private fun ConsumerLessonCard.toChipText(status: Status): String =
if (status == Status.Default) "D-$remainingDays" else "Now"

private fun ConsumerLessonCard.toCardStatus(): Status = Status.Default
private fun ConsumerLessonCard.toCardStatus(): Status = when {
displayStatus == IN_PROGRESS -> Status.Matching
remainingDays == 0 -> Status.Matched
else -> Status.Default
}

private companion object {
const val IN_PROGRESS = "IN_PROGRESS"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,9 @@ private fun ReviewCard(
overflow = TextOverflow.Ellipsis,
)

Spacer(
Modifier
.weight(1f)
.heightIn(min = 11.dp),
)
Spacer(Modifier.height(11.dp))

Spacer(Modifier.weight(1f))

Text(
text = review.date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ private fun PayInfoSection(
) {
SsingMatchingDetailCard(
nickname = state.nickname,
teamCount = state.participants.size,
stepLabel = "결제 정보",
stepLabelColor = SSINGTheme.colors.textAlternative,
tags = state.tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ package com.ssing.presentation.consumerpayment
import androidx.lifecycle.viewModelScope
import com.ssing.core.network.exception.ApiException
import com.ssing.core.ui.base.BaseViewModel
import com.ssing.core.ui.common.component.Gender
import com.ssing.core.ui.common.component.Participant
import com.ssing.core.ui.extension.uiMessage
import com.ssing.data.matching.consumermatching.model.ConsumerMatchingActive
import com.ssing.data.matching.consumermatching.model.ConsumerMatchingSummaryParticipant
import com.ssing.data.matching.consumermatching.repository.api.ConsumerMatchingRepository
import com.ssing.data.payment.model.PaymentSummary
import com.ssing.data.payment.repository.api.PaymentRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
import kotlinx.coroutines.launch
import timber.log.Timber
import javax.inject.Inject
Expand Down Expand Up @@ -42,15 +46,19 @@ internal class PaymentViewModel @Inject constructor(

updateState {
copy(
nickname = requestSummary.requesterName,
tags = persistentListOf(
requestSummary.sport.toSport(),
requestSummary.lessonLevel.toLessonLevel()
),
location = requestSummary.resort.displayName,
duration = lessonSummary?.durationMinutes?.toDurationText() ?: duration,
participants = requestSummary.participants.map { it.toParticipant() }
.toPersistentList(),
lessonCost = priceSummary?.lessonPriceAmount ?: lessonCost,
resortCost = priceSummary?.resortPassFeeAmount ?: resortCost,
totalPaymentAmount = priceSummary?.totalPaymentAmount ?: totalPaymentAmount,
equipmentStatus = "착용 완료",
)
}
}
Expand Down Expand Up @@ -80,6 +88,15 @@ internal class PaymentViewModel @Inject constructor(
else -> "${this / 60}시간 ${this % 60}분"
}

private fun ConsumerMatchingSummaryParticipant.toParticipant(): Participant =
Participant(age = age, gender = gender.toGender())

private fun String.toGender(): Gender = when (this) {
"MALE" -> Gender.MALE
"FEMALE" -> Gender.FEMALE
else -> Gender.MALE
}

fun onPaymentClick() {
if (uiState.value.isLoading) return
val matchingRequestId = matchingRequestId ?: run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,28 @@ internal class InstructorHomeViewModel @Inject constructor(
}.toImmutableList()
}

private fun InstructorLessonCard.toReservation(): Reservation =
Reservation(
private fun InstructorLessonCard.toReservation(): Reservation {
val status = toReservationStatus()
return Reservation(
lessonId = lessonId,
offerId = offerId,
chip = toChipText(),
chip = toChipText(status),
displayText = title,
location = resort.displayName,
date = runCatching { OffsetDateTime.parse(scheduledAt).toLocalDateTime() }.getOrNull(),
imageRes = toImageRes(),
status = toReservationStatus(),
status = status,
)
}

private fun InstructorLessonCard.toImageRes(): Int = when (sport) {
"SKI" -> R.drawable.img_ski_86
"SNOWBOARD" -> R.drawable.img_snowboard_86
else -> R.drawable.img_ski_86
}

private fun InstructorLessonCard.toChipText(): String = when {
displayStatus == IN_PROGRESS -> "진행중"
remainingDays == 0 -> "Now"
else -> "D-$remainingDays"
}
private fun InstructorLessonCard.toChipText(status: Status): String =
if (status == Status.Default) "D-$remainingDays" else "Now"

private fun InstructorLessonCard.toReservationStatus(): Status =
when (displayStatus) {
Expand All @@ -111,8 +110,10 @@ internal class InstructorHomeViewModel @Inject constructor(
WAITING_FOR_INSTRUCTOR,
WAITING_FOR_CONFIRMATION,
PAYMENT_PENDING -> Status.Matched
CONFIRMED,
IN_PROGRESS -> Status.Default

IN_PROGRESS -> Status.Matching

CONFIRMED -> Status.Default

else -> Status.Default
}
Expand Down
Loading