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

[TNT-210] 트레이너 마이페이지, 홈 캘린더 화면 작성 #54

Merged
merged 5 commits into from
Feb 4, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Domain

/// 트레이너 관련 네트워크 요청을 처리하는 TrainerRepository 구현체
public struct TrainerRepositoryImpl: TrainerRepository {

private let networkService: NetworkService = .shared

public init() {}
Expand All @@ -23,4 +24,25 @@ public struct TrainerRepositoryImpl: TrainerRepository {
decodingType: GetVerifyInvitationCodeResDTO.self
)
}

public func getTheFirstInvitationCode() async throws -> GetTheFirstInvitationCodeDTO {
return try await networkService.request(
TrainerTargetType.getFirstInvitationCode,
decodingType: GetTheFirstInvitationCodeDTO.self
)
}

public func getReissuanceInvitationCode() async throws -> GetReissuanceInvitationCodeDTO {
return try await networkService.request(
TrainerTargetType.getReissuanceInvitationCode,
decodingType: GetReissuanceInvitationCodeDTO.self
)
}

public func getDateSessionList(date: String) async throws -> GetDateSessionListDTO {
return try await networkService.request(
TrainerTargetType.getDateLessionList(date: date),
decodingType: GetDateSessionListDTO.self
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import Domain
public enum TrainerTargetType {
/// 트레이너 초대코드 인증
case getVerifyInvitationCode(code: String)
/// 트레이너 초대코드 불러오기
case getFirstInvitationCode
/// 트레이너 캘린더, 특정 날짜의 PT 리스트 불러오기
case getDateLessionList(date: String)
/// 트레이너 초대코드 재발급
case getReissuanceInvitationCode
}

extension TrainerTargetType: TargetType {
Expand All @@ -26,27 +32,51 @@ extension TrainerTargetType: TargetType {
switch self {
case .getVerifyInvitationCode(let code):
return "/invitation-code/verify/\(code)"
case .getFirstInvitationCode:
return "/invitation-code"
case .getDateLessionList(let date):
return "/lessions/\(date)"
case .getReissuanceInvitationCode:
return "/invitation-code/reissue"
}
}

var method: HTTPMethod {
switch self {
case .getVerifyInvitationCode:
return .get
case .getFirstInvitationCode:
return .get
case .getDateLessionList:
return .get
case .getReissuanceInvitationCode:
return .put
}
}

var task: RequestTask {
switch self {
case .getVerifyInvitationCode:
return .requestPlain
case .getFirstInvitationCode:
return .requestPlain
case .getDateLessionList:
return .requestPlain
case .getReissuanceInvitationCode:
return .requestPlain
}
}

var headers: [String: String]? {
switch self {
case .getVerifyInvitationCode:
return ["Content-Type": "application/json"]
case .getFirstInvitationCode:
return nil
case .getDateLessionList:
return ["Content-Type": "application/json"]
case .getReissuanceInvitationCode:
return ["Content-Type": "application/json"]
Comment on lines 72 to +79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

참고용으로 올려드립니다! 아래와 같이 작성하면 조금? 더 편합니다 갠취인것 같아요.

case .getVerifyInvitationCode, .getDateLessionList, .getReissuanceInvitationCode:
    return ["Content-Type": "application/json"]

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "icn_plus_empty.svg",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public extension ImageResource {
static let icnStarSmile: ImageResource = DesignSystemAsset.icnStarSmile.imageResource
static let icnWriteBlackFilled: ImageResource = DesignSystemAsset.icnWriteBlackFilled.imageResource
static let icnPlus: ImageResource = DesignSystemAsset.icnPlus.imageResource
static let icnPlusEmpty: ImageResource = DesignSystemAsset.icnPlusEmpty.imageResource
static let icnAlarm: ImageResource = DesignSystemAsset.icnAlarm.imageResource
static let icnCalendar: ImageResource = DesignSystemAsset.icnCalendar.imageResource
static let icnDelete24px: ImageResource = DesignSystemAsset.icnDelete24.imageResource
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// GetReissuanceInvitationCodeDTO.swift
// Domain
//
// Created by 박서연 on 2/4/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

public struct GetReissuanceInvitationCodeDTO: Decodable {
public let trainerId: String
public let invitationCode: String

public init(
trainerId: String,
invitationCode: String
) {
self.trainerId = trainerId
self.invitationCode = invitationCode
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// GetTheFirstInvitationCodeDTO.swift
// Domain
//
// Created by 박서연 on 2/4/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// 트레이너의 최초 연결 코드
public struct GetTheFirstInvitationCodeDTO: Decodable {
public let invitationCode: String

public init(invitationCode: String) {
self.invitationCode = invitationCode
}
}
100 changes: 100 additions & 0 deletions TnT/Projects/Domain/Sources/DTO/Trainer/TrainerHomeResponseDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// TrainerHomeResponseDTO.swift
// Domain
//
// Created by 박서연 on 2/4/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// 특정 날짜의 PT 리스트 불러오기
public struct GetDateSessionListDTO: Decodable {
public let count: Int
public let date: String
public let lessons: [SessonDTO]

public init(
count: Int,
date: String,
lessons: [SessonDTO]
) {
self.count = count
self.date = date
self.lessons = lessons
}
}

public struct SessonDTO: Decodable {
public let ptLessonId: String
public let traineeId: String
public let traineeName: String
public let session: Int
public let startTime: String
public let endTime: String
public let isCompleted: Bool

public init(
ptLessonId: String,
traineeId: String,
traineeName: String,
session: Int,
startTime: String,
endTime: String,
isCompleted: Bool
) {
self.ptLessonId = ptLessonId
self.traineeId = traineeId
self.traineeName = traineeName
self.session = session
self.startTime = startTime
self.endTime = endTime
self.isCompleted = isCompleted
}
}

public struct GetDateSessionListEntity: Equatable, Encodable {
public let id = UUID().uuidString
public let count: Int
public let date: String
public let lessons: [SessonEntity]

public init(
count: Int,
date: String,
lessons: [SessonEntity]
) {
self.count = count
self.date = date
self.lessons = lessons
}
}

public struct SessonEntity: Equatable, Encodable {
public let id = UUID().uuidString
public let ptLessonId: String
Comment on lines +73 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기에서 id는 어떤 역할을 위한걸까요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Foreach에서 id값을 활용하기 위해서입니다!

@ViewBuilder
    private func RecordList() -> some View {
        VStack {
            if let record = store.tappedsessionInfo {
                ForEach(record.lessons, id: \.id) { record in
                    SessionCellView(session: record) {
                        send(.tapSessionCompleted(id: record.ptLessonId))
                    }
                }
            } else {
                RecordEmptyView()
            }
        }
        .padding(.horizontal, 20)
    }

Copy link
Contributor

@FpRaArNkK FpRaArNkK Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아하 그런거라면 API에서 ResponseDTO -> SessionEntity로 Mapping할 때
DTO에서 받아오는 id를 entity로 가져올 수 있게
init에 추가해주시면 좋을 것 같아요! 기본값은 UUID 넣어주는 방향으로요.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮 그렇네요. 수정해서 반영하고 머지하겠습니다!

public let traineeId: String
public let traineeName: String
public let session: Int
public let startTime: String
public let endTime: String
public var isCompleted: Bool

public init(
ptLessonId: String,
traineeId: String,
traineeName: String,
session: Int,
startTime: String,
endTime: String,
isCompleted: Bool
) {
self.ptLessonId = ptLessonId
self.traineeId = traineeId
self.traineeName = traineeName
self.session = session
self.startTime = startTime
self.endTime = endTime
self.isCompleted = isCompleted
}
}
2 changes: 2 additions & 0 deletions TnT/Projects/Domain/Sources/Policy/TDateFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public enum TDateFormat: String {
case M월_d일 = "M월 d일"
/// "01월 10일 화요일"
case MM월_dd일_EEEE = "MM월 dd일 EEEE"
/// "1월 10일 화요일"
case M월_d일_EEEE = "M월 d일 EEEE"
/// "EE"
case EE = "EE"
/// "오후 17:00" (시간 포맷)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ public protocol TrainerRepository {
/// - Returns: 검증 성공 시, 초대 코드 정보가 포함된 응답 DTO (`GetVerifyInvitationCodeResDTO`)
/// - Throws: 네트워크 오류 또는 유효하지 않은 초대 코드로 인한 서버 오류 발생 가능
func getVerifyInvitationCode(code: String) async throws -> GetVerifyInvitationCodeResDTO

/// 트레이너 최초 초대 코드 불러오기
func getTheFirstInvitationCode() async throws -> GetTheFirstInvitationCodeDTO

/// 트레이너 초대 코드 코드 재발급
func getReissuanceInvitationCode() async throws -> GetReissuanceInvitationCodeDTO

/// 트레이너 캘린더에 특정 날짜의 수업 정보 가져오기
func getDateSessionList(date: String) async throws -> GetDateSessionListDTO
}
Loading