Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions Koin/Apps/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ extension SceneDelegate {
let shareMenuListUseCase = DefaultShareMenuListUseCase(diningRepository: diningRepository)
let fetchDiningNotiUseCase = DefaultFetchDiningNotiUseCase(notiRepository: notiReposotiry)
let changeNotiUseCase = DefaultChangeNotiUseCase(notiRepository: notiReposotiry)
let fetchCurrentDiningItemsUseCase = DefaultFetchCurrentDiningItemsUseCase(repository: diningRepository)
let fetchOperatingDiningPlacesUseCase = DefaultFetchOperatingDiningPlacesUseCase(repository: diningRepository)
let reportSoldoutDiningUseCase = DefaultReportSoldoutDiningUseCase(repository: diningRepository)
let uploadFileUseCase = DefaultUploadFileUseCase(coreRepository: coreRepository)
let assignAbTestUseCase = DefaultAssignAbTestUseCase(abTestRepository: abTestRepository)
Expand All @@ -358,7 +358,7 @@ extension SceneDelegate {
shareMenuListUseCase: shareMenuListUseCase,
fetchDiningNotiUseCase: fetchDiningNotiUseCase,
changeNotiUseCase: changeNotiUseCase,
fetchCurrentDiningItemsUseCase: fetchCurrentDiningItemsUseCase,
fetchOperatingDiningPlacesUseCase: fetchOperatingDiningPlacesUseCase,
reportSoldoutDiningUseCase: reportSoldoutDiningUseCase,
uploadFileUseCase: uploadFileUseCase,
assignAbTestUseCase: assignAbTestUseCase,
Expand Down Expand Up @@ -471,7 +471,7 @@ extension SceneDelegate {
let shareMenuListUseCase = DefaultShareMenuListUseCase(diningRepository: diningRepository)
let fetchDiningNotiUseCase = DefaultFetchDiningNotiUseCase(notiRepository: notiReposotiry)
let changeNotiUseCase = DefaultChangeNotiUseCase(notiRepository: notiReposotiry)
let fetchCurrentDiningItemsUseCase = DefaultFetchCurrentDiningItemsUseCase(repository: diningRepository)
let fetchOperatingDiningPlacesUseCase = DefaultFetchOperatingDiningPlacesUseCase(repository: diningRepository)
let reportSoldoutDiningUseCase = DefaultReportSoldoutDiningUseCase(repository: diningRepository)
let uploadFileUseCase = DefaultUploadFileUseCase(coreRepository: coreRepository)
let assignAbTestUseCase = DefaultAssignAbTestUseCase(abTestRepository: abTestRepository)
Expand All @@ -482,7 +482,7 @@ extension SceneDelegate {
shareMenuListUseCase: shareMenuListUseCase,
fetchDiningNotiUseCase: fetchDiningNotiUseCase,
changeNotiUseCase: changeNotiUseCase,
fetchCurrentDiningItemsUseCase: fetchCurrentDiningItemsUseCase,
fetchOperatingDiningPlacesUseCase: fetchOperatingDiningPlacesUseCase,
reportSoldoutDiningUseCase: reportSoldoutDiningUseCase,
uploadFileUseCase: uploadFileUseCase,
assignAbTestUseCase: assignAbTestUseCase,
Expand Down
2 changes: 1 addition & 1 deletion Koin/Domain/Model/Dining/DiningPlace.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by 김나훈 on 3/9/24.
// Nullable 2024.04.26

enum DiningPlace: Equatable {
enum DiningPlace: Equatable, CaseIterable {
case cornerA
case cornerB
case cornerC
Expand Down
14 changes: 14 additions & 0 deletions Koin/Domain/Model/Dining/DiningReportRequest.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// DiningReportRequest.swift
// koin
//
// Created by 홍기정 on 10/28/26.
//

import Foundation

struct DiningReportRequest {
let place: DiningPlace
let id: Int
let evidenceImageData: Data
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
//
// FetchOperatingDiningPlacesUseCase.swift
// koin
//
// Created by 홍기정 on 10/18/26.
//

import Foundation

protocol FetchOperatingDiningPlacesUseCase {
func execute() async throws -> [(place: DiningPlace, id: Int?)]
}

final class DefaultFetchOperatingDiningPlacesUseCase: FetchOperatingDiningPlacesUseCase {

let repository: DiningRepository

init(repository: DiningRepository) {
self.repository = repository
}

func execute() async throws -> [(place: DiningPlace, id: Int?)] {
let calendar = Calendar.current
let now = Date()
let dayOfWeek: DayOfWeek = {
let weekday = calendar.component(.weekday, from: now)
switch weekday {
case 1:
return .sunday
case 7:
return .saturday
default:
return.weekday
}
}()
let currentTime = {
let hour = calendar.component(.hour, from: now)
let minute = calendar.component(.minute, from: now)
return String(format: "%02d:%02d", hour, minute)
}()
let currentDiningType = try? await repository.fetchCoopShopList()
.firstValue()
.opens
.filter {
$0.dayOfWeek == dayOfWeek
}
.first {
$0.contains(time: currentTime)
}
.map {
$0.type.toDiningType()
}
let operatingDiningItems = try await repository.fetchDiningList(date: Date()).firstValue()
.filter { $0.type == currentDiningType }
.filter { $0.place != .secondCampus }

let diningPlaces: [(DiningPlace, id: Int?)] = DiningPlace.allCases
.filter {
$0 != .secondCampus
}
.map { place in
let operatingDiningItem: DiningItem? = operatingDiningItems.first {
$0.place == place
&& $0.isSoldOut == false
&& $0.menu.first != "미운영"
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return (place, operatingDiningItem?.id)
}

return diningPlaces
}
}
46 changes: 23 additions & 23 deletions Koin/Presentation/Dining/Dining/DiningHostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,8 @@ extension DiningHostingController {
}

extension DiningHostingController {
private func onCompleteButtonTapped(
selectedItem: DiningItem,
evidenceImage: UIImage
) {
guard let imageData = evidenceImage.jpegData(compressionQuality: 0.5) else {
return
}
rootView.didTapReport(
selectedItem: selectedItem,
evidenceImage: imageData
)
private func onCompleteButtonTapped(_ request: DiningReportRequest) {
rootView.didTapReport(request)
}
}

Expand Down Expand Up @@ -174,56 +165,65 @@ extension DiningHostingController {
}

private func showReportModal(selectedPlace: DiningPlace?) {
let diningItems = rootView.currentDiningItems
guard let selectedItem = diningItems.first(where: { $0.place == selectedPlace }) ?? diningItems.first else {
let operatingPlaces = rootView.operatingPlaces
guard operatingPlaces.contains(where: { $0.id != nil }) else {
showToastMessage(message: "학생식당 운영시간이 아닙니다.")
return
}
self.modalView = makeModalView(selectedItem: selectedItem)
self.modalView = makeModalView(
operatingPlaces: operatingPlaces,
selectedPlace: selectedPlace
)
presentReportModalViewController()
}

private func makeModalView(selectedItem: DiningItem) -> DiningReportModalView {
private func makeModalView(
operatingPlaces: [(place: DiningPlace, id: Int?)],
selectedPlace: DiningPlace?
) -> DiningReportModalView {
return DiningReportModalView(
diningItems: rootView.currentDiningItems,
operatingPlaces: operatingPlaces,
onDismissButtonTapped: { [weak self] in
guard let self else {
return
}
if let reportAbTestName, let selectedItem = modalView?.selectedItem {
if let reportAbTestName, let selectedPlace = modalView?.selectedPlace {
rootView.makeLogAnalyticsEvent(
label: EventParameter.EventLabel.Campus.Dining.cafeteriaDiningSoldoutExit,
category: .click,
value: "\(reportAbTestName)_\(selectedItem.place.name)_이탈"
value: "\(reportAbTestName)_\(selectedPlace.name)_이탈"
)
}
dismiss(animated: true)
},
onPlaceSelected: { [weak self] item in
onPlaceSelected: { [weak self] place in
guard let self, let reportAbTest = rootView.reportAbTest else {
return
}
rootView.makeLogAnalyticsEvent(
label: EventParameter.EventLabel.Campus.Dining.cafeteriaDiningSoldoutSelect,
category: .select,
value: "\(reportAbTest.logValue)_\(item.place.name)"
value: "\(reportAbTest.logValue)_\(place.name)"
)
},
onSelectImageButtonTapped: { [weak self] in
guard let self else {
return
}
if let reportAbTestName, let selectedItem = modalView?.selectedItem {
if let reportAbTestName, let selectedPlace = modalView?.selectedPlace {
rootView.makeLogAnalyticsEvent(
label: EventParameter.EventLabel.Campus.Dining.cafeteriaDiningSoldoutPhoto,
category: .click,
value: "\(reportAbTestName)_\(selectedItem.place.name)"
value: "\(reportAbTestName)_\(selectedPlace.name)"
)
}
checkAndPresentPicker()
},
onCompleteButtonTapped: onCompleteButtonTapped,
selectedItem: selectedItem
showToastMessage: { [weak self] message in
self?.showToastMessage(message: message)
},
selectedPlace: selectedPlace
)
}

Expand Down
13 changes: 5 additions & 8 deletions Koin/Presentation/Dining/Dining/DiningView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct DiningView: ActionBindableView {

// MARK: - Properties
@State private var viewModel: DiningViewModel
var currentDiningItems: [DiningItem] {
viewModel.currentDiningItems
var operatingPlaces: [(place: DiningPlace, id: Int?)] {
viewModel.operatingPlaces
}
var reportAbTest: DiningReportAbTest? {
viewModel.reportAbTest
Expand Down Expand Up @@ -68,6 +68,7 @@ struct DiningView: ActionBindableView {
}
}
.onChange(of: viewModel.didFinishReporting) {
IndicatorView.dismiss()
sendAction(.didFinishReporting)
}
.onChange(of: viewModel.diningNoti) {
Expand All @@ -93,12 +94,9 @@ struct DiningView: ActionBindableView {
viewModel.execute(.didTapCloseReportTooltip)
}

func didTapReport(
selectedItem: DiningItem,
evidenceImage imageData: Data
) {
func didTapReport(_ request: DiningReportRequest) {
IndicatorView.show()
viewModel.execute(.didTapReport(selectedItem: selectedItem, imageData: imageData))
viewModel.execute(.didTapReport(request))
}

func didTapSoldOutSwitch(isOn: Bool) {
Expand Down Expand Up @@ -212,4 +210,3 @@ extension DiningView {
)
}
}

Loading
Loading