Completed Report Module
This commit is contained in:
99
WOKA/SideBarNav/Controller/MyOrderDetailsVC.swift
Normal file
99
WOKA/SideBarNav/Controller/MyOrderDetailsVC.swift
Normal file
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// MyOrderDetailsVC.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by MacBook Pro on 08/08/24.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Alamofire
|
||||
|
||||
class MyOrderDetailsVC: UIViewController {
|
||||
|
||||
@IBOutlet weak var orderIDNumber: UILabel!
|
||||
@IBOutlet weak var airWayBillNo: UILabel!
|
||||
@IBOutlet weak var status: UILabel!
|
||||
@IBOutlet weak var expectedDate: UILabel!
|
||||
@IBOutlet weak var tableView: UITableView!
|
||||
|
||||
var orderID : String?
|
||||
var data : OrderDetailsDM.ResultData?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
setupCell()
|
||||
|
||||
if let orderID{
|
||||
getOrdersDetails(orderID: orderID)
|
||||
}
|
||||
}
|
||||
|
||||
func setupCell(){
|
||||
tableView.register(UINib(nibName: K.CellIdentifier.SideBarNav.myOrderDetailsCell, bundle: nil), forCellReuseIdentifier: K.CellIdentifier.SideBarNav.myOrderDetailsCell)
|
||||
tableView.delegate = self
|
||||
tableView.dataSource = self
|
||||
}
|
||||
|
||||
// MARK: - Get MyORders
|
||||
|
||||
func getOrdersDetails(orderID : String){
|
||||
Utilities.startProgressHUD()
|
||||
let headers : HTTPHeaders = ["Accept-Language" : AuthFunc.shareInstance.languageSelected == .english ? "English" : "Hindi",
|
||||
"access-token": AuthFunc.shareInstance.getAccessToken()]
|
||||
let url = "\(APIEndPoints.SideBarNav.order_status_track )/\(orderID)"
|
||||
NetworkManager.shareInstance.apiRequest(url: url, method: .get, headers : headers) { [weak self](result : Result<BaseResponseModel<OrderDetailsDM>, NetworkManager.APIError>) in
|
||||
switch result{
|
||||
case .success(let data):
|
||||
switch data.success{
|
||||
case 0:
|
||||
Utilities.dismissProgressHUD()
|
||||
return
|
||||
case 1:
|
||||
Utilities.dismissProgressHUD()
|
||||
guard let data = data.data?.result?.first , let self else{return}
|
||||
self.data = data
|
||||
self.tableView.reloadData()
|
||||
setData()
|
||||
default:
|
||||
break
|
||||
}
|
||||
case .failure(let error):
|
||||
Utilities.dismissProgressHUD()
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func scrollToBottom(animated: Bool) {
|
||||
let bottomOffset = CGPoint(x: 0, y: tableView.contentSize.height - tableView.bounds.size.height)
|
||||
if bottomOffset.y > 0 {
|
||||
tableView.setContentOffset(bottomOffset, animated: animated)
|
||||
}
|
||||
}
|
||||
|
||||
func setData(){
|
||||
if let data{
|
||||
self.orderIDNumber.text = orderID ?? "NA"
|
||||
self.airWayBillNo.text = data.awbno
|
||||
self.status.text = data.shipmentLatestStatus
|
||||
self.expectedDate.text = data.edd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - TableView DataSource , Delegates
|
||||
|
||||
extension MyOrderDetailsVC : TableViewSRC{
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return self.data?.scanDetail?.count ?? 0
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.SideBarNav.myOrderDetailsCell) as! MyOrderDetailsCell
|
||||
|
||||
if let data = self.data?.scanDetail?[indexPath.row]{
|
||||
cell.setData(data: data)
|
||||
}
|
||||
return cell
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,12 @@ class MyOrdersVC: UIViewController {
|
||||
|
||||
var vm = MyOrdersVM()
|
||||
|
||||
@IBOutlet weak var tableView: UITableView!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
vm.vc = self
|
||||
vm.initView()
|
||||
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -39,3 +40,26 @@ class MyOrdersVC: UIViewController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - TableView DataSource , Delegates
|
||||
|
||||
extension MyOrdersVC : TableViewSRC{
|
||||
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return vm.orderData.count
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: K.CellIdentifier.SideBarNav.myOrderCell) as! MyOrderCell
|
||||
let data = vm.orderData[indexPath.row]
|
||||
cell.setData(data: data)
|
||||
return cell
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
let sb = UIStoryboard(name: K.StoryBoard.sideBarNav, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.SideBarNav.myOrderDetailsVC) as! MyOrderDetailsVC
|
||||
let orderID = vm.orderData[indexPath.row].orderID
|
||||
vcPush.orderID = orderID
|
||||
self.navigationController?.present(vcPush, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user