Skip to content

Commit

Permalink
✨ 参加表明処理の実装を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsutakein committed Dec 5, 2023
1 parent 49e8497 commit ba3e831
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public struct ComposeScheduleDetailScreen: UIViewControllerRepresentable {
id: scheduleId,
fetchParticipantScheduleById: Container.shared.get(
type: FetchParticipantScheduleByIdUseCase.self),
participate: Container.shared.get(type: ParticipateUseCase.self),
userMessageStateHolder: Container.shared.get(type: UserMessageStateHolder.self),
dateTimeFormatter: Container.shared.get(type: CommonNitoDateFormatter.self)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import kotlinx.serialization.Serializable

@Serializable
internal data class NetworkParticipantDeclaration(
val scheduleId: Long,
val memberId: Long,
val scheduleId: String,
val userId: String,
val comment: String,
)

internal fun ParticipantDeclaration.toNetworkModel(): NetworkParticipantDeclaration =
NetworkParticipantDeclaration(
scheduleId = scheduleId.toLong(),
memberId = memberId.toLong(),
scheduleId = scheduleId,
userId = memberId,
comment = comment,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package club.nito.feature.schedule.detail

import club.nito.core.common.NitoDateFormatter
import club.nito.core.domain.FetchParticipantScheduleByIdUseCase
import club.nito.core.domain.ParticipateUseCase
import club.nito.core.domain.model.ParticipantSchedule
import club.nito.core.model.FetchSingleContentResult
import club.nito.core.model.schedule.ScheduleId
Expand All @@ -18,6 +19,7 @@ import moe.tlaster.precompose.viewmodel.viewModelScope
public class ScheduleDetailStateMachine(
id: ScheduleId,
fetchParticipantScheduleById: FetchParticipantScheduleByIdUseCase,
private val participate: ParticipateUseCase,
public val userMessageStateHolder: UserMessageStateHolder,
private val dateTimeFormatter: NitoDateFormatter,
) : StateMachine(),
Expand Down Expand Up @@ -52,7 +54,9 @@ public class ScheduleDetailStateMachine(
viewModelScope.launch {
when (intent) {
is ScheduleDetailIntent.ClickParticipate -> {
showConfirmParticipateSchedule.emit(intent.schedule)
participate(intent.schedule.id, "")
val scheduledAt = dateTimeFormatter.formatDateTime(intent.schedule.scheduledAt)
userMessageStateHolder.showMessage("$scheduledAt に参加登録しました 🎉")
}

is ScheduleDetailIntent.ClickParticipateSchedule -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public val scheduleFeatureModule: Module = module {
ScheduleDetailStateMachine(
id = id,
fetchParticipantScheduleById = get(),
participate = get(),
userMessageStateHolder = get(),
dateTimeFormatter = get(),
)
Expand Down

0 comments on commit ba3e831

Please sign in to comment.