Skip to content

Commit

Permalink
[FIX/#239] 공고 상세 페이지 데이터 구조 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
arinming committed Sep 14, 2024
1 parent 6f1ddc2 commit 404568d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fun InternResponseDto.toInternInfo(): InternInfo =
title = title,
deadline = deadline,
workingPeriod = workingPeriod,
startDate = startDate,
startYearMonth = startYearMonth,
scrapCount = scrapCount,
viewCount = viewCount,
company = company,
Expand All @@ -19,5 +19,6 @@ fun InternResponseDto.toInternInfo(): InternInfo =
jobType = jobType,
detail = detail,
url = url,
scrapId = scrapId
isScrapped = isScrapped,
color = color,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 404568d

Please sign in to comment.