File tree Expand file tree Collapse file tree
Presentation/Sources/Report Expand file tree Collapse file tree Original file line number Diff line number Diff 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,
Original file line number Diff line number Diff line change 66//
77
88public 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 ,
Original file line number Diff line number Diff line change @@ -346,5 +346,4 @@ extension ReportHistoryViewController: ReportCategoryTableViewControllerDelegate
346346
347347 viewModel. action ( input: . filterCategory( type: selectedCategory) )
348348 }
349-
350349}
Original file line number Diff line number Diff line change 77
88import Combine
99import Domain
10+ import Foundation
1011
1112final 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 "
You can’t perform that action at this time.
0 commit comments