투표기능 추가
This commit is contained in:
		@@ -36,6 +36,11 @@ final class AuditionRoleDetailViewModel: ObservableObject {
 | 
			
		||||
    @Published var soundData: Data? = nil
 | 
			
		||||
    @Published var phoneNumber = ""
 | 
			
		||||
    
 | 
			
		||||
    @Published var isShowNotifyVote = true
 | 
			
		||||
    @Published var isShowSodaDialog = false
 | 
			
		||||
    @Published var dialogTitle = ""
 | 
			
		||||
    @Published var dialogDesc = ""
 | 
			
		||||
    
 | 
			
		||||
    var page = 1
 | 
			
		||||
    var isLast = false
 | 
			
		||||
    private var pageSize = 10
 | 
			
		||||
@@ -262,6 +267,62 @@ final class AuditionRoleDetailViewModel: ObservableObject {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    func voteApplicant(applicantId: Int) {
 | 
			
		||||
        isLoading = true
 | 
			
		||||
        
 | 
			
		||||
        repository.voteApplicant(applicantId: applicantId)
 | 
			
		||||
            .sink { result in
 | 
			
		||||
                switch result {
 | 
			
		||||
                case .finished:
 | 
			
		||||
                    DEBUG_LOG("finish")
 | 
			
		||||
                case .failure(let error):
 | 
			
		||||
                    ERROR_LOG(error.localizedDescription)
 | 
			
		||||
                }
 | 
			
		||||
            } receiveValue: { response in
 | 
			
		||||
                self.isLoading = false
 | 
			
		||||
                let responseData = response.data
 | 
			
		||||
                
 | 
			
		||||
                do {
 | 
			
		||||
                    let jsonDecoder = JSONDecoder()
 | 
			
		||||
                    let decoded = try jsonDecoder.decode(ApiResponseWithoutData.self, from: responseData)
 | 
			
		||||
                    
 | 
			
		||||
                    if decoded.success {
 | 
			
		||||
                        if self.isShowNotifyVote {
 | 
			
		||||
                            self.dialogTitle = "[오디션 응원]"
 | 
			
		||||
                            self.dialogDesc = "오디션을 응원하셨습니다\n(무료응원 : 1계정당 1일 1회)\n1캔으로 추가 응원을 해보세요."
 | 
			
		||||
                            self.isShowSodaDialog = true
 | 
			
		||||
                        }
 | 
			
		||||
                        
 | 
			
		||||
                        if let index = self.applicantList.firstIndex(where: { $0.applicantId == applicantId }) {
 | 
			
		||||
                            var applicant = self.applicantList[index]
 | 
			
		||||
                            applicant.voteCount += 1
 | 
			
		||||
                            
 | 
			
		||||
                            self.applicantList.remove(at: index)
 | 
			
		||||
                            self.applicantList.insert(applicant, at: index)
 | 
			
		||||
                        }
 | 
			
		||||
                    } else {
 | 
			
		||||
                        if let message = decoded.message {
 | 
			
		||||
                            if message.contains("오늘 응원은 여기까지") {
 | 
			
		||||
                                self.dialogTitle = "[오늘 응원 제한]"
 | 
			
		||||
                                self.dialogDesc = "오늘 응원은 여기까지!\n하루 최대 10회까지 이용이 가능합니다.\n내일 다시 이용해주세요."
 | 
			
		||||
                                self.isShowSodaDialog = true
 | 
			
		||||
                            } else {
 | 
			
		||||
                                self.errorMessage = message
 | 
			
		||||
                                self.isShowPopup = true
 | 
			
		||||
                            }
 | 
			
		||||
                        } else {
 | 
			
		||||
                            self.errorMessage = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
 | 
			
		||||
                            self.isShowPopup = true
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                } catch {
 | 
			
		||||
                    self.errorMessage = "알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
 | 
			
		||||
                    self.isShowPopup = true
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            .store(in: &subscription)
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    func deleteAllRecordingFilesWithNamePrefix(_ prefix: String) {
 | 
			
		||||
        let fileManager = FileManager.default
 | 
			
		||||
        let documentsURL = getDocumentsDirectory()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user