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-213] 트레이너 회원목록 페이지 작성 #62

Merged
merged 4 commits into from
Feb 10, 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
9 changes: 9 additions & 0 deletions TnT/Projects/DIContainer/Sources/DIContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ private enum SocialUseCaseKey: DependencyKey {
static let liveValue: SocialLoginUseCase = SocialLoginUseCase(socialLoginRepository: SocialLogInRepositoryImpl(loginManager: SNSLoginManager()))
}

private enum TrainerUseCaseRepoKey: DependencyKey {
static let liveValue: TrainerRepository = DefaultTrainerUseCase(trainerRepository: TrainerRepositoryImpl())
}

private enum KeyChainManagerKey: DependencyKey {
static let liveValue: KeyChainManager = keyChainManager
}
Expand Down Expand Up @@ -60,4 +64,9 @@ public extension DependencyValues {
get { self[SocialUseCaseKey.self] }
set { self[SocialUseCaseKey.self] = newValue }
}

var trainerRepoUseCase: TrainerRepository {
get { self[TrainerUseCaseRepoKey.self] }
set { self[TrainerUseCaseRepoKey.self] = newValue }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,11 @@ public struct TrainerRepositoryImpl: TrainerRepository {
decodingType: GetDateSessionListDTO.self
)
}

public func getMembersList() async throws -> GetMembersListDTO {
return try await networkService.request(
TrainerTargetType.getMemebersList,
decodingType: GetMembersListDTO.self
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public enum TrainerTargetType {
case getDateLessionList(date: String)
/// 트레이너 초대코드 재발급
case getReissuanceInvitationCode
/// 회원 조희
case getMemebersList
}

extension TrainerTargetType: TargetType {
Expand All @@ -38,6 +40,8 @@ extension TrainerTargetType: TargetType {
return "/lessions/\(date)"
case .getReissuanceInvitationCode:
return "/invitation-code/reissue"
case .getMemebersList:
return "/members"
}
}

Expand All @@ -51,6 +55,8 @@ extension TrainerTargetType: TargetType {
return .get
case .getReissuanceInvitationCode:
return .put
case .getMemebersList:
return .get
}
}

Expand All @@ -64,6 +70,8 @@ extension TrainerTargetType: TargetType {
return .requestPlain
case .getReissuanceInvitationCode:
return .requestPlain
case .getMemebersList:
return .requestPlain
}
}

Expand All @@ -77,6 +85,8 @@ extension TrainerTargetType: TargetType {
return ["Content-Type": "application/json"]
case .getReissuanceInvitationCode:
return ["Content-Type": "application/json"]
case .getMemebersList:
return ["Content-Type": "application/json"]
}
}

Expand Down
22 changes: 21 additions & 1 deletion TnT/Projects/DesignSystem/Sources/Navigation/TNavigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ public struct TNavigation: View {
Rectangle()
.fill(Color.clear)
.frame(width: 32, height: 32)

case .LTextRButtonTitle(let leftTitle, let pointText, _):
HStack(spacing: 6){
Text(leftTitle)
.typographyStyle(.heading2, with: .neutral900)
if let pointText = pointText {
Text(pointText)
.typographyStyle(.heading2, with: .red500)
} else { EmptyView() }
}
}
}

Expand All @@ -78,7 +88,7 @@ public struct TNavigation: View {
Text(centerTitle)
.typographyStyle(.heading4, with: .neutral900)
.frame(maxWidth: .infinity, alignment: .center)
case .LButton:
case .LButton, .LTextRButtonTitle(_, _, _):
EmptyView()
}
}
Expand All @@ -105,6 +115,14 @@ public struct TNavigation: View {
Rectangle()
.fill(Color.clear)
.frame(width: 32, height: 32)

case .LTextRButtonTitle(_, _, let rightButton):
TButton(
title: rightButton,
config: .small,
state: .disable(.gray(isEnabled: true))) {
rightAction?()
}
}
}
}
Expand Down Expand Up @@ -143,4 +161,6 @@ public enum TNavigationCase {
case Title(centerTitle: String)
/// 왼쪽 이미지
case LButton(leftImage: ImageResource)
/// 왼쪽 텍스트, 오른쪽 버튼
case LTextRButtonTitle(leftTitle: String, pointText: String?, rightButton: String)
}
59 changes: 59 additions & 0 deletions TnT/Projects/Domain/Sources/DTO/Trainer/GetMembersListDTO.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// GetMembersListDTO.swift
// Domain
//
// Created by 박서연 on 2/8/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// 트레이너 회원 조회 DTO
public struct GetMembersListDTO: Decodable {
/// 이름
public let name: String
/// 이메일
public let email: String
/// 프로필 사진
public let profileImageUrl: String
/// 생년월일
public let birthday: String?
/// 유저 타입 (트레이너/트레이니)
public let memberType: String
/// 소셜 로그인 타입
public let socialType: String
/// 관리중인 회원의 수
public let managementMember: Int
/// 함께했던 회원의 수
public let fellowMember: Int
/// 트레이너 ID
public let trainerId: String
/// 트레이니 키
public let height: Double?
/// 트레이니 무게
public let weight: Double?
/// 주의사항
public let cautionNote: String?
/// PT 목표
public let goalContents: [String]
}

