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

πŸ”€ :: [#79] ν•™μƒνšŒμ›κ°€μž… 검증 둜직 λ¦¬νŒ©ν† λ§ #119

Merged
merged 7 commits into from
Jan 13, 2024
97 changes: 45 additions & 52 deletions App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import Service

struct StudentSignUpView: View {
@StateObject var viewModel: StudentSignUpViewModel
@State var isSchool = false
@State var isShowingClubSelectSheet = false
@State var isShowingSuccessView = false

var body: some View {
Expand All @@ -15,27 +13,27 @@ struct StudentSignUpView: View {
VStack(spacing: 16) {
switch viewModel.selectedUserRole {
case .student:
ConditionView(viewModel.grade != nil && viewModel.classRoom != nil && viewModel.number != nil) {
ConditionView(viewModel.studentIDIsValid) {
inputAuthorizationInfoSection()
}

ConditionView(!viewModel.name.isEmpty) {
ConditionView(viewModel.nameIsValid) {
inputStudentInfoSection()
}

ConditionView(viewModel.selectedClub != "동아리") {
ConditionView(viewModel.selectedClub != nil) {
inputNameSection()
}

ConditionView(viewModel.selectedSchool != nil) {
inputClubSection()
}
case .teacher, .bbozzack:
ConditionView(!viewModel.name.isEmpty) {
ConditionView(viewModel.nameIsValid) {
inputAuthorizationInfoSection()
}

ConditionView(viewModel.selectedClub != "동아리") {
ConditionView(viewModel.selectedClub != nil) {
inputNameSection()
}

Expand All @@ -47,11 +45,11 @@ struct StudentSignUpView: View {
inputAuthorizationInfoSection()
}

ConditionView(!viewModel.name.isEmpty) {
ConditionView(viewModel.nameIsValid) {
inputCompanyInstructorInfoSection()
}

ConditionView(viewModel.selectedClub != "동아리") {
ConditionView(viewModel.selectedClub != nil) {
inputNameSection()
}

Expand All @@ -63,11 +61,11 @@ struct StudentSignUpView: View {
inputAuthorizationInfoSection()
}

ConditionView(!viewModel.name.isEmpty) {
ConditionView(viewModel.nameIsValid) {
inputProfessorInfoSection()
}

ConditionView(viewModel.selectedClub != "동아리") {
ConditionView(viewModel.selectedClub != nil) {
inputNameSection()
}

Expand All @@ -79,7 +77,7 @@ struct StudentSignUpView: View {
inputAuthorizationInfoSection()
}

ConditionView(!viewModel.name.isEmpty) {
ConditionView(viewModel.nameIsValid) {
inputGovernmentInfoSection()
}

Expand All @@ -96,20 +94,28 @@ struct StudentSignUpView: View {
}
}
.bitgouelBottomSheet(
isShowing: $isSchool
isShowing: $viewModel.isPresentedSchoolSheet
) {
SchoolListView(viewModel: viewModel)
.frame(height: 415)
SchoolListView(
searchKeyword: $viewModel.schoolSearch,
schoolList: viewModel.searchedSchoolList,
selectedSchool: viewModel.selectedSchool
) { highschool in
viewModel.selectedSchool = highschool
viewModel.isPresentedSchoolSheet = false
}
.frame(height: 415)
}
.bitgouelBottomSheet(
isShowing: $isShowingClubSelectSheet
isShowing: $viewModel.isPresentedClubSheet
) {
ClubListView(
searchText: $viewModel.clubSearch,
searchedClubList: viewModel.searchedClubList,
selectedClub: viewModel.selectedClub,
selectedClub: viewModel.selectedClub ?? "동아리",
clubDidSelect: { selectedClub in
viewModel.selectedClub = selectedClub
viewModel.isPresentedClubSheet = false
}
)
.frame(height: 415)
Expand Down Expand Up @@ -158,7 +164,7 @@ struct StudentSignUpView: View {
func inputAuthorizationInfoSection() -> some View {
VStack(spacing: 16) {
Group {
if !viewModel.password.isEmpty {
if viewModel.passwordIsValid {
SecureBitgouelTextField(
"λΉ„λ°€λ²ˆν˜Έ",
text: $viewModel.checkPassword
Expand All @@ -169,7 +175,7 @@ struct StudentSignUpView: View {
}
}

if !viewModel.certificationNumberEmail.isEmpty {
if viewModel.emailIsValid {
SecureBitgouelTextField(
"λΉ„λ°€λ²ˆν˜Έ",
text: $viewModel.password
Expand All @@ -179,46 +185,22 @@ struct StudentSignUpView: View {
}

Group {
if !viewModel.email.isEmpty {
if viewModel.checkEmail(viewModel.email) == true {
BitgouelTextField(
"인증번호",
text: $viewModel.certificationNumberEmail,
helpMessage: viewModel.convertSecondsToTime(timeInSeconds: viewModel.emailTimeRemaining),
link: "μž¬λ°œμ†‘"
)
}
}

if !viewModel.certificationNumberPhoneNumber.isEmpty {
if viewModel.phoneNumberIsValid {
BitgouelTextField(
"이메일",
text: $viewModel.email,
helpMessage: viewModel.emailHelpMessage,
isError: viewModel.isEmailErrorOccured
isError: !viewModel.emailIsValid
)
.onChange(of: viewModel.emailHelpMessage) { newValue in }
.textContentType(.emailAddress)
}
}
Group {
if !viewModel.phoneNumber.isEmpty {
BitgouelTextField(
"인증번호",
text: $viewModel.certificationNumberPhoneNumber,
helpMessage: viewModel.convertSecondsToTime(timeInSeconds: viewModel.phoneNumberTimeRemaining),
link: "μž¬λ°œμ†‘"
)
}
BitgouelTextField(
"μ „ν™”λ²ˆν˜Έ",
text: $viewModel.phoneNumber
)
.onChange(of: viewModel.phoneNumber) { newValue in
if !viewModel.phoneNumber.isEmpty {
viewModel.phoneNumberStartTimer()
}
}
.padding(.bottom, -20)
}
}
Expand All @@ -231,7 +213,7 @@ struct StudentSignUpView: View {
AssociationSelectButton(
text: viewModel.selectedSchool?.display() ?? "학ꡐ"
) {
isSchool.toggle()
viewModel.isPresentedSchoolSheet.toggle()
}
}

Expand All @@ -252,9 +234,9 @@ struct StudentSignUpView: View {
func inputClubSection() -> some View {
VStack(spacing: 0) {
AssociationSelectButton(
text: viewModel.selectedClub
text: viewModel.selectedClub ?? "동아리"
) {
isShowingClubSelectSheet.toggle()
viewModel.isPresentedClubSheet.toggle()
}
}
}
Expand All @@ -274,10 +256,15 @@ struct StudentSignUpView: View {
@ViewBuilder
func inputStudentInfoSection() -> some View {
VStack(spacing: 16) {
if viewModel.yearOfAdmission != nil {
if viewModel.yearOfAdmissionIsValid {
BitgouelTextField(
"ν•™λ²ˆ",
text: $viewModel.studentID,
text: Binding(
get: { viewModel.studentID },
set: { newValue in
viewModel.studentID = newValue
}
),
onSubmit: {
viewModel.parseStudentID()
}
Expand All @@ -288,8 +275,14 @@ struct StudentSignUpView: View {
BitgouelTextField(
"μž…ν•™λ…„λ„",
text: Binding(
get: { return String (viewModel.yearOfAdmission ?? 2023) },
set: { newValue in viewModel.yearOfAdmission = Int(newValue) }
get: {
guard let yearOfAdmission = viewModel.yearOfAdmission else { return "" }
return String(yearOfAdmission)
},
set: { newValue in
guard let yearOfAdmission = Int(newValue) else { return }
viewModel.yearOfAdmission = yearOfAdmission
}
)
)
.padding(.bottom, -20)
Expand Down
Loading
Loading