From 404568d62288c63d2c74157ebc8dc658c4dc18ab Mon Sep 17 00:00:00 2001 From: arinming Date: Sat, 14 Sep 2024 23:20:35 +0900 Subject: [PATCH] =?UTF-8?q?[FIX/#239]=20=EA=B3=B5=EA=B3=A0=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EA=B5=AC=EC=A1=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terning/data/dto/response/InternResponseDto.kt | 10 ++++++---- .../terning/data/mapper/intern/InternInfoMapper.kt | 5 +++-- .../com/terning/domain/entity/intern/InternInfo.kt | 5 +++-- .../java/com/terning/feature/intern/InternRoute.kt | 7 +++---- .../com/terning/feature/intern/InternViewModel.kt | 14 +++++++------- .../feature/intern/component/InternBottomBar.kt | 2 +- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt index 542c29130..3be4e1979 100644 --- a/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt +++ b/data/src/main/java/com/terning/data/dto/response/InternResponseDto.kt @@ -13,8 +13,8 @@ data class InternResponseDto( val deadline: String, @SerialName("workingPeriod") val workingPeriod: String, - @SerialName("startDate") - val startDate: String, + @SerialName("startYearMonth") + val startYearMonth: String, @SerialName("scrapCount") val scrapCount: Int, @SerialName("viewCount") @@ -33,6 +33,8 @@ data class InternResponseDto( val detail: String, @SerialName("url") val url: String, - @SerialName("scrapId") - val scrapId: Long? = null, + @SerialName("isScrapped") + val isScrapped: Boolean, + @SerialName("color") + val color: String? = null, ) \ No newline at end of file diff --git a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt index 7e3e8c1e0..9084268eb 100644 --- a/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt +++ b/data/src/main/java/com/terning/data/mapper/intern/InternInfoMapper.kt @@ -9,7 +9,7 @@ fun InternResponseDto.toInternInfo(): InternInfo = title = title, deadline = deadline, workingPeriod = workingPeriod, - startDate = startDate, + startYearMonth = startYearMonth, scrapCount = scrapCount, viewCount = viewCount, company = company, @@ -19,5 +19,6 @@ fun InternResponseDto.toInternInfo(): InternInfo = jobType = jobType, detail = detail, url = url, - scrapId = scrapId + isScrapped = isScrapped, + color = color, ) \ No newline at end of file diff --git a/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt b/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt index 77e70f12c..382db6d52 100644 --- a/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt +++ b/domain/src/main/java/com/terning/domain/entity/intern/InternInfo.kt @@ -5,7 +5,7 @@ data class InternInfo( val title: String, val deadline: String, val workingPeriod: String, - val startDate: String, + val startYearMonth: String, val scrapCount: Int, val viewCount: Int, val company: String, @@ -15,5 +15,6 @@ data class InternInfo( val jobType: String, val detail: String, val url: String, - val scrapId: Long? = null, + val isScrapped: Boolean, + val color: String? = null, ) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index c7b14af24..a1f60ab7b 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -52,10 +52,9 @@ fun InternRoute( viewModel: InternViewModel = hiltViewModel(), navController: NavHostController, ) { - val internState by viewModel.internUiState.collectAsStateWithLifecycle() - val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current + val internState by viewModel.internUiState.collectAsStateWithLifecycle(lifecycleOwner) LaunchedEffect(key1 = true) { viewModel.getInternInfo(announcementId) @@ -124,7 +123,7 @@ fun InternScreen( val internInfoList = listOf( stringResource(id = R.string.intern_info_d_day) to internInfo.deadline, stringResource(id = R.string.intern_info_working) to internInfo.workingPeriod, - stringResource(id = R.string.intern_info_start_date) to internInfo.startDate, + stringResource(id = R.string.intern_info_start_date) to internInfo.startYearMonth, ) val qualificationList = listOf( @@ -286,7 +285,7 @@ fun InternScreen( title = internInfo.title, scrapColor = CalRed, deadline = internInfo.deadline, - startYearMonth = internInfo.startDate, + startYearMonth = internInfo.startYearMonth, workingPeriod = internInfo.workingPeriod, internshipAnnouncementId = announcementId, companyImage = internInfo.companyImage, diff --git a/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt b/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt index 9eb0546e4..e1f955247 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternViewModel.kt @@ -31,14 +31,14 @@ class InternViewModel @Inject constructor( viewModelScope.launch { internRepository.getInternInfo(id) .onSuccess { internInfoModel -> - _internUiState.update { currentState -> - currentState.copy( - loadState = UiState.Success(internInfoModel), - isScrappedState = internInfoModel.scrapId != null, - ) - } + _internUiState.value = _internUiState.value.copy( + loadState = UiState.Success(internInfoModel) + ) } - .onFailure { + .onFailure { exception: Throwable -> + _internUiState.value = _internUiState.value.copy( + loadState = UiState.Failure(exception.toString()) + ) _sideEffect.emit(InternViewSideEffect.Toast(R.string.server_failure)) } } diff --git a/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt b/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt index 7e7922f14..08cae178a 100644 --- a/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt +++ b/feature/src/main/java/com/terning/feature/intern/component/InternBottomBar.kt @@ -76,7 +76,7 @@ fun InternBottomBar( .noRippleClickable { onScrapClick(internInfo) }, - tint = if (internInfo.scrapId != null) TerningMain else Grey350 + tint = if (internInfo.isScrapped) TerningMain else Grey350 ) Text( text = stringResource(