generated from GSM-MSG/MSG-Repository-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #383 from School-of-Company/380-input-company-feature
🔀 :: [#380] 기업 등록 페이지
- Loading branch information
Showing
13 changed files
with
185 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
App/Sources/Feature/InputCompanyFeature/Interface/InputCompanyFactory.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import SwiftUI | ||
|
||
public protocol InputCompanyFactory { | ||
associatedtype SomeView: View | ||
func makeView() -> SomeView | ||
} |
17 changes: 17 additions & 0 deletions
17
App/Sources/Feature/InputCompanyFeature/Source/InputCompanyComponent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import NeedleFoundation | ||
import SwiftUI | ||
import Service | ||
|
||
public protocol InputCompanyDependency: Dependency { | ||
var createdCompanyUseCase: any CreatedCompanyUseCase { get } | ||
} | ||
|
||
public final class InputCompanyComponent: Component<InputCompanyDependency>, InputCompanyFactory { | ||
public func makeView() -> some View { | ||
InputCompanyView( | ||
viewModel: .init( | ||
createdCompanyUseCase: dependency.createdCompanyUseCase | ||
) | ||
) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
App/Sources/Feature/InputCompanyFeature/Source/InputCompanyView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import SwiftUI | ||
|
||
struct InputCompanyView: View { | ||
@StateObject var viewModel: InputCompanyViewModel | ||
@Environment(\.dismiss) var dismiss | ||
|
||
init(viewModel: InputCompanyViewModel) { | ||
_viewModel = StateObject(wrappedValue: viewModel) | ||
} | ||
|
||
var body: some View { | ||
VStack(spacing: 0) { | ||
InputDataView( | ||
epic: "기업", | ||
state: "등록", | ||
selectedField: $viewModel.selectedFieldType, | ||
name: $viewModel.companyName | ||
) { | ||
viewModel.createCompany { | ||
dismiss() | ||
} | ||
} | ||
} | ||
.bitgouelToast( | ||
text: viewModel.errorMessage, | ||
isShowing: $viewModel.isErrorOccurred | ||
) | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
App/Sources/Feature/InputCompanyFeature/Source/InputCompanyViewModel.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Foundation | ||
import Service | ||
|
||
final class InputCompanyViewModel: BaseViewModel { | ||
@Published var selectedFieldType: FieldType? | ||
@Published var companyName: String = "" | ||
|
||
private let createdCompanyUseCase: any CreatedCompanyUseCase | ||
|
||
init(createdCompanyUseCase: any CreatedCompanyUseCase) { | ||
self.createdCompanyUseCase = createdCompanyUseCase | ||
} | ||
|
||
@MainActor | ||
func createCompany(_ success: @escaping () -> Void) { | ||
guard let field = selectedFieldType else { return } | ||
|
||
Task { | ||
do { | ||
try await createdCompanyUseCase( | ||
req: CreatedCompanyRequestDTO( | ||
companyName: companyName, | ||
field: field | ||
) | ||
) | ||
|
||
success() | ||
} catch { | ||
errorMessage = error.companyDomainErrorMessage() | ||
isErrorOccurred = true | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,6 @@ struct PickerTextField: View { | |
|
||
Spacer() | ||
} | ||
.padding(.vertical, 16) | ||
} | ||
} | ||
.background(backgroundColor) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters