Skip to content

Commit c5f69a3

Browse files
committed
feat: 제보히스토리 -> 제보상세 플로우 미비사항 구현
- 진행상황 collectionView cell에 진행상황 별 갯수 표시 - ReportEntity id 값을 옵셔널로 변경 - ReportDetail 날짜 포멧 변경
1 parent 064990b commit c5f69a3

6 files changed

Lines changed: 31 additions & 7 deletions

File tree

Projects/DataSource/Sources/DTO/ReportDTO.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ struct ReportDTO: Codable {
2121
let longitude: Double?
2222

2323
func toReportEntity() throws -> ReportEntity {
24-
guard let reportId else { throw NetworkError.decodingError }
2524
return ReportEntity(
2625
id: reportId,
2726
title: reportTitle,

Projects/Domain/Sources/Entity/ReportEntity.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
public struct ReportEntity {
9-
public let id: Int
9+
public let id: Int?
1010
public let title: String
1111
public let date: String?
1212
public let type: ReportType
@@ -17,7 +17,7 @@ public struct ReportEntity {
1717
public let photoURLs: [String]
1818

1919
public init(
20-
id: Int,
20+
id: Int?,
2121
title: String,
2222
date: String?,
2323
type: ReportType,

Projects/Presentation/Sources/Report/View/ReportHistoryViewController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,5 +346,4 @@ extension ReportHistoryViewController: ReportCategoryTableViewControllerDelegate
346346

347347
viewModel.action(input: .filterCategory(type: selectedCategory))
348348
}
349-
350349
}

Projects/Presentation/Sources/Report/ViewModel/ReportDetailViewModel.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import Combine
99
import Domain
10+
import Foundation
1011

1112
final class ReportDetailViewModel: ViewModel {
1213
enum Input {
@@ -39,8 +40,11 @@ final class ReportDetailViewModel: ViewModel {
3940
Task {
4041
do {
4142
if let reportEntity = try await reportRepository.fetchReportDetail(reportId: reportId) {
43+
let date = Date.convertToDate(from: reportEntity.date ?? "", dateType: .yearMonthDate)
44+
let dateString = date?.convertToString(dateType: .yearMonthDateWeek2)
45+
4246
let reportDetail = ReportDetail(
43-
date: reportEntity.date ?? "",
47+
date: dateString ?? "",
4448
title: reportEntity.title,
4549
status: reportEntity.progress,
4650
category: reportEntity.type,
@@ -49,7 +53,6 @@ final class ReportDetailViewModel: ViewModel {
4953
photoUrls: reportEntity.photoURLs)
5054
reportDetailSubject.send(reportDetail)
5155
}
52-
reportDetailSubject.send(nil)
5356
} catch {
5457
reportDetailSubject.send(nil)
5558
}

Projects/Presentation/Sources/Report/ViewModel/ReportHistoryViewModel.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ final class ReportHistoryViewModel: ViewModel {
126126
let date = Date.convertToDate(from: reportEntity.date ?? "", dateType: .yearMonthDate)
127127
let dateString = date?.convertToString(dateType: .yearMonthDateWeek)
128128

129+
guard let id = reportEntity.id else { continue }
130+
129131
let reportHistoryItem = ReportHistoryItem(
130-
id: reportEntity.id,
132+
id: id,
131133
title: reportEntity.title,
132134
thumbnailUrl: reportEntity.thumbnailURL ?? "",
133135
date: dateString ?? "",
@@ -139,6 +141,25 @@ final class ReportHistoryViewModel: ViewModel {
139141

140142
reports = reportHistoryItems
141143
reportSubject.send(reportHistoryItems)
144+
145+
let progressItems: [ReportProgressItem] = ReportProgress.allCases.map { progress in
146+
let count: Int
147+
148+
switch progress {
149+
case .entire:
150+
count = reports.count
151+
default:
152+
count = reports.filter { $0.progress == progress }.count
153+
}
154+
155+
return ReportProgressItem(
156+
uuid: UUID(),
157+
progress: progress,
158+
count: count,
159+
isSelected: progress == .entire)
160+
}
161+
162+
progressSubject.send(progressItems)
142163
} catch {
143164
// TODO: 에러 처리
144165
}

Projects/Shared/Sources/Extension/Date+.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ extension Date {
3333
case yearMonthDate
3434
case yearMonthDateShort
3535
case yearMonthDateWeek
36+
case yearMonthDateWeek2
3637
case yearMonth
3738
case dayOfWeek
3839
case date
@@ -46,6 +47,7 @@ extension Date {
4647
case .yearMonthDate: "yyyy-MM-dd"
4748
case .yearMonthDateShort: "yy.MM.dd"
4849
case .yearMonthDateWeek: "yyyy-MM-dd E"
50+
case .yearMonthDateWeek2: "yyyy-MM-dd (E)"
4951
case .yearMonth: "yyyy년 M월"
5052
case .dayOfWeek: "E"
5153
case .date: "d"

0 commit comments

Comments
 (0)