Skip to content

Commit

Permalink
Merge pull request #351 from GSM-MSG/348-authentication-issue
Browse files Browse the repository at this point in the history
🔀 :: 348 인증제 이슈
  • Loading branch information
baekteun authored Jul 13, 2024
2 parents e40893e + 7c18fbe commit 52d2671
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 163 deletions.
56 changes: 28 additions & 28 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,33 +474,33 @@ extension JwtStoreComponent: Registration {
extension AppComponent: Registration {
public func registerItems() {

localTable["rootComponent-RootComponent"] = { self.rootComponent as Any }
localTable["signinBuildable-any SigninBuildable"] = { self.signinBuildable as Any }
localTable["inputInformationBuildable-any InputInformationBuildable"] = { self.inputInformationBuildable as Any }
localTable["inputProfileInfoBuildable-any InputProfileInfoBuildable"] = { self.inputProfileInfoBuildable as Any }
localTable["inputSchoolLifeInfoBuildable-any InputSchoolLifeInfoBuildable"] = { self.inputSchoolLifeInfoBuildable as Any }
localTable["inputWorkInfoBuildable-any InputWorkInfoBuildable"] = { self.inputWorkInfoBuildable as Any }
localTable["inputMilitaryInfoBuildable-any InputMilitaryInfoBuildable"] = { self.inputMilitaryInfoBuildable as Any }
localTable["inputCertificateInfoBuildable-any InputCertificateInfoBuildable"] = { self.inputCertificateInfoBuildable as Any }
localTable["inputLanguageInfoBuildable-any InputLanguageInfoBuildable"] = { self.inputLanguageInfoBuildable as Any }
localTable["inputPrizeInfoBuildable-any InputPrizeInfoBuildable"] = { self.inputPrizeInfoBuildable as Any }
localTable["inputProjectInfoBuildable-any InputProjectInfoBuildable"] = { self.inputProjectInfoBuildable as Any }
localTable["mainBuildable-any MainBuildable"] = { self.mainBuildable as Any }
localTable["myPageBuildable-any MyPageBuildable"] = { self.myPageBuildable as Any }
localTable["techStackAppendBuildable-any TechStackAppendBuildable"] = { self.techStackAppendBuildable as Any }
localTable["studentDetailBuildable-any StudentDetailBuildable"] = { self.studentDetailBuildable as Any }
localTable["filterBuildable-any FilterBuildable"] = { self.filterBuildable as Any }
localTable["splashBuildable-any SplashBuildable"] = { self.splashBuildable as Any }
localTable["gsmAuthenticationBuildable-any GSMAuthenticationBuildable"] = { self.gsmAuthenticationBuildable as Any }
localTable["authDomainBuildable-any AuthDomainBuildable"] = { self.authDomainBuildable as Any }
localTable["studentDomainBuildable-any StudentDomainBuildable"] = { self.studentDomainBuildable as Any }
localTable["majorDomainBuildable-any MajorDomainBuildable"] = { self.majorDomainBuildable as Any }
localTable["fileDomainBuildable-any FileDomainBuildable"] = { self.fileDomainBuildable as Any }
localTable["userDomainBuildable-any UserDomainBuildable"] = { self.userDomainBuildable as Any }
localTable["techStackDomainBuildable-any TechStackDomainBuildable"] = { self.techStackDomainBuildable as Any }
localTable["jwtStoreBuildable-any JwtStoreBuildable"] = { self.jwtStoreBuildable as Any }
localTable["keychainBuildable-any KeychainBuildable"] = { self.keychainBuildable as Any }
localTable["authenticationDomainBuildable-any AuthenticationDomainBuildable"] = { self.authenticationDomainBuildable as Any }
localTable["rootComponent-RootComponent"] = { [unowned self] in self.rootComponent as Any }
localTable["signinBuildable-any SigninBuildable"] = { [unowned self] in self.signinBuildable as Any }
localTable["inputInformationBuildable-any InputInformationBuildable"] = { [unowned self] in self.inputInformationBuildable as Any }
localTable["inputProfileInfoBuildable-any InputProfileInfoBuildable"] = { [unowned self] in self.inputProfileInfoBuildable as Any }
localTable["inputSchoolLifeInfoBuildable-any InputSchoolLifeInfoBuildable"] = { [unowned self] in self.inputSchoolLifeInfoBuildable as Any }
localTable["inputWorkInfoBuildable-any InputWorkInfoBuildable"] = { [unowned self] in self.inputWorkInfoBuildable as Any }
localTable["inputMilitaryInfoBuildable-any InputMilitaryInfoBuildable"] = { [unowned self] in self.inputMilitaryInfoBuildable as Any }
localTable["inputCertificateInfoBuildable-any InputCertificateInfoBuildable"] = { [unowned self] in self.inputCertificateInfoBuildable as Any }
localTable["inputLanguageInfoBuildable-any InputLanguageInfoBuildable"] = { [unowned self] in self.inputLanguageInfoBuildable as Any }
localTable["inputPrizeInfoBuildable-any InputPrizeInfoBuildable"] = { [unowned self] in self.inputPrizeInfoBuildable as Any }
localTable["inputProjectInfoBuildable-any InputProjectInfoBuildable"] = { [unowned self] in self.inputProjectInfoBuildable as Any }
localTable["mainBuildable-any MainBuildable"] = { [unowned self] in self.mainBuildable as Any }
localTable["myPageBuildable-any MyPageBuildable"] = { [unowned self] in self.myPageBuildable as Any }
localTable["techStackAppendBuildable-any TechStackAppendBuildable"] = { [unowned self] in self.techStackAppendBuildable as Any }
localTable["studentDetailBuildable-any StudentDetailBuildable"] = { [unowned self] in self.studentDetailBuildable as Any }
localTable["filterBuildable-any FilterBuildable"] = { [unowned self] in self.filterBuildable as Any }
localTable["splashBuildable-any SplashBuildable"] = { [unowned self] in self.splashBuildable as Any }
localTable["gsmAuthenticationBuildable-any GSMAuthenticationBuildable"] = { [unowned self] in self.gsmAuthenticationBuildable as Any }
localTable["authDomainBuildable-any AuthDomainBuildable"] = { [unowned self] in self.authDomainBuildable as Any }
localTable["studentDomainBuildable-any StudentDomainBuildable"] = { [unowned self] in self.studentDomainBuildable as Any }
localTable["majorDomainBuildable-any MajorDomainBuildable"] = { [unowned self] in self.majorDomainBuildable as Any }
localTable["fileDomainBuildable-any FileDomainBuildable"] = { [unowned self] in self.fileDomainBuildable as Any }
localTable["userDomainBuildable-any UserDomainBuildable"] = { [unowned self] in self.userDomainBuildable as Any }
localTable["techStackDomainBuildable-any TechStackDomainBuildable"] = { [unowned self] in self.techStackDomainBuildable as Any }
localTable["jwtStoreBuildable-any JwtStoreBuildable"] = { [unowned self] in self.jwtStoreBuildable as Any }
localTable["keychainBuildable-any KeychainBuildable"] = { [unowned self] in self.keychainBuildable as Any }
localTable["authenticationDomainBuildable-any AuthenticationDomainBuildable"] = { [unowned self] in self.authenticationDomainBuildable as Any }
}
}
extension KeychainComponent: Registration {
Expand Down Expand Up @@ -669,7 +669,7 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi

#if !NEEDLE_DYNAMIC

private func register1() {
@inline(never) private func register1() {
registerProviderFactory("^->AppComponent->JwtStoreComponent", factoryb27d5aae1eb7e73575a6f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent", factoryEmptyDependencyProvider)
registerProviderFactory("^->AppComponent->KeychainComponent", factoryEmptyDependencyProvider)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import FileDomainTesting

@main
struct GSMAuthenticationFormDemoApp: App {
let make: DemoMakable = DemoMakable()

var body: some Scene {
WindowGroup {
let uiModel = GSMAuthenticationFormUIModel(
FormBuilderAreaListView(
areas: [
GSMAuthenticationFormUIModel.Area(
title: "Area 1",
Expand Down Expand Up @@ -66,29 +64,8 @@ struct GSMAuthenticationFormDemoApp: App {
)
]
)
],
files: [
GSMAuthenticationFormUIModel.File(name: "File 1", url: "http://example.com/file1"),
GSMAuthenticationFormUIModel.File(name: "File 2", url: "http://example.com/file2")
]
)

make.makeView(uiModel: uiModel)
}
}
}

final class DemoMakable {
func makeView(uiModel: GSMAuthenticationFormUIModel) -> GSMAuthenticationFormBuilderView {
return GSMAuthenticationFormBuilderView(
intent: GSMAuthenticationFormIntent(
model: GSMAuthenticationFormModel(),
fetchAuthenticationFormUseCase: FetchAuthenticationFormUseCaseSpy(),
inputAuthenticationUseCase: InputAuthenticationUseCaseSpy(),
fileUploadUseCase: FileUploadUseCaseSpy(), fetchAuthenticationStateUseCase: FetchAuthenticationStateUseCaseSpy()
),
uiModel: uiModel
) { _ in
) { _ in }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ final class GSMAuthenticationFormIntent: GSMAuthenticationFormIntentProtocol {
model?.updateAuthenticationStateEntity(authenticationStateEntity: authenticationStateEntity)

model?.updateAuthenticationStateModel(
stateModel:
.init(
name: authenticationStateEntity.name,
score: authenticationStateEntity.score,
grader: authenticationStateEntity.grader,
markingBoardType: authenticationStateEntity.markingBoardType
)
stateModel: .init(
name: authenticationStateEntity.name,
score: authenticationStateEntity.score,
grader: authenticationStateEntity.grader,
markingBoardType: authenticationStateEntity.markingBoardType
)
)
if authenticationStateEntity.markingBoardType != .notSubmitted {
model?.updateIsLoading(isLoading: false)
Expand Down Expand Up @@ -83,7 +82,19 @@ final class GSMAuthenticationFormIntent: GSMAuthenticationFormIntentProtocol {
}
}

func saveButtonDidTap(state: any GSMAuthenticationFormStateProtocol) {
func saveButtonDidTap() {
model?.updateIsPresentedSubmitDialog(isPresentedSubmitDialog: true)
}

func toastDismissed() {
model?.updateIsSubmitting(isSubmitting: false)
}

func dialogDismissed() {
model?.updateIsPresentedSubmitDialog(isPresentedSubmitDialog: false)
}

func submitButtonDidTap(state: any GSMAuthenticationFormStateProtocol) {
Task {
do {
guard let authenticationEntity = state.authenticationEntity else { return }
Expand All @@ -93,6 +104,8 @@ final class GSMAuthenticationFormIntent: GSMAuthenticationFormIntentProtocol {
entity: authenticationEntity
)
)
dialogDismissed()
model?.updateIsSubmitting(isSubmitting: true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import Foundation
protocol GSMAuthenticationFormIntentProtocol {
func viewOnAppear()
func formOnAppear()
func saveButtonDidTap(state: any GSMAuthenticationFormStateProtocol)
func saveButtonDidTap()
func toastDismissed()
func dialogDismissed()
func submitButtonDidTap(state: any GSMAuthenticationFormStateProtocol)
func appendField(
area: Int,
sectionIndex: Int,
Expand Down Expand Up @@ -43,7 +46,6 @@ protocol GSMAuthenticationFormIntentProtocol {
file: Data,
fileName: String
)

func updateSelectField(
area: Int,
sectionIndex: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ import FoundationUtil
final class GSMAuthenticationFormModel: ObservableObject, GSMAuthenticationFormStateProtocol {
@Published var uiModel: GSMAuthenticationFormUIModel = .init(areas: [], files: [])
@Published var fieldContents: [GSMAuthenticationFormFieldModel] = []
@Published var stateModel: GSMAuthenticationStateModel = .init(name: "", score: 0, markingBoardType: .notSubmitted)
@Published var stateModel: GSMAuthenticationStateModel = .init(name: "", score: 0, markingBoardType: .underReview)
@Published var isLoading: Bool = false
@Published var isSubmitting: Bool = false
@Published var isPresentedSubmitDialog: Bool = false
var authenticationEntity: AuthenticationFormEntity?
var authenticationStateEntity: AuthenticationStateEntity?
@Published var areas: [GSMAuthenticationFormUIModel.Area] = []
@Published var files: [GSMAuthenticationFormUIModel.File] = []
}

extension GSMAuthenticationFormModel: GSMAuthenticationFormActionProtocol {
func updateGSMAuthenticationFormUIModel(uiModel: GSMAuthenticationFormUIModel) {
self.uiModel = uiModel
self.areas = uiModel.areas
self.files = uiModel.files
}

func updateAuthenticationEntity(authenticationEntity: AuthenticationFormEntity) {
Expand Down Expand Up @@ -61,7 +67,7 @@ extension GSMAuthenticationFormModel: GSMAuthenticationFormActionProtocol {
)
}

uiModel.areas[area].sections[sectionIndex].groups.insert(
areas[area].sections[sectionIndex].groups.insert(
.init(
groupId: selectedGroup.groupId,
maxScore: selectedGroup.maxScore,
Expand All @@ -72,39 +78,46 @@ extension GSMAuthenticationFormModel: GSMAuthenticationFormActionProtocol {
}

func updateTextField(area: Int, sectionIndex: Int, groupIndex: Int, fieldIndex: Int, text: String) {
uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type = .text(value: text)
areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type = .text(value: text)
}

func updateNumberField(area: Int, sectionIndex: Int, groupIndex: Int, fieldIndex: Int, number: Int) {
uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type = .number(value: number)
areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type = .number(value: number)
}

func updateBoolField(area: Int, sectionIndex: Int, groupIndex: Int, fieldIndex: Int, select: String) {
uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type =
.boolean(selectedValue: select, values: uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].findFieldTypeValue())
areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type =
.boolean(selectedValue: select, values: areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].findFieldTypeValue())
}

func updateFileField(area: Int, sectionIndex: Int, groupIndex: Int, fieldIndex: Int, file: String) {
uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type = .file(fileName: file)
areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type = .file(fileName: file)
}

func updateSelectField(area: Int, sectionIndex: Int, groupIndex: Int, fieldIndex: Int, select: String) {
uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type =
.select(selectedValue: select, values: uiModel.areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].findFieldTypeValue())
areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].type =
.select(selectedValue: select, values: areas[area].sections[sectionIndex].groups[groupIndex].fields[fieldIndex].findFieldTypeValue())
}

func deleteField(
area: Int,
sectionIndex: Int,
groupIndex: Int
) {
uiModel.areas[area].sections[sectionIndex].groups.remove(at: groupIndex)
areas[area].sections[sectionIndex].groups.remove(at: groupIndex)
}


func updateIsLoading(isLoading: Bool) {
self.isLoading = isLoading
}

func updateIsSubmitting(isSubmitting: Bool) {
self.isSubmitting = isSubmitting
}

func updateIsPresentedSubmitDialog(isPresentedSubmitDialog: Bool) {
self.isPresentedSubmitDialog = isPresentedSubmitDialog
}
}

private extension GSMAuthenticationFormModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import Foundation

protocol GSMAuthenticationFormStateProtocol {
var uiModel: GSMAuthenticationFormUIModel { get }
var areas: [GSMAuthenticationFormUIModel.Area] { get }
var files: [GSMAuthenticationFormUIModel.File] { get }
var authenticationEntity: AuthenticationFormEntity? { get }
var authenticationStateEntity: AuthenticationStateEntity? { get }
var stateModel: GSMAuthenticationStateModel { get }
var isLoading: Bool { get }
var isSubmitting: Bool { get }
var isPresentedSubmitDialog: Bool { get }
}

protocol GSMAuthenticationFormActionProtocol: AnyObject {
Expand Down Expand Up @@ -68,4 +72,8 @@ protocol GSMAuthenticationFormActionProtocol: AnyObject {
)

func updateIsLoading(isLoading: Bool)

func updateIsSubmitting(isSubmitting: Bool)

func updateIsPresentedSubmitDialog(isPresentedSubmitDialog: Bool)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import DesignSystem
import SwiftUI
import ViewUtil

enum FieldChanges {
case text(String)
case number(Int)
case boolean(String)
case file(Data, String)
case select(String)
}

enum FieldInteraction {
case fieldChanges(area: Int, sectionIndex: Int, groupIndex: Int, fieldIndex: Int, fieldChanges: FieldChanges)
case groupAdd(area: Int, section: Int, group: Int)
case groupRemove(area: Int, section: Int, group: Int)
}

struct FormBuilderAreaListView: View {
private typealias Area = GSMAuthenticationFormUIModel.Area
private typealias Section = Area.Section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ struct FormBuilderAreaView: View {
}
)
)
.keyboardType(.numberPad)
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import SwiftUI

struct GSMAuthenticationFileDownloadView: View {
@Environment(\.openURL) var openURL
private let files: [GSMAuthenticationFormUIModel.File]
@State private var isCollapsed = false
private let uiModel: [GSMAuthenticationFormUIModel.File]
private typealias File = GSMAuthenticationFormUIModel.File

init(
uiModel: [GSMAuthenticationFormUIModel.File]
files: [GSMAuthenticationFormUIModel.File]
) {
self.uiModel = uiModel
self.files = files
}

var body: some View {
fileAreaView(files: uiModel)
fileAreaView(files: files)
}

@ViewBuilder
Expand Down

This file was deleted.

Loading

0 comments on commit 52d2671

Please sign in to comment.