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

[WEAV-139] 프로필 정보 수정 기능 구현 #50

Merged
merged 13 commits into from
Nov 24, 2024
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
6 changes: 3 additions & 3 deletions OpenApiGenerator/Sources/OpenapiGenerated/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -659,8 +659,8 @@ public struct Client: APIProtocol {
///
/// 현재 로그인한 사용자의 프로필 정보를 수정합니다. (이름, 직군, 직장, 활동 지역)
///
/// - Remark: HTTP `PATCH /users/my`.
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)`.
/// - Remark: HTTP `PUT /users/my`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)`.
public func updateMyUserInfo(_ input: Operations.updateMyUserInfo.Input) async throws -> Operations.updateMyUserInfo.Output {
try await client.send(
input: input,
Expand All @@ -672,7 +672,7 @@ public struct Client: APIProtocol {
)
var request: HTTPTypes.HTTPRequest = .init(
soar_path: path,
method: .patch
method: .put
)
suppressMutabilityWarning(&request)
converter.setAcceptHeader(
Expand Down
50 changes: 29 additions & 21 deletions OpenApiGenerator/Sources/OpenapiGenerated/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public protocol APIProtocol: Sendable {
///
/// 현재 로그인한 사용자의 프로필 정보를 수정합니다. (이름, 직군, 직장, 활동 지역)
///
/// - Remark: HTTP `PATCH /users/my`.
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)`.
/// - Remark: HTTP `PUT /users/my`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)`.
func updateMyUserInfo(_ input: Operations.updateMyUserInfo.Input) async throws -> Operations.updateMyUserInfo.Output
/// 프로필 위젯 추가 및 수정
///
Expand Down Expand Up @@ -183,8 +183,8 @@ extension APIProtocol {
///
/// 현재 로그인한 사용자의 프로필 정보를 수정합니다. (이름, 직군, 직장, 활동 지역)
///
/// - Remark: HTTP `PATCH /users/my`.
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)`.
/// - Remark: HTTP `PUT /users/my`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)`.
public func updateMyUserInfo(
headers: Operations.updateMyUserInfo.Input.Headers = .init(),
body: Operations.updateMyUserInfo.Input.Body
Expand Down Expand Up @@ -588,39 +588,47 @@ public enum Components {
/// 사용자 이름
///
/// - Remark: Generated from `#/components/schemas/UpdateMyUserInfoRequest/name`.
public var name: Swift.String?
public var name: Swift.String
/// - Remark: Generated from `#/components/schemas/UpdateMyUserInfoRequest/jobOccupation`.
public var jobOccupation: Components.Schemas.JobOccupation?
public var jobOccupation: Components.Schemas.JobOccupation
/// 사용자의 회사 ID
///
/// - Remark: Generated from `#/components/schemas/UpdateMyUserInfoRequest/companyId`.
public var companyId: Swift.String?
/// 같은 회사에 근무하는 파트너를 허용하는지 여부 (companyID가 없을 경우 null)
///
/// - Remark: Generated from `#/components/schemas/UpdateMyUserInfoRequest/allowSameCompany`.
public var allowSameCompany: Swift.Bool?
/// 사용자의 활동 지역 목록 ID 리스트
///
/// - Remark: Generated from `#/components/schemas/UpdateMyUserInfoRequest/locationIds`.
public var locationIds: [Swift.String]?
public var locationIds: [Swift.String]
/// Creates a new `UpdateMyUserInfoRequest`.
///
/// - Parameters:
/// - name: 사용자 이름
/// - jobOccupation:
/// - companyId: 사용자의 회사 ID
/// - allowSameCompany: 같은 회사에 근무하는 파트너를 허용하는지 여부 (companyID가 없을 경우 null)
/// - locationIds: 사용자의 활동 지역 목록 ID 리스트
public init(
name: Swift.String? = nil,
jobOccupation: Components.Schemas.JobOccupation? = nil,
name: Swift.String,
jobOccupation: Components.Schemas.JobOccupation,
companyId: Swift.String? = nil,
locationIds: [Swift.String]? = nil
allowSameCompany: Swift.Bool? = nil,
locationIds: [Swift.String]
) {
self.name = name
self.jobOccupation = jobOccupation
self.companyId = companyId
self.allowSameCompany = allowSameCompany
self.locationIds = locationIds
}
public enum CodingKeys: String, CodingKey {
case name
case jobOccupation
case companyId
case allowSameCompany
case locationIds
}
}
Expand Down Expand Up @@ -2367,12 +2375,12 @@ public enum Operations {
///
/// 현재 로그인한 사용자의 프로필 정보를 수정합니다. (이름, 직군, 직장, 활동 지역)
///
/// - Remark: HTTP `PATCH /users/my`.
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)`.
/// - Remark: HTTP `PUT /users/my`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)`.
public enum updateMyUserInfo {
public static let id: Swift.String = "updateMyUserInfo"
public struct Input: Sendable, Hashable {
/// - Remark: Generated from `#/paths/users/my/PATCH/header`.
/// - Remark: Generated from `#/paths/users/my/PUT/header`.
public struct Headers: Sendable, Hashable {
public var accept: [OpenAPIRuntime.AcceptHeaderContentType<Operations.updateMyUserInfo.AcceptableContentType>]
/// Creates a new `Headers`.
Expand All @@ -2384,9 +2392,9 @@ public enum Operations {
}
}
public var headers: Operations.updateMyUserInfo.Input.Headers
/// - Remark: Generated from `#/paths/users/my/PATCH/requestBody`.
/// - Remark: Generated from `#/paths/users/my/PUT/requestBody`.
@frozen public enum Body: Sendable, Hashable {
/// - Remark: Generated from `#/paths/users/my/PATCH/requestBody/content/application\/json`.
/// - Remark: Generated from `#/paths/users/my/PUT/requestBody/content/application\/json`.
case json(Components.Schemas.UpdateMyUserInfoRequest)
}
public var body: Operations.updateMyUserInfo.Input.Body
Expand All @@ -2405,9 +2413,9 @@ public enum Operations {
}
@frozen public enum Output: Sendable, Hashable {
public struct Ok: Sendable, Hashable {
/// - Remark: Generated from `#/paths/users/my/PATCH/responses/200/content`.
/// - Remark: Generated from `#/paths/users/my/PUT/responses/200/content`.
@frozen public enum Body: Sendable, Hashable {
/// - Remark: Generated from `#/paths/users/my/PATCH/responses/200/content/application\/json`.
/// - Remark: Generated from `#/paths/users/my/PUT/responses/200/content/application\/json`.
case json(Components.Schemas.UpdateMyUserInfoResponse)
/// The associated value of the enum case if `self` is `.json`.
///
Expand All @@ -2434,7 +2442,7 @@ public enum Operations {
}
/// 수정 성공
///
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)/responses/200`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)/responses/200`.
///
/// HTTP response code: `200 ok`.
case ok(Operations.updateMyUserInfo.Output.Ok)
Expand All @@ -2457,7 +2465,7 @@ public enum Operations {
}
/// 잘못된 요청
///
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)/responses/400`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)/responses/400`.
///
/// HTTP response code: `400 badRequest`.
case badRequest(Components.Responses.BadRequest)
Expand All @@ -2480,7 +2488,7 @@ public enum Operations {
}
/// 인증 실패 (토큰 만료 또는 유효하지 않은 토큰)
///
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)/responses/401`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)/responses/401`.
///
/// HTTP response code: `401 unauthorized`.
case unauthorized(Components.Responses.Unauthorized)
Expand All @@ -2503,7 +2511,7 @@ public enum Operations {
}
/// 서버 오류
///
/// - Remark: Generated from `#/paths//users/my/patch(updateMyUserInfo)/responses/500`.
/// - Remark: Generated from `#/paths//users/my/put(updateMyUserInfo)/responses/500`.
///
/// HTTP response code: `500 internalServerError`.
case internalServerError(Components.Responses.InternalServerError)
Expand Down
2 changes: 1 addition & 1 deletion OpenApiGenerator/Sources/openapi-generator-cli/3days-oas
Submodule 3days-oas updated 1 files
+10 −1 openapi.yaml
22 changes: 22 additions & 0 deletions Projects/App/Sources/Navigation/NavigationStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ extension PathType {
case .dreamPartnerDistance(let input):
DreamPartnerDistanceView(input)
}

case .editProfile(let subView):
switch subView {
case .profileImage(let input):
EmptyView()
case .jobOccupation(let input):
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
EditProfileJobView(input)
case .company(let input):
EditProfileCompanyView(userInfo: input)
case .region(let input):
EditProfileRegionView(userInfo: input)
}

case .editDreamPartner(let subView):
switch subView {
case .ageRange(let userInfo):
EmptyView()
case .jobOccupation(let userInfo):
EmptyView()
case .distance(let userInfo):
EmptyView()
}
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
34 changes: 32 additions & 2 deletions Projects/Core/CommonKit/Sources/Path/PathTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public enum PathType: Hashable {
// Features
case home(UserInfo?)
case signUp(SignUpSubViewType)
case editProfile(EditProfileViewType)
case editDreamPartner(EditDreamPartnerViewType)
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved

#if STAGING || DEBUG
public static var debugPreviewTypes: [PathType] = [
Expand Down Expand Up @@ -64,8 +66,8 @@ public enum PathType: Hashable {
case .intro: return "메인"

case .home: return "홈"
case .signUp(let subType):
switch subType {
case .signUp(let subView):
switch subView {
case .authPhoneInput: return "전화번호 입력"
case .authPhoneVerify: return "전화번호 인증"
case .authAgreement: return "이용 약관"
Expand All @@ -85,6 +87,21 @@ public enum PathType: Hashable {
case .dreamPartnerJobOccupation: return "이상형 직업"
case .dreamPartnerDistance: return "이상형과의 거리"
}

case .editProfile(let subView):
switch subView {
case .profileImage: return "프로필 이미지 수정"
case .jobOccupation: return "직군 수정"
case .company: return "직장 수정"
case .region: return "활동 지역 수정"
}

case .editDreamPartner(let subView):
switch subView {
case .ageRange: return "이상형 나이대 수정"
case .jobOccupation: return "이상형 직군 수정"
case .distance: return "이상형과의 거리 수정"
}
}
}
}
Expand Down Expand Up @@ -148,3 +165,16 @@ public enum SignUpSubViewType: Hashable {
}
}
}

public enum EditProfileViewType {
case profileImage(UserInfo)
case jobOccupation(UserInfo)
case company(UserInfo)
case region(UserInfo)
}

public enum EditDreamPartnerViewType {
case ageRange(UserInfo)
case jobOccupation(UserInfo)
case distance(UserInfo)
}
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public protocol ProfileServiceProtocol {
func requestDeleteProfileWidget(
widgetType: Components.Schemas.ProfileWidgetType
) async throws

func requestPutUserInfo(userInfo: UserInfo) async throws
}

public final class ProfileService {
Expand Down Expand Up @@ -53,4 +55,24 @@ extension ProfileService: ProfileServiceProtocol {
)
_ = try response.noContent
}

public func requestPutUserInfo(userInfo: UserInfo) async throws {
guard let jobOccupation = userInfo.profile.jobOccupationDTO else {
return
}
let result = try await client.updateMyUserInfo(
.init(
body: .json(
.init(
name: userInfo.name,
jobOccupation: jobOccupation,
companyId: userInfo.profile.companyId,
allowSameCompany: userInfo.dreamPartner.allowSameCompany,
locationIds: userInfo.profile.locations.map { $0.id }
)
)
)
)
_ = try result.ok
}
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import OpenapiGenerated
import CoreKit
import Model

public final class ProfileServiceMock: ProfileServiceProtocol {
public init() {}
Expand All @@ -27,4 +28,9 @@ public final class ProfileServiceMock: ProfileServiceProtocol {
print("✅ [ProfileServiceMock] requestDeleteProfileWidget 성공!")
return
}

public func requestPutUserInfo(userInfo: UserInfo) async throws {
print("✅ [ProfileServiceMock] requestPutUserInfo 성공!")
return
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,24 @@ public struct DropDownPicker<Content: View>: View {
LazyVStack(alignment: .leading, spacing: 0) {
ForEach(0 ..< dataSources.count, id: \.self) { index in
let item = dataSources[index]
Button(action: {
tapHandler?(index)

HStack(spacing: 16) {
Text(item.name)
.typography(.regular_14)
.multilineTextAlignment(.leading)
Spacer()
}
.foregroundStyle(DesignCore.Colors.grey500)
.frame(height: itemSize)
.padding(.horizontal, 16)
.background(.white)
.containerShape(Rectangle())
coderabbitai[bot] marked this conversation as resolved.
Show resolved Hide resolved
.onTapGesture {
withAnimation {
showDropDown.toggle()
tapHandler?(index)
}
}, label: {
HStack(spacing: 16) {
Text(item.name)
.typography(.regular_14)
.multilineTextAlignment(.leading)
Spacer()
}
.foregroundStyle(DesignCore.Colors.grey500)
.frame(height: itemSize)
.padding(.horizontal, 16)
.background(.white)
})
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
Loading
Loading