Skip to content

Commit 887ed50

Browse files
authored
Merge pull request #41 from YAPP-Github/TNT-142-traineeSignUp-connectionSecond
[TNT-142] 트레이니 연결 화면 작성 완료
2 parents 3f45772 + 95c2cb4 commit 887ed50

23 files changed

+969
-41
lines changed

TnT/Projects/DIContainer/Sources/DIContainer.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ private enum UserUseCaseKey: DependencyKey {
1616
}
1717

1818
private enum TraineeUseCaseKey: DependencyKey {
19-
static let liveValue: TraineeUseCase = DefaultTraineeUseCase(trainerRepository: TrainerRepositoryImpl())
19+
static let liveValue: TraineeUseCase = DefaultTraineeUseCase(
20+
trainerRepository: TrainerRepositoryImpl(),
21+
traineeRepository: TraineeRepositoryImpl()
22+
)
2023
}
2124

2225
// MARK: - DependencyValues
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// TraineeRepositoryImpl.swift
3+
// Data
4+
//
5+
// Created by 박민서 on 1/27/25.
6+
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import Foundation
10+
import Dependencies
11+
12+
import Domain
13+
14+
/// 트레이니 관련 네트워크 요청을 처리하는 TraineeRepository 구현체
15+
public struct TraineeRepositoryImpl: TraineeRepository {
16+
private let networkService: NetworkService = .shared
17+
18+
public init() {}
19+
20+
public func postConnectTrainer(_ info: TraineeConnectInfoEntity) async throws -> PostConnectTrainerResDTO {
21+
let requestDTO = PostConnectTrainerReqDTO(
22+
invitationCode: info.invitationCode,
23+
startDate: info.startDate,
24+
totalPtCount: info.totalPtCount,
25+
finishedPtCount: info.finishedPtCount
26+
)
27+
28+
return try await networkService.request(
29+
TraineeTargetType.postConnectTrainer(reqDto: requestDTO),
30+
decodingType: PostConnectTrainerResDTO.self
31+
)
32+
}
33+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//
2+
// TraineeTargetType.swift
3+
// Data
4+
//
5+
// Created by 박민서 on 1/27/25.
6+
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
import Domain
12+
13+
/// 트레이니 관련 API 요청 타입 정의
14+
public enum TraineeTargetType {
15+
/// 트레이너 연결 요청
16+
case postConnectTrainer(reqDto: PostConnectTrainerReqDTO)
17+
}
18+
19+
extension TraineeTargetType: TargetType {
20+
var baseURL: URL {
21+
let url: String = Config.apiBaseUrlDev + "/trainees"
22+
return URL(string: url)!
23+
}
24+
25+
var path: String {
26+
switch self {
27+
case .postConnectTrainer:
28+
return "/connect-trainer"
29+
}
30+
}
31+
32+
var method: HTTPMethod {
33+
switch self {
34+
case .postConnectTrainer:
35+
return .post
36+
}
37+
}
38+
39+
var task: RequestTask {
40+
switch self {
41+
case .postConnectTrainer(let reqDto):
42+
return .requestJSONEncodable(encodable: reqDto)
43+
}
44+
}
45+
46+
var headers: [String: String]? {
47+
switch self {
48+
case .postConnectTrainer:
49+
return ["Content-Type": "application/json"]
50+
}
51+
}
52+
53+
var interceptors: [any Interceptor] {
54+
return [
55+
LoggingInterceptor(),
56+
AuthTokenInterceptor(),
57+
ResponseValidatorInterceptor(),
58+
RetryInterceptor(maxRetryCount: 0)
59+
]
60+
}
61+
}
62+

TnT/Projects/Data/Sources/Network/Service/Trainer/TrainerTargetType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Foundation
1010

1111
import Domain
1212

13-
/// 사용자 관련 API 요청 타입 정의
13+
/// 트레이너 관련 API 요청 타입 정의
1414
public enum TrainerTargetType {
1515
/// 트레이너 초대코드 인증
1616
case getVerifyInvitationCode(code: String)

TnT/Projects/DesignSystem/Sources/Components/PopUp/TPopUpAlertView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public struct TPopUpAlertView: View {
2424
// 텍스트 Section
2525
VStack(spacing: 8) {
2626
Text(alertState.title)
27-
.typographyStyle(.heading4, with: .neutral900)
27+
.typographyStyle(.heading3, with: .neutral900)
2828
.multilineTextAlignment(.center)
2929
.padding(.top, 20)
3030
if let message = alertState.message {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// TraineeRequestDTO.swift
3+
// Domain
4+
//
5+
// Created by 박민서 on 1/27/25.
6+
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
/// 트레이너 연결 요청 DTO
12+
public struct PostConnectTrainerReqDTO: Encodable {
13+
/// 초대 코드
14+
public let invitationCode: String
15+
/// 시작 날짜
16+
public let startDate: String
17+
/// 총 PT 횟수
18+
public let totalPtCount: Int
19+
/// 현재 PT 횟수
20+
public let finishedPtCount: Int
21+
22+
public init(
23+
invitationCode: String,
24+
startDate: String,
25+
totalPtCount: Int,
26+
finishedPtCount: Int
27+
) {
28+
self.invitationCode = invitationCode
29+
self.startDate = startDate
30+
self.totalPtCount = totalPtCount
31+
self.finishedPtCount = finishedPtCount
32+
}
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// TraineeResponseDTO.swift
3+
// Domain
4+
//
5+
// Created by 박민서 on 1/27/25.
6+
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
/// 트레이너 연결 응답 DTO
12+
public struct PostConnectTrainerResDTO: Decodable {
13+
/// 트레이너 이름
14+
let trainerName: String
15+
/// 트레이니 이름
16+
let traineeName: String
17+
/// 트레이너 프로필 이미지 URL
18+
let trainerProfileImageUrl: String
19+
/// 트레이니 프로필 이미지 URL
20+
let traineeProfileImageUrl: String
21+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// ConnectionInfoEntity.swift
3+
// Domain
4+
//
5+
// Created by 박민서 on 1/27/25.
6+
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
/// 트레이너와 트레이니가 연결된 정보
12+
public struct ConnectionInfoEntity {
13+
/// 트레이너 이름
14+
public let trainerName: String
15+
/// 트레이니 이름
16+
public let traineeName: String
17+
/// 트레이너 프로필 이미지 URL
18+
public let trainerProfileImageUrl: URL?
19+
/// 트레이니 프로필 이미지 URL
20+
public let traineeProfileImageUrl: URL?
21+
22+
public init(trainerName: String, traineeName: String, trainerProfileImageUrl: String, traineeProfileImageUrl: String) {
23+
self.trainerName = trainerName
24+
self.traineeName = traineeName
25+
self.trainerProfileImageUrl = URL(string: trainerProfileImageUrl)
26+
self.traineeProfileImageUrl = URL(string: traineeProfileImageUrl)
27+
}
28+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// TraineeConnectInfoEntity.swift
3+
// Domain
4+
//
5+
// Created by 박민서 on 1/27/25.
6+
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
/// 트레이너 연결을 위한 도메인 모델
12+
public struct TraineeConnectInfoEntity {
13+
/// 초대 코드
14+
public let invitationCode: String
15+
/// 시작 날짜
16+
public let startDate: String
17+
/// 총 PT 횟수
18+
public let totalPtCount: Int
19+
/// 현재 PT 횟수
20+
public let finishedPtCount: Int
21+
}

TnT/Projects/Domain/Sources/Entity/UserSignUpInfo.swift renamed to TnT/Projects/Domain/Sources/Entity/UserSignUpInfoEntity.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// UserSignUpInfo.swift
2+
// UserSignUpInfoEntity.swift
33
// Domain
44
//
55
// Created by 박민서 on 1/24/25.
@@ -9,7 +9,7 @@
99
import Foundation
1010

1111
/// 회원 가입 시 입력되는 기본 정보 구조체
12-
public struct UserSignUpInfo: Equatable {
12+
public struct UserSignUpInfoEntity: Equatable {
1313
/// 사용자 유형 (트레이너 / 트레이니)
1414
public var userType: UserType
1515
/// 프로필 이미지 (옵션)

0 commit comments

Comments
 (0)