Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] [#229] 웨이팅 탭 api들 연결 #230

Merged
merged 16 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import com.unifest.android.core.data.repository.OnboardingRepository
import com.unifest.android.core.data.repository.OnboardingRepositoryImpl
import com.unifest.android.core.data.repository.RemoteConfigRepository
import com.unifest.android.core.data.repository.RemoteConfigRepositoryImpl
import com.unifest.android.core.data.repository.WaitingRepository
import com.unifest.android.core.data.repository.WaitingRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down Expand Up @@ -44,4 +46,8 @@ internal abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindRemoteConfigRepository(remoteConfigRepositoryImpl: RemoteConfigRepositoryImpl): RemoteConfigRepository

@Binds
@Singleton
abstract fun bingWaitingRepository(waitingRepositoryImpl: WaitingRepositoryImpl): WaitingRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.unifest.android.core.data.mapper

import com.unifest.android.core.model.MyWaitingModel
import com.unifest.android.core.network.response.MyWaiting

internal fun MyWaiting.toModel(): MyWaitingModel {
return MyWaitingModel(
boothId = boothId,
waitingId = waitingId,
partySize = partySize,
tel = tel,
deviceId = deviceId,
createdAt = createdAt,
updatedAt = updatedAt,
status = status,
waitingOrder = waitingOrder,
boothName = boothName,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.unifest.android.core.data.repository

import com.unifest.android.core.model.MyWaitingModel

interface WaitingRepository {
suspend fun getMyWaitingList(): Result<List<MyWaitingModel>>
suspend fun cancelBoothWaiting(waitingId: Long): Result<Unit>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.unifest.android.core.data.repository

import android.content.Context
import com.unifest.android.core.common.getDeviceId
import com.unifest.android.core.data.mapper.toModel
import com.unifest.android.core.data.util.runSuspendCatching
import com.unifest.android.core.network.request.WaitingRequest
import com.unifest.android.core.network.service.UnifestService
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject

class WaitingRepositoryImpl @Inject constructor(
@ApplicationContext private val context: Context,
private val service: UnifestService,
) : WaitingRepository {
override suspend fun getMyWaitingList() = runSuspendCatching {
service.getMyWaitingList(
deviceId = getDeviceId(context),
).data?.map { it.toModel() } ?: emptyList()
}

override suspend fun cancelBoothWaiting(waitingId: Long): Result<Unit> = runSuspendCatching {
service.cancelBoothWaiting(
WaitingRequest(
waitingId = waitingId,
deviceId = getDeviceId(context),
),
).data.toModel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
Expand All @@ -19,6 +20,7 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicTextField
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.Remove
Expand All @@ -36,6 +38,7 @@ import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.unit.dp
Expand All @@ -49,6 +52,8 @@ import com.unifest.android.core.designsystem.theme.BoothTitle2
import com.unifest.android.core.designsystem.theme.BoothTitle3
import com.unifest.android.core.designsystem.theme.Content2
import com.unifest.android.core.designsystem.theme.Content6
import com.unifest.android.core.designsystem.theme.DarkGrey400
import com.unifest.android.core.designsystem.theme.LightGrey200
import com.unifest.android.core.designsystem.theme.Title1
import com.unifest.android.core.designsystem.theme.Title2
import com.unifest.android.core.designsystem.theme.Title3
Expand Down Expand Up @@ -140,7 +145,7 @@ fun UnifestDialog(
.weight(1f)
.height(45.dp)
.padding(start = 4.dp),
containerColor = MaterialTheme.colorScheme.onTertiaryContainer,
containerColor = if (isSystemInDarkTheme()) DarkGrey400 else LightGrey200,
) {
Text(
text = stringResource(id = cancelTextResId),
Expand Down Expand Up @@ -236,6 +241,9 @@ fun WaitingPinDialog(
color = MaterialTheme.colorScheme.onBackground,
),
cursorBrush = SolidColor(MaterialTheme.colorScheme.onBackground),
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number,
),
decorationBox = { innerTextField ->
if (pinNumber.isEmpty()) {
Text(
Expand Down Expand Up @@ -402,6 +410,9 @@ fun WaitingDialog(
color = MaterialTheme.colorScheme.onBackground,
),
cursorBrush = SolidColor(MaterialTheme.colorScheme.onBackground),
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Number,
),
decorationBox = { innerTextField ->
if (phoneNumber.isEmpty()) {
Text(
Expand Down Expand Up @@ -676,6 +687,26 @@ fun AppUpdateDialog(
}
}

@Composable
fun WaitingCancelDialog(
onCancelClick: () -> Unit,
onConfirmClick: () -> Unit,
) {
UnifestTheme {
UnifestDialog(
onDismissRequest = {},
titleResId = R.string.waiting_cancel_dialog_title,
iconResId = R.drawable.ic_caution,
iconDescription = "Caution Icon",
descriptionResId = R.string.waiting_cancel_dialog_description,
confirmTextResId = R.string.confirm,
cancelTextResId = R.string.cancel,
onCancelClick = onCancelClick,
onConfirmClick = onConfirmClick,
)
}
}

@ComponentPreview
@Composable
fun ServerErrorDialogPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,15 @@ val WaitingNumber3 = TextStyle(
fontWeight = FontWeight.Bold,
fontSize = 15.sp,
)

val WaitingNumber4 = TextStyle(
fontFamily = pretendardFamily,
fontWeight = FontWeight.Bold,
fontSize = 18.sp,
)

val WaitingNumber5 = TextStyle(
fontFamily = pretendardFamily,
fontWeight = FontWeight.SemiBold,
fontSize = 30.sp,
)
5 changes: 5 additions & 0 deletions core/designsystem/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
<string name="waiting_cancel_waiting">웨이팅 취소</string>
<string name="waiting_booth_check">부스 확인하기</string>
<string name="waiting_nth">번째</string>
<string name="waiting_cancel_dialog_title">웨이팅을 취소합니다</string>
<string name="waiting_cancel_dialog_description">정말 취소 하시겠습니까?</string>
<string name="waiting_no_waiting">신청한 웨이팅이 없어요</string>
<string name="waiting_no_waiting_description">주점/부스 구경하러 가기></string>
<string name="waiting_my_turn">입장해주세요</string>

<!-- Menu -->
<string name="menu_title">메뉴</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.unifest.android.core.model

import androidx.compose.runtime.Stable

@Stable
data class MyWaitingModel(
val boothId: Long = 0L,
val waitingId: Long = 0L,
val partySize: Long = 0L,
val tel: String = "",
val deviceId: String = "",
val createdAt: String = "",
val updatedAt: String = "",
val status: String = "",
val waitingOrder: Long = 0L,
val boothName: String = "",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.unifest.android.core.network.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class WaitingRequest(
@SerialName("waitingId")
val waitingId: Long,
@SerialName("deviceId")
val deviceId: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.unifest.android.core.network.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

@Serializable
data class MyWaitingResponse(
@SerialName("code")
val code: String,
@SerialName("message")
val message: String,
@SerialName("data")
val data: List<MyWaiting>? = null,
)

@Serializable
data class MyWaiting(
@SerialName("boothId")
val boothId: Long = 0L,
@SerialName("waitingId")
val waitingId: Long = 0L,
@SerialName("partySize")
val partySize: Long = 0L,
@SerialName("tel")
val tel: String = "",
@SerialName("deviceId")
val deviceId: String = "",
@SerialName("createdAt")
val createdAt: String = "",
@SerialName("updatedAt")
val updatedAt: String = "",
@SerialName("status")
val status: String = "",
@SerialName("waitingOrder")
val waitingOrder: Long = 0L,
@SerialName("boothName")
val boothName: String = "",
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ package com.unifest.android.core.network.service
import com.unifest.android.core.network.request.BoothWaitingRequest
import com.unifest.android.core.network.request.CheckPinValidationRequest
import com.unifest.android.core.network.request.LikeBoothRequest
import com.unifest.android.core.network.request.WaitingRequest
import com.unifest.android.core.network.response.AllBoothsResponse
import com.unifest.android.core.network.response.BoothDetailResponse
import com.unifest.android.core.network.response.CheckPinValidationResponse
import com.unifest.android.core.network.response.FestivalSearchResponse
import com.unifest.android.core.network.response.FestivalTodayResponse
import com.unifest.android.core.network.response.LikeBoothResponse
import com.unifest.android.core.network.response.LikedBoothsResponse
import com.unifest.android.core.network.response.MyWaitingResponse
import com.unifest.android.core.network.response.PopularBoothsResponse
import com.unifest.android.core.network.response.WaitingResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.PUT
import retrofit2.http.Path
import retrofit2.http.Query

Expand Down Expand Up @@ -79,4 +82,14 @@ interface UnifestService {
suspend fun requestBoothWaiting(
@Body boothWaitingRequest: BoothWaitingRequest,
): WaitingResponse

@GET("waiting/me/{deviceId}")
suspend fun getMyWaitingList(
@Path("deviceId") deviceId: String,
): MyWaitingResponse

@PUT("waiting")
suspend fun cancelBoothWaiting(
@Body request: WaitingRequest,
): WaitingResponse
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ class BoothViewModel @Inject constructor(
it.copy(
waitingId = waiting.waitingId,
waitingTel = "",
waitingPartySize = 1,
boothPinNumber = "",
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ internal fun MainScreen(
waitingNavGraph(
padding = innerPadding,
popBackStack = navigator::popBackStackIfNotMap,
navigateToBoothDetail = navigator::navigateToBoothDetail,
)
menuNavGraph(
padding = innerPadding,
Expand Down
2 changes: 2 additions & 0 deletions feature/waiting/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ android {

dependencies {
implementations(
projects.core.data,

libs.kotlinx.collections.immutable,
libs.timber,
)
Expand Down
Loading
Loading