public extension GetMembersListDTO {
public static func toEntity(resEntity: GetMembersListDTO) -> GetMembersListEntity {
return GetMembersListEntity(
name: resEntity.name,
email: resEntity.email,
profileImageUrl: resEntity.profileImageUrl,
birthday: resEntity.birthday ?? "",
memberType: resEntity.memberType,
socialType: resEntity.socialType,
managementMember: resEntity.managementMember,
fellowMember: resEntity.fellowMember,
trainerId: resEntity.trainerId,
height: resEntity.height ?? 0.0,
weight: resEntity.weight ?? 0.0,
cautionNote: resEntity.cautionNote ?? "",
goalContents: resEntity.goalContents
)
}
}
92 changes: 92 additions & 0 deletions TnT/Projects/Domain/Sources/Entity/GetMembersListEntity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
//
// GetMembersListEntity.swift
// Domain
//
// Created by 박서연 on 2/8/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

/// 트레이너 회원 조회 DTO
public struct GetMembersListEntity: Encodable, Equatable {
/// ID 값 활용을 위한 추가
public let id: String
/// 이름
public let name: String
/// 이메일
public let email: String
/// 프로필 사진
public let profileImageUrl: String
/// 생년월일
public let birthday: String?
/// 유저 타입 (트레이너/트레이니)
public let memberType: String
/// 소셜 로그인 타입
public let socialType: String
/// 관리중인 회원의 수
public let managementMember: Int
/// 함께했던 회원의 수
public let fellowMember: Int
/// 트레이너 ID
public let trainerId: String
/// 트레이니 키
public let height: Double?
/// 트레이니 무게
public let weight: Double?
/// 주의사항
public let cautionNote: String?
/// PT 목표
public let goalContents: [String]

public init(
id: String = UUID().uuidString,
name: String,
email: String,
profileImageUrl: String,
birthday: String?,
memberType: String,
socialType: String,
managementMember: Int,
fellowMember: Int,
trainerId: String,
height: Double?,
weight: Double?,
cautionNote: String?,
goalContents: [String]
) {
self.id = id
self.name = name
self.email = email
self.profileImageUrl = profileImageUrl
self.birthday = birthday
self.memberType = memberType
self.socialType = socialType
self.managementMember = managementMember
self.fellowMember = fellowMember
self.trainerId = trainerId
self.height = height
self.weight = weight
self.cautionNote = cautionNote
self.goalContents = goalContents
}
}

extension GetMembersListEntity {
static func toDTO(entity: GetMembersListEntity) -> GetMembersListDTO {
return GetMembersListDTO(
name: entity.name,
email: entity.email,
profileImageUrl: entity.profileImageUrl,
birthday: entity.birthday ?? "",
memberType: entity.memberType,
socialType: entity.socialType,
managementMember: entity.managementMember,
fellowMember: entity.fellowMember,
trainerId: entity.trainerId,
height: entity.height ?? 0.0,
weight: entity.weight ?? 0.0,
cautionNote: entity.cautionNote ?? "",
goalContents: entity.goalContents)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ public protocol TrainerRepository {

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

/// 회원 조희
func getMembersList() async throws -> GetMembersListDTO
}
39 changes: 39 additions & 0 deletions TnT/Projects/Domain/Sources/UseCase/TrainerUseCase.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// TrainerUseCase.swift
// Domain
//
// Created by 박서연 on 2/8/25.
// Copyright © 2025 yapp25thTeamTnT. All rights reserved.
//

import Foundation

// MARK: - TrainerUseCase Default 구현체
public struct DefaultTrainerUseCase: TrainerRepository {

private let trainerRepository: TrainerRepository

public init (trainerRepository: TrainerRepository) {
self.trainerRepository = trainerRepository
}

public func getVerifyInvitationCode(code: String) async throws -> GetVerifyInvitationCodeResDTO {
return try await trainerRepository.getVerifyInvitationCode(code: code)
}

public func getTheFirstInvitationCode() async throws -> GetTheFirstInvitationCodeDTO {
return try await trainerRepository.getTheFirstInvitationCode()
}

public func getReissuanceInvitationCode() async throws -> GetReissuanceInvitationCodeDTO {
return try await trainerRepository.getReissuanceInvitationCode()
}

public func getDateSessionList(date: String) async throws -> GetDateSessionListDTO {
return try await trainerRepository.getDateSessionList(date: date)
}

public func getMembersList() async throws -> GetMembersListDTO {
return try await trainerRepository.getMembersList()
}
}
Loading