Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
πŸ”€ :: (#141) 병원 μ§„λ£Œ μ˜ˆμ•½ μ½”λ“œ λ¦¬νŒ©ν† λ§
Browse files Browse the repository at this point in the history
πŸ”€ :: (#141) 병원 μ§„λ£Œ μ˜ˆμ•½ μ½”λ“œ λ¦¬νŒ©ν† λ§
  • Loading branch information
Tmdhoon2 authored Dec 4, 2023
2 parents 319f05f + d985e19 commit 1b1e025
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ internal fun Reservation(
}
}

LaunchedEffect(Unit) {
reservationViewModel.fetchDayReservations()
}

LaunchedEffect("$yearState-$monthState-$dayState") {
reservationViewModel.setDate("$yearState-$monthState-$dayState")
reservationViewModel.fetchDayReservations()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.signal.signal_android.feature.reservation

import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.snapshots.SnapshotStateList
import com.signal.domain.entity.FetchDayReservationsEntity
import com.signal.domain.entity.FetchHospitalsEntity
import com.signal.domain.entity.FetchReservationDetailsEntity
Expand All @@ -9,14 +11,13 @@ import java.time.LocalTime
import java.util.UUID

data class ReservationState(
val dayReservationEntity: List<FetchDayReservationsEntity.DayReservationEntity>,
val dayReservationEntity: SnapshotStateList<FetchDayReservationsEntity.DayReservationEntity>,
val hospitals: List<FetchHospitalsEntity.HospitalEntity>,
val reservationDetailsEntity: FetchReservationDetailsEntity,
val isDayReservationsEmpty: Boolean,
val isHospitalsEmpty: Boolean,
val date: String,
val reason: String,
val reservationDate: String,
val reservationTime: String,
val time: String,
val reservationStatus: ReservationStatus,
Expand All @@ -25,7 +26,7 @@ data class ReservationState(
) {
companion object {
fun getDefaultState() = ReservationState(
dayReservationEntity = listOf(),
dayReservationEntity = mutableStateListOf(),
hospitals = listOf(),
reservationDetailsEntity = FetchReservationDetailsEntity(
image = null,
Expand All @@ -40,7 +41,6 @@ data class ReservationState(
isHospitalsEmpty = true,
date = LocalDate.now().toString(),
reason = "",
reservationDate = LocalDate.now().toString(),
reservationTime = LocalTime.now().toString(),
time = "${LocalTime.now().hour}:${LocalTime.now().minute}",
reservationStatus = ReservationStatus.WAIT,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.signal.signal_android.feature.reservation

import androidx.compose.runtime.toMutableStateList
import androidx.lifecycle.viewModelScope
import com.signal.domain.entity.FetchDayReservationsEntity
import com.signal.domain.entity.FetchHospitalsEntity
Expand Down Expand Up @@ -27,7 +28,7 @@ class ReservationViewModel(
_dayReservations.addAll(it.reservations)
setState(
copy(
dayReservationEntity = _dayReservations,
dayReservationEntity = _dayReservations.toMutableStateList(),
isDayReservationsEmpty = _dayReservations.isEmpty(),
)
)
Expand Down Expand Up @@ -66,7 +67,7 @@ class ReservationViewModel(
reservationRepository.createReservation(
hospitalId = hospitalId,
reason = reason,
date = reservationDate,
date = date,
time = reservationTime,
)
}.onSuccess {
Expand Down

0 comments on commit 1b1e025

Please sign in to comment.