Completed Report Module

This commit is contained in:
2024-08-08 18:47:13 +05:30
parent 0348f07230
commit 08bf5514e2
29 changed files with 1216 additions and 117 deletions

View File

@@ -38,6 +38,8 @@ class MyListVM{
setupCell()
Utilities.startProgressHUD()
getFavouriteListing()
vc.karaokeViewBtn.roundCorner()
}
@objc func viewPush(notification: Notification){
@@ -119,7 +121,8 @@ class MyListVM{
let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi",
"access-token": AuthFunc.shareInstance.getAccessToken()]
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Home.favourite_listing, method: .post, headers: headers) { [weak self](result : Result<BaseResponseModel<FavouriteListingDM>, NetworkManager.APIError>) in
let params : Parameters = ["api_version" : "v2"]
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Home.favourite_listing, method: .post,parameters : params, headers: headers) { [weak self](result : Result<BaseResponseModel<FavouriteListingDM>, NetworkManager.APIError>) in
switch result{
case .success(let data):
guard let self else{return}
@@ -202,6 +205,7 @@ class MyListVM{
reloadCollections()
feedbackGenerator.impactOccurred()
checkNil()
checkViewAll()
default:
break
}
@@ -218,6 +222,19 @@ class MyListVM{
}
}
func checkViewAll(){
if let favListing = MyListDataTemp.shareInstance.favListingData{
if let karaokeCount = favListing.singKaraokeData?.count, karaokeCount >= 3 {
vc.karaokeViewBtn.isHidden = false
}else{
vc.karaokeViewBtn.isHidden = true
}
}
}
// MARK: - Like , unlike
func likePost(postID : Int, postType : Int, index : Int , onCompletion : @escaping (Bool) -> Void){

View File

@@ -0,0 +1,108 @@
//
// MyListViewAllVM.swift
// WOKA
//
// Created by MacBook Pro on 08/08/24.
//
import Foundation
import Alamofire
class MyListViewAllVM{
weak var vc : MyListViewAllVC!
var moduleType = Int()
var postType = Int()
var pageNo = 0
var favListingData : FavouriteListingDM.ResultData?
var webSeriesHindi = [FavouriteListingDM.ResultData.ShowDatum]()
func initView(){
getFavouriteListing()
}
// MARK: - Get Favourite Listing
func getFavouriteListing(){
let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi",
"access-token": AuthFunc.shareInstance.getAccessToken()]
let params : Parameters = ["post_type" : postType,
"api_version" : "v2",
"start" : pageNo,
"limit" : "10"]
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Home.favourite_listing, method: .post,parameters : params, headers: headers) { [weak self](result : Result<BaseResponseModel<FavouriteListingDM>, NetworkManager.APIError>) in
switch result{
case .success(let data):
guard let self else{return}
switch data.success{
case 0:
Utilities.dismissProgressHUD()
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
case 1:
Utilities.dismissProgressHUD()
guard let data = data.data?.result else{return}
if var hindiData = favListingData?.showData{
/*
Taking out the hindi series , 1-> English , 18-> Hindi
And the saving it to hindi series, also modify the bookmark category ids
*/
webSeriesHindi = hindiData.compactMap { $0 }.filter {
($0.bookmarkCategoryIDS?.components(separatedBy: ",").first == "18" || $0.bookmarkCategoryIDS?.components(separatedBy: ",").last == "18")
}.map { element -> FavouriteListingDM.ResultData.ShowDatum in
var modifiedElement = element
modifiedElement.bookmarkCategoryIDS = "18"
modifiedElement.categoryMasterID = "18"
return modifiedElement
}
if let data = favListingData?.showData{
var indicesToRemove = [Int]()
// Deleting the hindi series from main (those with category ID "18")
for (index, element) in data.enumerated() {
if let bookMarkCatID = element.bookmarkCategoryIDS?.components(separatedBy: ","){
if bookMarkCatID.count > 1{ // means multiple language
/*
if its greater than one , its for sure we have extracted the hindi episode
*/
hindiData[index].bookmarkCategoryIDS = "1"
}else{ // means single language
if bookMarkCatID.first == "18"{
indicesToRemove.append(index)
}
}
}
}
// Remove items in reverse order to avoid index shifting issues
for index in indicesToRemove.reversed() {
hindiData.remove(at: index)
}
}
// Updating the showData with the filtered list
// MyListDataTemp.shareInstance.favListingData?.showData = hindiData.map({$0.categoryMasterID = 1})
favListingData?.showData = hindiData.map { item in
var modifiedItem = item
modifiedItem.categoryMasterID = "1"
return modifiedItem
}
}
default:
break
}
case .failure(let error):
guard let self else{return}
Utilities.dismissProgressHUD()
self.vc.toast(msg: error.localizedDescription , time: 2)
}
}
}
}