From cce539ad499af57ad606259557880e09050f91bf Mon Sep 17 00:00:00 2001 From: Roy Date: Thu, 19 Nov 2026 17:23:15 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=9C=EB=B2=84=20v3.0.4=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EC=9D=91=EB=8B=B5=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=EC=9D=84=20=EC=95=B1=EC=97=90=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 멤버 수: activeMemberCount 를 받아 "멤버 N명" 표시에 사용 (memberCount 는 사용 좌석 수로 유지) - AI 토론 철학자 이미지: 서버 philosopher.imageUrl 우선 사용 (이름·얼굴 불일치 수정) - 커스텀 배틀 태그: 클래스 배틀 상세 battle.categoryTags 를 투표 화면 카테고리로 표시 - 이용권 코드: PKE+6자리(9자) 입력 제한, 예시 문구 변경, TICKET_429_LOCKED 5회 잠금 안내 - 참여 오류: CLASS_409_TICKET_ENDED 를 마감과 다른 문구로 구분 Claude-Session: https://claude.ai/code/session_012p64qYTmqHhkJDFnd2C6KB --- .../Entity/Battle/ClassBattleDetail.swift | 6 ++++- .../Sources/Entity/Debate/ClassDebate.swift | 3 +++ .../Sources/Entity/Error/ClassError.swift | 4 +++- .../Entity/Error/ClassTicketError.swift | 3 +++ .../Entity/Room/ClassJoinPreview.swift | 4 ++++ .../Sources/Entity/Room/ClassRoom.swift | 5 +++++ .../Default/MockClassRepository.swift | 1 + .../Model/DTO/ClassBattleSessionDTO.swift | 5 +++++ .../Sources/Model/DTO/ClassDebateDTO.swift | 1 + .../Sources/Model/DTO/ClassroomDataDTO.swift | 3 +++ .../Model/Mapper/ClassBattleSessionDTO+.swift | 3 ++- .../Model/Mapper/ClassDebateDTO+.swift | 2 ++ .../Model/Mapper/ClassroomDataDTO+.swift | 3 +++ .../Sources/Repository/ClassErrorMapper.swift | 3 ++- .../ClassRepositoryImpl+Ticket.swift | 1 + .../Sources/ClassErrorMappingTests.swift | 2 +- .../Reducer/ClassAIChatFeature.swift | 4 +++- .../Reducer/ClassBattleFlowFeature.swift | 4 +++- .../ClassDetail/View/ClassDetailView.swift | 2 +- .../Reducer/ClassMemberFeature.swift | 4 ++-- .../Model/ClassTicketRegisterNotice.swift | 3 +++ .../Reducer/ClassTicketFeature.swift | 8 +++++++ .../ClassTicket/View/ClassTicketView.swift | 2 +- .../View/Components/MyClassRoomCard.swift | 2 +- .../Tests/Sources/ClassTicketTests.swift | 22 +++++++++++++++++-- .../Sources/Alert/CustomAlertState.swift | 4 ++++ 26 files changed, 90 insertions(+), 14 deletions(-) diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Battle/ClassBattleDetail.swift b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Battle/ClassBattleDetail.swift index 9f6cf482..cdade3ed 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Battle/ClassBattleDetail.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Battle/ClassBattleDetail.swift @@ -12,6 +12,8 @@ public struct ClassBattleDetail: Equatable, Identifiable, Sendable { public let participantsCount: Int public let audioDuration: Int public let options: [ClassBattleOption] + /// 카테고리 태그 이름(예: `철학`). 커스텀 배틀도 서버가 주제 카테고리를 태그로 붙인다. + public let categoryTags: [String] public init( id: Int, @@ -24,7 +26,8 @@ public struct ClassBattleDetail: Equatable, Identifiable, Sendable { currentStep: ClassBattleStep, participantsCount: Int, audioDuration: Int, - options: [ClassBattleOption] + options: [ClassBattleOption], + categoryTags: [String] = [] ) { self.id = id self.title = title @@ -37,5 +40,6 @@ public struct ClassBattleDetail: Equatable, Identifiable, Sendable { self.participantsCount = participantsCount self.audioDuration = audioDuration self.options = options + self.categoryTags = categoryTags } } diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Debate/ClassDebate.swift b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Debate/ClassDebate.swift index 2927df6a..5cf49fb4 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Debate/ClassDebate.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Debate/ClassDebate.swift @@ -7,6 +7,7 @@ public struct ClassDebate: Equatable, Sendable { public let canReply: Bool public let canRetry: Bool public let philosopherName: String + public let philosopherImageURL: URL? public let participantOptionTitle: String public let opponentOptionTitle: String public let messages: [ClassDebateMessage] @@ -21,6 +22,7 @@ public struct ClassDebate: Equatable, Sendable { canReply: Bool, canRetry: Bool, philosopherName: String, + philosopherImageURL: URL? = nil, participantOptionTitle: String, opponentOptionTitle: String, messages: [ClassDebateMessage], @@ -34,6 +36,7 @@ public struct ClassDebate: Equatable, Sendable { self.canReply = canReply self.canRetry = canRetry self.philosopherName = philosopherName + self.philosopherImageURL = philosopherImageURL self.participantOptionTitle = participantOptionTitle self.opponentOptionTitle = opponentOptionTitle self.messages = messages diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassError.swift b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassError.swift index 752081ab..126f4be4 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassError.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassError.swift @@ -10,6 +10,7 @@ import Foundation public enum ClassError: LocalizedError, Equatable, Sendable { case invalidCode case closed + case ticketEnded case alreadyJoined case duplicateName case accessDenied @@ -42,7 +43,8 @@ public enum ClassError: LocalizedError, Equatable, Sendable { public var message: String { switch self { case .invalidCode: return "참여 코드를 다시 확인해 주세요." - case .closed: return "종료된 클래스입니다." + case .closed: return "참여 기간이 마감된 클래스입니다." + case .ticketEnded: return "이용 기간이 끝난 클래스입니다." case .alreadyJoined: return "이미 참여한 클래스입니다." case .duplicateName: return "이미 사용 중인 이름이에요." case .accessDenied: return "클래스 결과를 볼 권한이 없어요." diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassTicketError.swift b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassTicketError.swift index 305d5f62..77c597fe 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassTicketError.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Error/ClassTicketError.swift @@ -7,6 +7,8 @@ public enum ClassTicketError: LocalizedError, Equatable, Sendable { case claimed case activeTicket case notFound + /// 없는 코드를 1시간 안에 5번 넣어 1시간 동안 입력이 막힘(`TICKET_429_LOCKED`). + case locked case invalidResponse case network(String) @@ -20,6 +22,7 @@ public enum ClassTicketError: LocalizedError, Equatable, Sendable { case .claimed: return "이미 다른 계정에 등록된 이용권 코드예요." case .activeTicket: return "이미 사용 중인 이용권이 있어요. 만료 후 등록할 수 있어요." case .notFound: return "등록된 이용권이 없어요." + case .locked: return "코드를 5번 잘못 입력해 1시간 동안 입력할 수 없어요." case .invalidResponse: return "이용권 정보를 읽지 못했어요. 다시 시도해 주세요." case let .network(message): return message } diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassJoinPreview.swift b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassJoinPreview.swift index b8a32580..a1cb7682 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassJoinPreview.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassJoinPreview.swift @@ -7,6 +7,7 @@ public struct ClassJoinPreview: Equatable, Sendable { public let battleThumbnailURL: URL? public let battleType: String public let memberCount: Int + public let activeMemberCount: Int public let capacity: Int public let closeAt: Date @@ -17,6 +18,7 @@ public struct ClassJoinPreview: Equatable, Sendable { battleThumbnailURL: URL?, battleType: String, memberCount: Int, + activeMemberCount: Int? = nil, capacity: Int, closeAt: Date ) { @@ -26,6 +28,7 @@ public struct ClassJoinPreview: Equatable, Sendable { self.battleThumbnailURL = battleThumbnailURL self.battleType = battleType self.memberCount = memberCount + self.activeMemberCount = activeMemberCount ?? memberCount self.capacity = capacity self.closeAt = closeAt } @@ -38,6 +41,7 @@ public struct ClassJoinPreview: Equatable, Sendable { battleThumbnailURL: room.battle.thumbnailURL, battleType: room.battleType.rawValue, memberCount: room.memberCount, + activeMemberCount: room.activeMemberCount, capacity: room.memberCapacity ?? 0, closeAt: room.deadline ) diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassRoom.swift b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassRoom.swift index fd34ab57..e0efbbdf 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassRoom.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Entity/Room/ClassRoom.swift @@ -16,7 +16,10 @@ public struct ClassRoom: Equatable, Identifiable, Sendable { public let deadline: Date public let ticketExpiresAt: Date? public let closeAt: Date? + /// 사용 좌석 수. 활동한 뒤 나간 사람도 포함한다. 남은 자리는 `memberCapacity - memberCount`. public let memberCount: Int + /// 현재 명단 인원(참여하는 운영자 포함). 화면의 "멤버 N명"에 쓴다. + public let activeMemberCount: Int public let memberCapacity: Int? public let role: ClassRole public let status: ClassStatus @@ -32,6 +35,7 @@ public struct ClassRoom: Equatable, Identifiable, Sendable { deadline: Date, closeAt: Date? = nil, memberCount: Int, + activeMemberCount: Int? = nil, role: ClassRole, status: ClassStatus, allowsAnonymousOpinion: Bool, @@ -50,6 +54,7 @@ public struct ClassRoom: Equatable, Identifiable, Sendable { self.ticketExpiresAt = ticketExpiresAt self.closeAt = closeAt self.memberCount = memberCount + self.activeMemberCount = activeMemberCount ?? memberCount self.memberCapacity = memberCapacity self.role = role self.status = status diff --git a/Projects/Domain/ClassDomain/Interface/Sources/Repository/Default/MockClassRepository.swift b/Projects/Domain/ClassDomain/Interface/Sources/Repository/Default/MockClassRepository.swift index 2e7f95ef..9832931e 100644 --- a/Projects/Domain/ClassDomain/Interface/Sources/Repository/Default/MockClassRepository.swift +++ b/Projects/Domain/ClassDomain/Interface/Sources/Repository/Default/MockClassRepository.swift @@ -432,6 +432,7 @@ private extension ClassRoom { deadline: deadline, closeAt: closeAt, memberCount: memberCount, + activeMemberCount: memberCount, role: role, status: status, allowsAnonymousOpinion: allowsAnonymousOpinion, diff --git a/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassBattleSessionDTO.swift b/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassBattleSessionDTO.swift index 92d5d8ab..6dffc0b7 100644 --- a/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassBattleSessionDTO.swift +++ b/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassBattleSessionDTO.swift @@ -24,11 +24,16 @@ struct ClassBattleSessionDTO: Decodable, Sendable { let options: [Option] } + struct Tag: Decodable, Sendable { + let name: String + } + let battleInfo: Info let description: String? let shareUrl: String? let userVoteStatus: String? let currentStep: String? + let categoryTags: [Tag]? } diff --git a/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassDebateDTO.swift b/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassDebateDTO.swift index 82f94ab8..9bd87f77 100644 --- a/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassDebateDTO.swift +++ b/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassDebateDTO.swift @@ -3,6 +3,7 @@ import ClassDomainInterface struct ClassDebateDTO: Decodable, Sendable { struct Philosopher: Decodable, Sendable { let name: String + let imageUrl: String? } struct Option: Decodable, Sendable { diff --git a/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassroomDataDTO.swift b/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassroomDataDTO.swift index 01dd32fa..70aeff3e 100644 --- a/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassroomDataDTO.swift +++ b/Projects/Domain/ClassDomain/Sources/Model/DTO/ClassroomDataDTO.swift @@ -11,6 +11,7 @@ struct ClassListItemDTO: Decodable, Sendable { let battleThumbnailUrl: String? let battleType: ClassBattleType let memberCount: Int + let activeMemberCount: Int? let capacity: Int let closeAt: String let closed: Bool @@ -31,6 +32,7 @@ struct ClassDetailDataDTO: Decodable, Sendable { let battle: Battle let battleType: ClassBattleType let memberCount: Int + let activeMemberCount: Int? let capacity: Int let deadline: String? let ticketExpiresAt: String @@ -47,6 +49,7 @@ struct ClassJoinPreviewDataDTO: Decodable, Sendable { let battleThumbnailUrl: String? let battleType: String let memberCount: Int + let activeMemberCount: Int? let capacity: Int let closeAt: String } diff --git a/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassBattleSessionDTO+.swift b/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassBattleSessionDTO+.swift index fb9ba900..543126e6 100644 --- a/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassBattleSessionDTO+.swift +++ b/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassBattleSessionDTO+.swift @@ -31,7 +31,8 @@ extension ClassBattleSessionDTO.Battle { currentStep: currentStep, participantsCount: battleInfo.participantsCount ?? 0, audioDuration: battleInfo.audioDuration ?? 0, - options: battleInfo.options.map { $0.toDomain() } + options: battleInfo.options.map { $0.toDomain() }, + categoryTags: categoryTags?.map(\.name) ?? [] ) } } diff --git a/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassDebateDTO+.swift b/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassDebateDTO+.swift index 7b8bbb91..d563cf69 100644 --- a/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassDebateDTO+.swift +++ b/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassDebateDTO+.swift @@ -1,4 +1,5 @@ import ClassDomainInterface +import Foundation extension ClassDebateDTO.Message { func toDomain() throws -> ClassDebateMessage { @@ -26,6 +27,7 @@ extension ClassDebateDTO { canReply: canReply, canRetry: canRetry, philosopherName: philosopher.name, + philosopherImageURL: philosopher.imageUrl.flatMap(URL.init(string:)), participantOptionTitle: participantOption.title, opponentOptionTitle: opponentOption.title, messages: messages.map { try $0.toDomain() }, diff --git a/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassroomDataDTO+.swift b/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassroomDataDTO+.swift index c5e1b41c..7d68c277 100644 --- a/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassroomDataDTO+.swift +++ b/Projects/Domain/ClassDomain/Sources/Model/Mapper/ClassroomDataDTO+.swift @@ -13,6 +13,7 @@ extension ClassListItemDTO { deadline: .distantFuture, closeAt: closeDate, memberCount: memberCount, + activeMemberCount: activeMemberCount, role: try myRole.classRole(), status: closed ? .closed : .open, allowsAnonymousOpinion: false, @@ -38,6 +39,7 @@ extension ClassDetailDataDTO { deadline: try deadline.map { try $0.classDate() } ?? .distantFuture, closeAt: try closeAt.classDate(), memberCount: memberCount, + activeMemberCount: activeMemberCount, role: try myRole.classRole(), status: closed ? .closed : .open, allowsAnonymousOpinion: false, @@ -59,6 +61,7 @@ extension ClassJoinPreviewDataDTO { battleThumbnailURL: battleThumbnailUrl.flatMap(URL.init(string:)), battleType: battleType, memberCount: memberCount, + activeMemberCount: activeMemberCount, capacity: capacity, closeAt: try closeAt.classDate() ) diff --git a/Projects/Domain/ClassDomain/Sources/Repository/ClassErrorMapper.swift b/Projects/Domain/ClassDomain/Sources/Repository/ClassErrorMapper.swift index 92326fd0..e11de5ee 100644 --- a/Projects/Domain/ClassDomain/Sources/Repository/ClassErrorMapper.swift +++ b/Projects/Domain/ClassDomain/Sources/Repository/ClassErrorMapper.swift @@ -25,7 +25,8 @@ enum ClassErrorMapper { private static func classError(code: String) -> ClassError? { switch code { case "CLASS_404_CODE": return .invalidCode - case "CLASS_409_CLOSED", "CLASS_409_TICKET_ENDED": return .closed + case "CLASS_409_CLOSED": return .closed + case "CLASS_409_TICKET_ENDED": return .ticketEnded case "CLASS_409_JOINED": return .alreadyJoined case "CLASS_409_NAME": return .duplicateName case "CLASS_404": return .notFound diff --git a/Projects/Domain/ClassDomain/Sources/Repository/ClassRepositoryImpl+Ticket.swift b/Projects/Domain/ClassDomain/Sources/Repository/ClassRepositoryImpl+Ticket.swift index 60820b94..509d75e2 100644 --- a/Projects/Domain/ClassDomain/Sources/Repository/ClassRepositoryImpl+Ticket.swift +++ b/Projects/Domain/ClassDomain/Sources/Repository/ClassRepositoryImpl+Ticket.swift @@ -49,6 +49,7 @@ extension ClassRepositoryImpl { case "TICKET_409_CLAIMED": return .claimed case "TICKET_409_ACTIVE": return .activeTicket case "TICKET_404": return .notFound + case "TICKET_429_LOCKED": return .locked default: return .network(response.message ?? "이용권 정보를 불러오지 못했어요.") } } diff --git a/Projects/Domain/ClassDomain/Tests/Sources/ClassErrorMappingTests.swift b/Projects/Domain/ClassDomain/Tests/Sources/ClassErrorMappingTests.swift index f2609eae..cb4ac1e4 100644 --- a/Projects/Domain/ClassDomain/Tests/Sources/ClassErrorMappingTests.swift +++ b/Projects/Domain/ClassDomain/Tests/Sources/ClassErrorMappingTests.swift @@ -7,7 +7,7 @@ struct ClassErrorMappingTests { @Test(arguments: [ ("CLASS_404_CODE", ClassError.invalidCode), ("CLASS_409_CLOSED", .closed), - ("CLASS_409_TICKET_ENDED", .closed), + ("CLASS_409_TICKET_ENDED", .ticketEnded), ("CLASS_409_JOINED", .alreadyJoined), ("CLASS_409_NAME", .duplicateName), ("CLASS_404", .notFound), diff --git a/Projects/Feature/Class/Sources/ClassAIChat/Reducer/ClassAIChatFeature.swift b/Projects/Feature/Class/Sources/ClassAIChat/Reducer/ClassAIChatFeature.swift index dc168d66..e078c8a3 100644 --- a/Projects/Feature/Class/Sources/ClassAIChat/Reducer/ClassAIChatFeature.swift +++ b/Projects/Feature/Class/Sources/ClassAIChat/Reducer/ClassAIChatFeature.swift @@ -63,7 +63,9 @@ public struct ClassAIChatFeature { } public var opponentAvatarURL: URL? { - selectedOptionID == 1 ? room.battle.philosopherBImageURL : room.battle.philosopherAImageURL + // 이름과 얼굴이 어긋나지 않게 서버가 준 토론 철학자 이미지를 먼저 쓴다. + if let url = debate?.philosopherImageURL { return url } + return selectedOptionID == 1 ? room.battle.philosopherBImageURL : room.battle.philosopherAImageURL } public var quickReplies: [String] { diff --git a/Projects/Feature/Class/Sources/ClassBattleFlow/Reducer/ClassBattleFlowFeature.swift b/Projects/Feature/Class/Sources/ClassBattleFlow/Reducer/ClassBattleFlowFeature.swift index ba546520..471fd2e9 100644 --- a/Projects/Feature/Class/Sources/ClassBattleFlow/Reducer/ClassBattleFlowFeature.swift +++ b/Projects/Feature/Class/Sources/ClassBattleFlow/Reducer/ClassBattleFlowFeature.swift @@ -137,7 +137,9 @@ public struct ClassBattleFlowFeature { } public var voteCategoryLabel: String? { - guard let category = room?.battle.categoryDisplayTitle, !category.isEmpty else { return nil } + // 클래스 배틀 상세의 카테고리 태그를 먼저 쓴다. 커스텀 배틀은 방 정보에 카테고리가 없다. + let category = session?.battle.categoryTags.first ?? room?.battle.categoryDisplayTitle + guard let category, !category.isEmpty else { return nil } return "#\(category)" } diff --git a/Projects/Feature/Class/Sources/ClassDetail/View/ClassDetailView.swift b/Projects/Feature/Class/Sources/ClassDetail/View/ClassDetailView.swift index 98a54075..cb4e0176 100644 --- a/Projects/Feature/Class/Sources/ClassDetail/View/ClassDetailView.swift +++ b/Projects/Feature/Class/Sources/ClassDetail/View/ClassDetailView.swift @@ -127,7 +127,7 @@ private extension ClassDetailView { Button { send(.membersTapped) } label: { informationRow( "클래스 멤버", - detail: "총 \(store.room.memberCount)명이 참여하고 있어요", + detail: "총 \(store.room.activeMemberCount)명이 참여하고 있어요", actionTitle: "보기" ) } diff --git a/Projects/Feature/Class/Sources/ClassMember/Reducer/ClassMemberFeature.swift b/Projects/Feature/Class/Sources/ClassMember/Reducer/ClassMemberFeature.swift index 4b7cf8d1..0f1dd050 100644 --- a/Projects/Feature/Class/Sources/ClassMember/Reducer/ClassMemberFeature.swift +++ b/Projects/Feature/Class/Sources/ClassMember/Reducer/ClassMemberFeature.swift @@ -60,9 +60,9 @@ public struct ClassMemberFeature { public var memberCountTitle: String { guard let capacity = room.memberCapacity, capacity > 0 else { - return "멤버 \(room.memberCount)" + return "멤버 \(room.activeMemberCount)" } - return "멤버 \(room.memberCount) / \(capacity)" + return "멤버 \(room.activeMemberCount) / \(capacity)" } public var visibleMembers: [ClassMember] { diff --git a/Projects/Feature/Class/Sources/ClassTicket/Model/ClassTicketRegisterNotice.swift b/Projects/Feature/Class/Sources/ClassTicket/Model/ClassTicketRegisterNotice.swift index 3dfb3128..10c86f31 100644 --- a/Projects/Feature/Class/Sources/ClassTicket/Model/ClassTicketRegisterNotice.swift +++ b/Projects/Feature/Class/Sources/ClassTicket/Model/ClassTicketRegisterNotice.swift @@ -16,6 +16,7 @@ public enum ClassTicketRegisterNotice: Equatable, Sendable { case registrationExpired case alreadyActive case registerFailed + case locked /// Android `toRegisterDialog`와 같은 매핑. 사용 중 이용권(`TICKET_409_ACTIVE`)만 iOS에서 따로 안내한다. public init(error: ClassTicketError) { @@ -24,6 +25,7 @@ public enum ClassTicketRegisterNotice: Equatable, Sendable { case .invalidCode, .revoked: self = .invalidCode case .registrationExpired: self = .registrationExpired case .activeTicket: self = .alreadyActive + case .locked: self = .locked case .notFound, .invalidResponse, .network: self = .registerFailed } } @@ -35,6 +37,7 @@ public enum ClassTicketRegisterNotice: Equatable, Sendable { case .registrationExpired: return .ticketRegistrationExpired() case .alreadyActive: return .ticketAlreadyActive() case .registerFailed: return .ticketRegisterFailed() + case .locked: return .ticketLocked() } } } diff --git a/Projects/Feature/Class/Sources/ClassTicket/Reducer/ClassTicketFeature.swift b/Projects/Feature/Class/Sources/ClassTicket/Reducer/ClassTicketFeature.swift index a3b71e73..d3a87b2a 100644 --- a/Projects/Feature/Class/Sources/ClassTicket/Reducer/ClassTicketFeature.swift +++ b/Projects/Feature/Class/Sources/ClassTicket/Reducer/ClassTicketFeature.swift @@ -44,6 +44,9 @@ public struct ClassTicketFeature { return String(scalars) } + /// 이용권 코드 길이. 예: `PKE05D2E1` + public static let codeLength = 9 + public var canCheckCode: Bool { !normalizedCode.isEmpty && !isChecking && !isLoadingExistingTicket } @@ -141,6 +144,11 @@ public struct ClassTicketFeature { Reduce { state, action in switch action { case .binding(\.code): + // 코드는 `PKE` + 16진수 6자리(9자)다. 영문·숫자가 9자를 넘으면 잘라낸다. + let codeCharacters = state.normalizedCode.filter { $0 != "-" } + if codeCharacters.count > State.codeLength { + state.code = String(codeCharacters.prefix(State.codeLength)) + } let wasLookingUpRegisteredTicket = state.preview != nil && state.isLoadingExistingTicket state.preview = nil if wasLookingUpRegisteredTicket { diff --git a/Projects/Feature/Class/Sources/ClassTicket/View/ClassTicketView.swift b/Projects/Feature/Class/Sources/ClassTicket/View/ClassTicketView.swift index 1bb03fc2..a5a591b6 100644 --- a/Projects/Feature/Class/Sources/ClassTicket/View/ClassTicketView.swift +++ b/Projects/Feature/Class/Sources/ClassTicket/View/ClassTicketView.swift @@ -102,7 +102,7 @@ private extension ClassTicketView { } .pretendardFont(.labelSmall) - TextField("", text: $store.code, prompt: Text("전달 받은 코드를 입력해주세요").foregroundStyle(.gray300)) + TextField("", text: $store.code, prompt: Text("예: PKE05D2E1").foregroundStyle(.gray300)) .textInputAutocapitalization(.characters) .autocorrectionDisabled() .keyboardType(.asciiCapable) diff --git a/Projects/Feature/Class/Sources/MyClass/View/Components/MyClassRoomCard.swift b/Projects/Feature/Class/Sources/MyClass/View/Components/MyClassRoomCard.swift index debe3f91..8fa5f71f 100644 --- a/Projects/Feature/Class/Sources/MyClass/View/Components/MyClassRoomCard.swift +++ b/Projects/Feature/Class/Sources/MyClass/View/Components/MyClassRoomCard.swift @@ -95,7 +95,7 @@ private extension MyClassRoomCard { HStack(spacing: 6) { metaItem( systemName: "person", - text: "멤버 \(room.memberCount)명" + text: "멤버 \(room.activeMemberCount)명" ) if let deadlineText { diff --git a/Projects/Feature/Class/Tests/Sources/ClassTicketTests.swift b/Projects/Feature/Class/Tests/Sources/ClassTicketTests.swift index 98fa35ba..1ba7384c 100644 --- a/Projects/Feature/Class/Tests/Sources/ClassTicketTests.swift +++ b/Projects/Feature/Class/Tests/Sources/ClassTicketTests.swift @@ -58,8 +58,8 @@ struct ClassTicketTests { $0.shouldCheckExistingTicket = false $0.isLoadingExistingTicket = true } - await store.send(.binding(.set(\.code, "PICKE-AB12-CD34"))) { - $0.code = "PICKE-AB12-CD34" + await store.send(.binding(.set(\.code, "PKE05D2E1"))) { + $0.code = "PKE05D2E1" } #expect(!store.state.canCheckCode) await gate.complete(ticket) @@ -356,6 +356,24 @@ struct ClassTicketTests { #expect(ClassTicketRegisterNotice(error: .network("x")) == .registerFailed) } + @Test + func 코드를_5번_잘못_넣어_잠기면_1시간_입력_제한을_안내한다() { + #expect(ClassTicketRegisterNotice(error: .locked) == .locked) + #expect(ClassTicketError.locked.message == "코드를 5번 잘못 입력해 1시간 동안 입력할 수 없어요.") + } + + @Test + func 코드는_PKE_형식_9자를_넘으면_잘라낸다() async { + let store = TestStore(initialState: ClassTicketFeature.State()) { ClassTicketFeature() } + await store.send(.binding(.set(\.code, "pke05d2e1ff"))) { + $0.code = "PKE05D2E1" + } + await store.send(.binding(.set(\.code, "pke-05d2e1"))) { + $0.code = "pke-05d2e1" + } + #expect(store.state.normalizedCode == "PKE-05D2E1") + } + @Test func 확인_단계에서_뒤로가면_코드_입력으로_돌아가고_등록_중에는_무시한다() async { var state = ClassTicketFeature.State() diff --git a/Projects/UI/PickeSharedUI/Sources/Alert/CustomAlertState.swift b/Projects/UI/PickeSharedUI/Sources/Alert/CustomAlertState.swift index 5cb6c0c3..7b408c85 100644 --- a/Projects/UI/PickeSharedUI/Sources/Alert/CustomAlertState.swift +++ b/Projects/UI/PickeSharedUI/Sources/Alert/CustomAlertState.swift @@ -218,6 +218,10 @@ public extension CustomAlertState where Action == CustomAlertAction { notice("코드 등록이 완료되지 않았습니다\n네트워크 확인 후 한 번 더 시도해주세요") } + static func ticketLocked() -> CustomAlertState { + notice("코드를 5번 잘못 입력해\n1시간 동안 입력할 수 없어요") + } + static func ticketAlreadyActive() -> CustomAlertState { notice("이미 사용 중인 이용권이 있어요\n만료 후 등록할 수 있어요") }