Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: [#354] κ°•μ˜ μ‚­μ œ κΈ°λŠ₯ μΆ”κ°€ #355

Merged
merged 5 commits into from
Jul 3, 2024
6 changes: 6 additions & 0 deletions App/Sources/Application/DI/Lecture/AppComponent+Lecture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,10 @@ public extension AppComponent {
ModifyApplicantWhetherUseCaseImpl(lectureRepository: lectureRepository)
}
}

var deleteLectureUseCase: any DeleteLectureUseCase {
shared {
DeleteLectureUseCaseImpl(lectureRepository: lectureRepository)
}
}
}
3 changes: 3 additions & 0 deletions App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ private func factory050817f1b6d356b83467f47b58f8f304c97af4d5(_ component: Needle
return ClubListDependency90c6e61626f7c53ad50fProvider(appComponent: parent1(component) as! AppComponent)
}
private class LectureListDetailDependency2a815f1240973966e6a6Provider: LectureListDetailDependency {
var deleteLectureUseCase: any DeleteLectureUseCase {
return appComponent.deleteLectureUseCase
}
var fetchLectureDetailUseCase: any FetchLectureDetailUseCase {
return appComponent.fetchLectureDetailUseCase
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ struct ClubDetailView: View {
.progressViewStyle(.circular)
} else {
VStack(alignment: .leading, spacing: 4) {
BitgouelText(
text: viewModel.clubName,
font: .title2
)

HStack {
BitgouelText(
text: "μ†Œμ† 학ꡐ",
Expand All @@ -35,7 +30,7 @@ struct ClubDetailView: View {
Spacer()

BitgouelText(
text: viewModel.highSchoolName,
text: viewModel.schoolName,
font: .text3
)
}
Expand Down Expand Up @@ -92,6 +87,7 @@ struct ClubDetailView: View {
}
}
}
.navigationTitle(viewModel.clubName)
.if(viewModel.authority != .admin) {
$0.navigationBarBackButtonHidden()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final class ClubDetailViewModel: BaseViewModel {
// MARK: ClubInfo
var clubID: Int = 0
@Published var clubName: String = ""
@Published var highSchoolName: String = ""
@Published var schoolName: String = ""
@Published var students: [ClubDetailEntity.MemberInfoEntity] = []
@Published var teacher: ClubDetailEntity.TeacherInfoEntity?

Expand Down Expand Up @@ -41,17 +41,15 @@ final class ClubDetailViewModel: BaseViewModel {

Task {
do {
let response = try await fetchMyInfoUseCase()
let clubDetail = try await fetchClubDetail(authority: authority)

updateClubDetail(clubInfo: clubDetail)

let response = try await fetchMyInfoUseCase()
userID = response.userID

isLoading = false
} catch {
errorMessage = error.clubDomainErrorMessage()

isErrorOccurred = true
print(String(describing: error))
}
}
}
Expand All @@ -69,7 +67,7 @@ final class ClubDetailViewModel: BaseViewModel {
func updateClubDetail(clubInfo: ClubDetailEntity) {
self.clubID = clubInfo.clubID
self.clubName = clubInfo.clubName
self.highSchoolName = clubInfo.highSchoolName
self.schoolName = clubInfo.schoolName
self.students = clubInfo.students
self.teacher = clubInfo.teacher
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SwiftUI

struct LectureListDetailView: View {
@Environment(\.dismiss) var dismiss
@StateObject var viewModel: LectureListDetailViewModel

private let lectureApplicantListFactory: any LectureApplicantListFactory
Expand Down Expand Up @@ -173,6 +174,20 @@ struct LectureListDetailView: View {
.onAppear {
viewModel.onAppear()
}
.toolbar {
ToolbarItemGroup(placement: .navigationBarTrailing) {
switch viewModel.userAuthority {
case .admin,
.professor,
.government,
.companyInstructor:
changeLectureStatusButton()

default:
EmptyView()
}
}
}
.navigate(
to: lectureApplicantListFactory.makeView(lectureID: viewModel.lectureID).eraseToAnyView(),
when: Binding(
Expand All @@ -182,6 +197,26 @@ struct LectureListDetailView: View {
}
)
)
.confirmationDialog("", isPresented: $viewModel.isPresentedLectureActionSheet) {
Button("κ°•μ˜ μˆ˜μ •") {
#warning("κ°•μ˜ μˆ˜μ • κΈ°λŠ₯ μΆ”κ°€")
}
Button("κ°•μ˜ μ‚­μ œ", role: .destructive) {
viewModel.deleteLecture {
dismiss()
}
}
Button("μ·¨μ†Œ", role: .cancel) {}
}
}

@ViewBuilder
func changeLectureStatusButton() -> some View {
Button {
viewModel.updateIsPresentedLectureActionSheet(isPresented: true)
} label: {
BitgouelAsset.Icons.verticalEllipsisFill.swiftUIImage
}
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,39 @@ final class LectureListDetailViewModel: BaseViewModel {
@Published var isCancel: Bool = false
@Published var isPresentedLectureApplicantListView: Bool = false
@Published var userAuthority: UserAuthorityType = .user
@Published var isPresentedLectureActionSheet: Bool = false

let lectureID: String
private let fetchLectureDetailUseCase: any FetchLectureDetailUseCase
private let applyLectureUseCase: any ApplyLectureUseCase
private let cancelLectureUseCase: any CancelLectureUseCase
private let loadUserAuthorityUseCase: any LoadUserAuthorityUseCase
private let deleteLectureUseCase: any DeleteLectureUseCase

init(
lectureID: String,
fetchLectureDetailUseCase: any FetchLectureDetailUseCase,
applyLectureUseCase: any ApplyLectureUseCase,
cancelLectureUseCase: any CancelLectureUseCase,
loadUserAuthorityUseCase: any LoadUserAuthorityUseCase
loadUserAuthorityUseCase: any LoadUserAuthorityUseCase,
deleteLectureUseCase: any DeleteLectureUseCase
) {
self.lectureID = lectureID
self.fetchLectureDetailUseCase = fetchLectureDetailUseCase
self.applyLectureUseCase = applyLectureUseCase
self.cancelLectureUseCase = cancelLectureUseCase
self.loadUserAuthorityUseCase = loadUserAuthorityUseCase
self.deleteLectureUseCase = deleteLectureUseCase
}

func updateIsPresentedLectureApplicantView(isPresented: Bool) {
isPresentedLectureApplicantListView = isPresented
}

func updateIsPresentedLectureActionSheet(isPresented: Bool) {
isPresentedLectureActionSheet = isPresented
}

@MainActor
func onAppear() {
isLoading = true
Expand Down Expand Up @@ -77,4 +85,18 @@ final class LectureListDetailViewModel: BaseViewModel {
}
}
}

func deleteLecture(_ success: @escaping () -> Void) {
Task {
do {
try await deleteLectureUseCase(lectureID: lectureID)

success()
} catch {
errorMessage = error.lectureDomainErrorMessage()

isErrorOccurred = true
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public protocol LectureListDetailDependency: Dependency {
var cancelLectureUseCase: any CancelLectureUseCase { get }
var loadUserAuthorityUseCase: any LoadUserAuthorityUseCase { get }
var lectureApplicantListFactory: any LectureApplicantListFactory { get }
var deleteLectureUseCase: any DeleteLectureUseCase { get }
}

public final class LectureListDetailComponent: Component<LectureListDetailDependency>, LectureListDetailFactory {
Expand All @@ -19,7 +20,8 @@ public final class LectureListDetailComponent: Component<LectureListDetailDepend
fetchLectureDetailUseCase: dependency.fetchLectureDetailUseCase,
applyLectureUseCase: dependency.applyLectureUseCase,
cancelLectureUseCase: dependency.cancelLectureUseCase,
loadUserAuthorityUseCase: dependency.loadUserAuthorityUseCase
loadUserAuthorityUseCase: dependency.loadUserAuthorityUseCase,
deleteLectureUseCase: dependency.deleteLectureUseCase
),
lectureApplicantListFactory: dependency.lectureApplicantListFactory
)
Expand Down
6 changes: 5 additions & 1 deletion App/Sources/Feature/SignUpFeature/SignUpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ struct SignUpView: View {
inputGovernmentInfoSection()
}

ConditionView(viewModel.selectedSchool != nil) {
ConditionView(viewModel.selectedClub != nil) {
inputNameSection()
}

ConditionView(viewModel.selectedSchool != nil) {
inputClubSection()
}

default:
EmptyView()
}
Expand Down
37 changes: 11 additions & 26 deletions App/Sources/Feature/SignUpFeature/SignUpViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,47 +122,33 @@ final class SignUpViewModel: BaseViewModel {
if selectedSchool == nil {
return "학ꡐ 선택"
}
if selectedClub == nil {
return "동아리 선택"
}
if !nameIsValid {
return "이름 μž…λ ₯"
}

switch selectedUserRole {
case .student:
if selectedClub == nil {
return "동아리 선택"
} else if !nameIsValid {
return "이름 μž…λ ₯"
} else if !yearOfAdmissionIsValid {
if !yearOfAdmissionIsValid {
return "μž…ν•™λ…„λ„ μž…λ ₯"
} else if !studentIDIsValid {
return "ν•™λ²ˆ μž…λ ₯"
}
case .teacher, .bbozzack:
if selectedClub == nil {
return "동아리 선택"
} else if !nameIsValid {
return "이름 μž…λ ₯"
}

case .companyInstructor:
if selectedClub == nil {
return "동아리 선택"
} else if !nameIsValid {
return "이름 μž…λ ₯"
} else if selectedCompany.isEmpty {
if selectedCompany.isEmpty {
return "κΈ°μ—… μž…λ ₯"
}

case .professor:
if selectedClub == nil {
return "동아리 선택"
} else if !nameIsValid {
return "이름 μž…λ ₯"
} else if selectedUniversity.isEmpty {
if selectedUniversity.isEmpty {
return "λŒ€ν•™ μž…λ ₯"
}

case .government:
if !nameIsValid {
return "이름 μž…λ ₯"
} else if selectedGovernment.isEmpty {
if selectedGovernment.isEmpty {
return "κΈ°κ΄€ μž…λ ₯"
} else if sectors.isEmpty {
return "μ—…μ’… μž…λ ₯"
Expand Down Expand Up @@ -353,8 +339,7 @@ final class SignUpViewModel: BaseViewModel {
func signup(_ success: @escaping () -> Void) {
guard let selectedSchool else { return }
guard let selectedClub else { return }
guard checkphoneNumber(phoneNumber: phoneNumber)
else { return updateIsPhoneNumberErrorOccurred(isErrorOccurred: true) }
guard checkphoneNumber(phoneNumber: phoneNumber) else { return updateIsPhoneNumberErrorOccurred(isErrorOccurred: true) }
guard checkEmail(email: email) else { return updateIsEmailErrorOccurred(isErrorOccurred: true) }
guard checkPassword(password: password) else { return updateIsPasswordErrorOccurred(isErrorOccurred: true) }
guard checkedPassword() else { return updateIsCheckPasswordErrorOccurred(isErrorOccurred: true) }
Expand Down
15 changes: 14 additions & 1 deletion Service/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import ProjectDescription
import ProjectDescriptionHelpers
import EnvironmentPlugin

let configurations: [Configuration] = generateEnvironment == .ci ?
[
.debug(name: .dev),
.debug(name: .stage),
.release(name: .prod)
] :
[
.debug(name: .dev, xcconfig: .relativeToXCConfig(type: .dev, name: "Service")),
.debug(name: .stage, xcconfig: .relativeToXCConfig(type: .stage, name: "Service")),
.release(name: .prod, xcconfig: .relativeToXCConfig(type: .prod, name: "Service"))
]

let project = Project.dynamicFramwork(
name: "Service",
platform: .iOS,
Expand All @@ -11,5 +23,6 @@ let project = Project.dynamicFramwork(
]
),
deploymentTarget: env.deploymentTarget,
scripts: [.needle]
configurations: configurations,
scripts: [.needle, .swiftLint]
)
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,8 @@ public final class RemoteLectureDataSourceImpl: BaseRemoteDataSource<LectureAPI>
public func modifyApplicantWhether(lectureID: String, studentID: String, isComplete: Bool) async throws {
try await request(.modifyApplicantWhether(lectureID: lectureID, studentID: studentID, isComplete: isComplete))
}

public func deleteLecture(lectureID: String) async throws {
try await request(.deleteLecture(lectureID: lectureID))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public struct LectureRepositoryImpl: LectureRepository {
isComplete: isComplete
)
}

public func deleteLecture(lectureID: String) async throws {
try await remoteLectureDataSource.deleteLecture(lectureID: lectureID)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Foundation

public struct DeleteLectureUseCaseImpl: DeleteLectureUseCase {
private let lectureRepository: any LectureRepository

public init(lectureRepository: any LectureRepository) {
self.lectureRepository = lectureRepository
}

public func callAsFunction(lectureID: String) async throws {
try await lectureRepository.deleteLecture(lectureID: lectureID)
}
}
Loading
Loading