Untitled

mail@pastecode.io avatar
unknown
swift
a year ago
54 kB
3
Indexable
Never
//
//  BookingDetailsView.swift
//  Garageworks-iOS-Revamp
//
//  Created by DigitalFlake Kapil Dongre on 07/01/23.
//

import SwiftUI
import Razorpay
import Foundation

struct BookingDetailsView: View {
    
    @Environment(\.presentationMode) var presentationMode
    var custId: String? = ""
    var bookId: String? = ""
    
    @State var isBookingDetailsOpen: Bool = false
    @State var isJobCardOpen: Bool = false
    @State var isBookingTrackingOpen: Bool = false
    @State var isPaymentDetailsOpen: Bool = false
    @State var isServiceDetailsOpen: Bool = false
    @State var isReccomendationOpen: Bool = false
    
    @State var isComplaintOpen: Bool = false
    
    @StateObject var razorPayObserver: RazorPayObserver = RazorPayObserver()
    
    @Binding var price: String?
    
    @State var isLinkActive = false
    
    @State private var showWebView = false
    @State var isJobCardApprovalLinkActive = false
    
    @StateObject var bookingDataObserver = BookingDatasetObserver()
    @StateObject var serviceReport = ServiceReportObserver()
    
    //    @StateObject var bookingDetailObserver: BookingDetailModelObserver = BookingDetailModelObserver(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!), customer_id: (UserDefaults.standard.string(forKey: "customer_id")!))
    
    @StateObject var bookingDetailObserver = BookingDetailModelObserver()
    
    @State var callImageDetailView: Int? = nil
    
    @StateObject var jobCardObserver = JobCardDetailObserver()
    //= JobCardDetailObserver(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!))
    @State private var showJobcardText: String = ""
    @State var showProgress : Bool = true
    
    @Binding var is_reschedule : Int
    @Binding var bookingID : String
    
    var body: some View {
        GeometryReader{geometry in
            //NavigationView{
            VStack{
                HStack(spacing:20){
                    Image("Vector 1")
                        .resizable()
                        .frame(width: 8, height: 15)
                        .padding(.leading,15)
                        .foregroundColor(Color.init(hex: Colors.color_gr2))
                    Text("Booking Details")
                        .font(Font.custom(Fonts.product_regular, size: 16))
                        .foregroundColor(Color.init(hex: Colors.color_gr2))
                    Spacer()
                }
                .frame(width:geometry.size.width,height:geometry.size.height * 0.10,alignment: .center)
                .background(.white)
                .onTapGesture {
                    bookingID = bookingDataObserver.bookingDatasetObserver?.booking_id ?? ""
                    is_reschedule = bookingDataObserver.bookingDatasetObserver?.is_reschedule ?? -1
                    self.presentationMode.wrappedValue.dismiss()
                }
                
                
                VStack(spacing: 20){
                    VStack{
                        VStack(alignment: .leading,spacing: 20){
                            HStack{
                                VStack(alignment: .leading,spacing: 5){
                                    
                                    Text("\(bookingDataObserver.bookingDatasetObserver?.vehicle_make ?? "") \(bookingDataObserver.bookingDatasetObserver?.vehicle_model ?? "")")
                                        .bold()
                                        .font(Font.custom(Fonts.inter, size: 12))
                                        .foregroundColor(Color.init(hex: Colors.color_or))
                                    
                                    Text("#\(bookingDataObserver.bookingDatasetObserver?.booking_id ?? "")")
                                        .font(Font.custom(Fonts.product_bold, size: 20))
                                        .foregroundColor(.black)
                                }
                                Spacer()
                                
                                VStack(alignment: .leading,spacing: 5){
                                    
                                    Text("\(bookingDataObserver.bookingDatasetObserver?.custom_status ?? "")")
                                        .foregroundColor(.white)
                                        .font(Font.custom(Fonts.product_bold, size: 12))
                                        .padding([.leading, .trailing], 12)
                                        .padding([.top, .bottom], 5)
                                        .background(Color(hex: "\(bookingDataObserver.bookingDatasetObserver?.custom_status_color ?? "")"))
                                        .cornerRadius(10)
                                }
                            }
                            .frame(width: geometry.size.width * 0.8)
                            .padding(.top)
                            .padding(.leading, 15)
                            
                            HStack{
                                VStack(alignment: .leading,spacing: 5){
                                    Text("Date")
                                        .font(Font.custom(Fonts.product_regular, size: 12))
                                        .foregroundColor(Color.init(hex: Colors.color_light_gr))
                                    
                                    Text("\(bookingDataObserver.bookingDatasetObserver?.service_date ?? "" )")
                                        .font(Font.custom(Fonts.product_regular, size: 16))
                                        .foregroundColor(.black)
                                }
                                .frame(width: geometry.size.width * 0.43,alignment: .leading)
                                
                                //                            Spacer()
                                VStack(alignment: .leading,spacing: 5){
                                    Text("Time")
                                        .font(Font.custom(Fonts.product_regular, size: 12))
                                        .foregroundColor(Color.init(hex: Colors.color_light_gr))
                                    
                                    Text("\(bookingDataObserver.bookingDatasetObserver?.time_slot ?? "" )")
                                        .font(Font.custom(Fonts.product_regular, size: 16))
                                        .foregroundColor(.black)
                                }
                                .frame(width: geometry.size.width * 0.47,alignment: .leading)
                                
                                
                            }
                            //                                            .background(.red)
                            .frame(width: geometry.size.width * 0.9,alignment: .leading)
                            .padding(.horizontal)
                            
                            
                            VStack(alignment: .leading){
                                
                                HStack{
                                    VStack(alignment: .leading,spacing: 5){
                                        Text("Est. Amount")
                                            .font(Font.custom(Fonts.product_regular, size: 12))
                                            .foregroundColor(Color.init(hex: Colors.color_light_gr))
                                        Text("₹ \(bookingDataObserver.bookingDatasetObserver?.estimated_amount ?? "")")
                                            .font(Font.custom(Fonts.product_regular, size: 16))
                                            .foregroundColor(.black)
                                    }
                                    .frame(width: geometry.size.width * 0.43,alignment: .leading)
                                    
                                    
                                    VStack{
                                        BookingDetailsButtonView()
                                            .padding(.bottom,20)
                                            .environmentObject(bookingDataObserver)
                                    }
                                    .frame(width: geometry.size.width * 0.47, alignment: .top)
                                    .padding(.bottom,20)
                                    .onAppear{
                                        bookingID = UserDefaults.standard.string(forKey: "booking_id")!
                                        is_reschedule = bookingDataObserver.bookingDatasetObserver?.is_reschedule ?? -1
                                    }
                                }
                                .frame(width: geometry.size.width * 0.9,alignment: .leading)
                                .padding(.horizontal)
                                .padding(.bottom)
                                
                            }
                            
                        }.frame(width: geometry.size.width * 0.9,height: geometry.size.height * 0.2, alignment: .leading)
                            .padding([.top, .bottom])
                            .background()
                            .cornerRadius(10)
                        
                    }
                    .padding(.top, 20)
                    
                    
                    VStack(alignment: .leading){
                        ScrollView{
                            
                            //MARK: Booking Details
                            VStack{
                                Button(){
                                    self.isBookingDetailsOpen.toggle()
                                    self.isJobCardOpen = false
                                    self.isBookingTrackingOpen = false
                                    self.isPaymentDetailsOpen = false
                                    self.isServiceDetailsOpen = false
                                    self.isReccomendationOpen = false
                                    
                                }label: {
                                    HStack{
                                        Text("Booking Details")
                                            .font(Font.custom(Fonts.product_medium, size: 15))
                                            .foregroundColor(.black)
                                        
                                        Spacer()
                                        
                                        if isBookingDetailsOpen == false{
                                            Image("openList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }else{
                                            Image("closeList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }
                                    }
                                    .frame(width: geometry.size.width * 0.8)
                                }
                                .padding([.leading, .trailing, .top], 10)
                                
                                Divider()
                                    .padding(.top, 10)
                                //Content of booking Details
                                if isBookingDetailsOpen{
                                    VStack(alignment: .leading ,spacing: 10){
                                        HStack{
                                            Text("Name :")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text("\(bookingDataObserver.bookingDatasetObserver?.customer_name ?? " ")")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                            
                                        }
                                        HStack{
                                            Text("Mobile :")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text("\(bookingDataObserver.bookingDatasetObserver?.customer_mobile ?? " ")")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                        }
                                        if bookingDataObserver.bookingDatasetObserver?.customer_email != ""{
                                            HStack{
                                                Text("Email :")
                                                    .font(Font.custom(Fonts.product_regular, size: 14))
                                                    .foregroundColor(Color.init(hex: Colors.color_F6))
                                                
                                                Spacer()
                                                
                                                Text("\(bookingDataObserver.bookingDatasetObserver?.customer_email ?? " ")")
                                                    .font(Font.custom(Fonts.product_regular, size: 14))
                                            }
                                        }
                                        HStack{
                                            Text("Address :")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text("\(bookingDataObserver.bookingDatasetObserver?.customer_address ?? " ")")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                            
                                        }
                                        
                                        
                                        HStack{
                                            Text("Area :")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text("\(bookingDataObserver.bookingDatasetObserver?.customer_area ?? " ")")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                        }
                                        
                                        HStack{
                                            Text("Pincode :")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text("\(bookingDataObserver.bookingDatasetObserver?.customer_pincode ?? " ")")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                        }
                                        HStack{
                                            Text("City :")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text("\(bookingDataObserver.bookingDatasetObserver?.customer_city ?? " ")")
                                                .font(Font.custom(Fonts.product_regular, size: 14))
                                        }
                                        
                                    }
                                    .padding()
                                    Divider()
                                }
                            }
                            
                            //MARK: Recommendation
                            if bookingDataObserver.bookingDatasetObserver?.is_autojobcard == "1"{
                                VStack{
                                    Button(){
                                        self.isReccomendationOpen.toggle()
                                        
                                        self.isBookingDetailsOpen = false
                                        self.isJobCardOpen = false
                                        self.isBookingTrackingOpen = false
                                        self.isPaymentDetailsOpen = false
                                        self.isServiceDetailsOpen = false
                                        //self.isReccomendationOpen = false
                                        
                                    }label: {
                                        HStack{
                                            Text("Service Report Details / Recommendation")
                                                .font(Font.custom(Fonts.product_medium, size: 15))
                                                .foregroundColor(.black)
                                            Spacer()
                                            
                                            if isReccomendationOpen == false{
                                                Image("openList")
                                                    .resizable()
                                                    .frame(width: 12, height: 7)
                                            }else{
                                                Image("closeList")
                                                    .resizable()
                                                    .frame(width: 12, height: 7)
                                            }
                                        }
                                        .frame(width: geometry.size.width * 0.8)
                                        
                                    }
                                    .padding([.leading, .trailing, .top], 10)
                                    Divider()
                                        .padding(.top, 10)
                                }
                                
                                if isReccomendationOpen{
                                    VStack{
                                        
                                        HStack(spacing: 10){
                                            NavigationLink(destination: ImageDetailView(displayImage: "extendImage").navigationBarHidden(true), tag: 1, selection: $callImageDetailView){
                                                Image("extendImage")
                                                    .resizable()
                                                    .frame(width: 70, height: 70)
                                                    .onTapGesture {
                                                        self.callImageDetailView = 1
                                                    }
                                            }
                                            
                                            //                                Image("reccomendDemo")
                                            //                                    .resizable()
                                            //                                    .frame(width: 70, height: 70)
                                            
                                            VStack(alignment: .leading, spacing: 5){
                                                Text("Comments")
                                                    .foregroundColor(.gray)
                                                    .font(.system(size: 14, weight: .regular))
                                                Text("\(bookingDataObserver.bookingDatasetObserver?.specific_complaints ?? "") \(bookingDataObserver.bookingDatasetObserver?.specific_services ?? "") \(bookingDataObserver.bookingDatasetObserver?.specific_repairs ?? "")")
                                                    .multilineTextAlignment(.leading)
                                                    .font(.system(size: 15, weight: .regular))
                                                    .foregroundColor(.gray)
                                            }
                                        } .frame(width: geometry.size.width * 0.8)
                                            .padding(.leading)
                                        
                                        List{
                                            
                                            HStack(spacing: 10){
                                                Image("reccomendDemo")
                                                    .resizable()
                                                    .frame(width: 70, height: 70)
                                                
                                                VStack(alignment: .leading, spacing: 5){
                                                    Text("Comments")
                                                        .font(Font.custom(Fonts.product_medium, size: 13))
                                                        .foregroundColor(Color.init(hex: Colors.color_F6))
                                                    Text("\(bookingDataObserver.bookingDatasetObserver?.specific_complaints ?? "") \(bookingDataObserver.bookingDatasetObserver?.specific_services ?? "") \(bookingDataObserver.bookingDatasetObserver?.specific_repairs ?? "")")
                                                        .multilineTextAlignment(.leading)
                                                        .font(Font.custom(Fonts.product_medium, size: 13))
                                                        .foregroundColor(Color.init(hex: Colors.color_F6))
                                                }
                                                Spacer()
                                            }
                                            .frame(width: geometry.size.width * 0.8)
                                            //                                            Spacer()
                                            
                                        }
                                    }
                                }
                            }
                            
                            //MARK: Jobcard Details
                            else{
                                //
                                VStack{
                                    Button(){
                                        jobCardObserver.getJobCardDetail(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!))
                                        
                                        self.isBookingDetailsOpen = false
                                        //self.isJobCardOpen = false
                                        self.isBookingTrackingOpen = false
                                        self.isPaymentDetailsOpen = false
                                        self.isServiceDetailsOpen = false
                                        self.isReccomendationOpen = false
                                        
                                    }label: {
                                        HStack{
                                            Text("Jobcard Details")
                                                .font(Font.custom(Fonts.product_medium, size: 15))
                                                .foregroundColor(.black)
                                            
                                            Spacer()
                                            
                                            if isJobCardOpen == false{
                                                Image("openList")
                                                    .resizable()
                                                    .frame(width: 12, height: 7)
                                            }else{
                                                Image("closeList")
                                                    .resizable()
                                                    .frame(width: 12, height: 7)
                                            }
                                        }
                                        .frame(width: geometry.size.width * 0.8)
                                    }
                                    .padding([.leading, .trailing, .top], 10)
                                    
                                    
                                    if isJobCardOpen{
                                        HStack{
                                            
                                            Text("Name")
                                                .font(Font.custom(Fonts.product_medium, size: 12))
                                                .foregroundColor(.black)
                                                .frame(width: 127, alignment: .leading)
                                            
                                            Text("Qty")
                                                .font(Font.custom(Fonts.product_medium, size: 12))
                                                .frame(width: 27)
                                            
                                            
                                            Text("Spares")
                                                .font(Font.custom(Fonts.product_medium, size: 12))
                                                .frame(width: 44)
                                            
                                            
                                            Text("Labour")
                                                .font(Font.custom(Fonts.product_medium, size: 12))
                                                .frame(width: 44)
                                            
                                            
                                            Text("Total")
                                                .font(Font.custom(Fonts.product_medium, size: 12))
                                                .frame(width: 40)
                                            
                                        }
                                        .padding([.top, .bottom], 5)
                                        .padding([.leading, .trailing], 15)
                                        .background(Color(red: 0.906, green: 0.91, blue: 0.914))
                                        .cornerRadius(10)
                                        .padding(.top, 10)
                                        //
                                        LazyVStack(alignment: .leading, spacing: 10){
                                            ForEach(jobCardObserver.store, id: \.self) {
                                                content in
                                                
                                                // Text("\(content.item_id)")
                                                //
                                                HStack(spacing: 10){
                                                    Text("\(content.item ?? " ")")
                                                        .font(Font.custom(Fonts.product_medium, size: 13))
                                                        .foregroundColor(Color.init(hex: Colors.color_F5))
                                                        .frame(width: 140, alignment: .leading)
                                                    //.background(.red)
                                                    
                                                    Text("\(content.qty ?? " ")")
                                                        .font(Font.custom(Fonts.product_medium, size: 12))
                                                        .foregroundColor(Color.init(hex: Colors.color_F5))
                                                        .frame(width: 27, alignment: .leading)
                                                    //.background(.yellow)
                                                    
                                                    
                                                    Text("\(rsUnicode) \(content.spares_rate ?? " ")")
                                                        .font(Font.custom(Fonts.product_medium, size: 12))
                                                        .foregroundColor(Color.init(hex: Colors.color_F5))
                                                        .frame(width: 44, alignment: .leading)
                                                    // .background(.orange)
                                                    
                                                    Text("\(rsUnicode) \(content.labour_rate ?? " " )")
                                                        .font(Font.custom(Fonts.product_medium, size: 12))
                                                        .foregroundColor(Color.init(hex: Colors.color_F5))
                                                        .frame(width: 44, alignment: .leading)
                                                    // .background(.cyan)
                                                    
                                                    Text("\(rsUnicode) \(content.amount ?? " ")")
                                                        .font(Font.custom(Fonts.product_medium, size: 12))
                                                        .foregroundColor(Color.init(hex: Colors.color_F5))
                                                        .frame(width: 44, alignment: .leading)
                                                    // .background(.yellow)
                                                }
                                                .padding([.leading, .trailing], 10)
                                                //
                                                //
                                                //
                                                
                                            }
                                        }.frame(width: geometry.size.width * 0.9, alignment: .leading)
                                        //.background(.red)
                                        //                                                .padding(.leading, 20)
                                    }
                                    Divider()
                                        .padding(.top, 10)
                                }
                            }
                            
                            // MARK: Booking Tracking
                            VStack{
                                Button(){
                                    self.isBookingTrackingOpen.toggle()
                                    
                                    self.isBookingDetailsOpen = false
                                    self.isJobCardOpen = false
                                    //self.isBookingTrackingOpen = false
                                    self.isPaymentDetailsOpen = false
                                    self.isServiceDetailsOpen = false
                                    self.isReccomendationOpen = false
                                }label: {
                                    HStack{
                                        Text("Booking Tracking")
                                            .font(Font.custom(Fonts.product_medium, size: 15))
                                            .foregroundColor(.black)
                                        
                                        Spacer()
                                        
                                        if isBookingTrackingOpen == false{
                                            Image("openList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }else{
                                            Image("closeList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }
                                    }
                                    .frame(width: geometry.size.width * 0.8)
                                }
                                .padding([.leading, .trailing, .top], 10)
                                Divider()
                                    .padding(.top, 10)
                                
                                
                                //Booking tracking content
                                
                                if isBookingTrackingOpen{
                                    
                                    
                                    
                                    VStack(alignment: HorizontalAlignment.leading, spacing: 0) {
                                        ForEach(bookingDetailObserver.bookingDetailModelObserver?.service_tracker ?? [], id: \.self){ trackService in
                                            
                                            HStack {
                                                if trackService.action == "completed" {
                                                    Image(trackService.active == "0" ? "completedRadioButton" : "ongoingRadioButton").frame(width: 30)
                                                } else {
                                                    Image("pendingRadioButton").frame(width: 30)
                                                }
                                                Text("\(trackService.title ?? "")")
                                                    .font(Font.custom(Fonts.product_medium, size: 15))
                                                Spacer()
                                            }
                                            
                                            HStack{
                                                if trackService.title != "Booking Completed"{
                                                    if trackService.action == "completed" && trackService.active == "0"{
                                                        Rectangle().fill(Color.blue).frame(width: 2, height: trackService.details == "" ? 15 : 29, alignment: .center).padding(.leading, 14)
                                                    }
                                                    else{
                                                        Rectangle().fill(Color.gray).frame(width: 2, height: trackService.details == "" ? 15 : 29, alignment: .center).padding(.leading, 14)
                                                    }
                                                }
                                                
                                                Text("\(trackService.details ?? "")")
                                                    .foregroundColor(Color.init(hex: Colors.color_F5))
                                                    .font(Font.custom(Fonts.product_regular, size: 12))
                                                    .padding(.leading)
                                                    .padding(.bottom, trackService.details == "" ? 0 : 15)
                                                    .frame(width: geometry.size.width * 0.8, alignment: .topLeading)
                                            }
                                            
                                            
                                            //.background()
                                        }
                                        
                                    }
                                    .padding(10)
                                    .background()
                                    
                                    
                                    Divider()
                                    
                                }
                            }
                            
                            //MARK: Payment Details
                            VStack{
                                Button(){
                                    self.isPaymentDetailsOpen.toggle()
                                    
                                    self.isBookingDetailsOpen = false
                                    self.isJobCardOpen = false
                                    self.isBookingTrackingOpen = false
                                    //self.isPaymentDetailsOpen = false
                                    self.isServiceDetailsOpen = false
                                    self.isReccomendationOpen = false
                                }label: {
                                    HStack{
                                        Text("Payment Details")
                                            .font(Font.custom(Fonts.product_medium, size: 15))
                                            .foregroundColor(.black)
                                        
                                        Spacer()
                                        
                                        if isPaymentDetailsOpen == false{
                                            Image("openList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }else{
                                            Image("closeList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }
                                    }
                                    .frame(width: geometry.size.width * 0.8)
                                }
                                .padding([.leading, .trailing, .top], 10)
                                Divider()
                                    .padding(.top, 10)
                                //Content of Payment Details
                                if isPaymentDetailsOpen{
                                    VStack(alignment: .leading ,spacing: 10){
                                        HStack{
                                            Text("Estimated Amount :")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                            Spacer()
                                            
                                            Text("\(rsUnicode) \(bookingDataObserver.bookingDatasetObserver?.payment_details?.estimated_amount ?? "0")")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                            
                                        }
                                        HStack{
                                            Text("Additional :")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                            Spacer()
                                            
                                            Text("\(rsUnicode) \(bookingDataObserver.bookingDatasetObserver?.payment_details?.discount ?? "0")")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                        }
                                        
                                        HStack{
                                            Text("Booking Fee Paid Total :")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                            Spacer()
                                            
                                            Text("\(rsUnicode) \(bookingDataObserver.bookingDatasetObserver?.payment_details?.booking_fee ?? "")")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                        }
                                        
                                        HStack{
                                            Text("Wallet Used :")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                            Spacer()
                                            
                                            Text("\(rsUnicode) \(bookingDataObserver.bookingDatasetObserver?.payment_details?.wallet_used ?? "")")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                        }
                                        
                                        HStack{
                                            Text("Payable Amount :")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                            Spacer()
                                            
                                            Text("\(rsUnicode) \(bookingDataObserver.bookingDatasetObserver?.payment_details?.payable_amount ?? "")")
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                        }
                                        
                                    }
                                    .padding()
                                    Divider()
                                }
                                
                            }
                            
                            //MARK: Service details
                            VStack{
                                Button(){
                                    self.isServiceDetailsOpen.toggle()
                                    
                                    self.isBookingDetailsOpen = false
                                    self.isJobCardOpen = false
                                    self.isBookingTrackingOpen = false
                                    self.isPaymentDetailsOpen = false
                                    //self.isServiceDetailsOpen = false
                                    self.isReccomendationOpen = false
                                    
                                }label: {
                                    HStack{
                                        Text("Service Details")
                                            .font(Font.custom(Fonts.product_medium, size: 15))
                                            .foregroundColor(.black)
                                        Spacer()
                                        
                                        if isServiceDetailsOpen == false{
                                            Image("openList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }else{
                                            Image("closeList")
                                                .resizable()
                                                .frame(width: 12, height: 7)
                                        }
                                    }
                                    .frame(width: geometry.size.width * 0.8)
                                    
                                }
                                .padding([.leading, .trailing, .top], 10)
                                Divider()
                                    .padding(.top, 10)
                                
                                //content of Service details
                                if isServiceDetailsOpen{
                                    VStack(alignment: .leading ,spacing: 10){
                                        HStack{
                                            Text("Name :")
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                                .foregroundColor(Color.init(hex: Colors.color_F6))
                                            
                                            Spacer()
                                            
                                            Text(bookingDataObserver.bookingDatasetObserver?.service_category_name ?? "")
                                                .font(Font.custom(Fonts.product_medium, size: 13))
                                            
                                        }
                                        if bookingDataObserver.bookingDatasetObserver?.payment_details?.coupon_code != ""{
                                            HStack{
                                                Text("Coupon :")
                                                    .font(Font.custom(Fonts.product_medium, size: 13))
                                                    .foregroundColor(Color.init(hex: Colors.color_F6))
                                                
                                                Spacer()
                                                
                                                Text(bookingDataObserver.bookingDatasetObserver?.payment_details?.coupon_code ?? "")
                                                    .font(Font.custom(Fonts.product_medium, size: 13))
                                            }
                                        }
                                        if bookingDataObserver.bookingDatasetObserver?.specific_complaints ?? "" != ""{
                                            HStack{
                                                Button(){
                                                    self.isComplaintOpen.toggle()
                                                }label: {
                                                    Text("Complaint: ")
                                                        .font(Font.custom(Fonts.product_medium, size: 13))
                                                        .foregroundColor(Color.init(hex: Colors.color_F6))
                                                    
                                                    Spacer()
                                                    
                                                    if isComplaintOpen == false{
                                                        Image("openList")
                                                            .resizable()
                                                            .frame(width: 12, height: 7)
                                                    }else{
                                                        Image("closeList")
                                                            .resizable()
                                                            .frame(width: 12, height: 7)
                                                    }
                                                }
                                            }
                                            if isComplaintOpen{
                                                VStack{
                                                    Text("\(bookingDataObserver.bookingDatasetObserver?.specific_complaints ?? "")")
                                                        .font(Font.custom(Fonts.product_medium, size: 13))
                                                        .foregroundColor(Color.init(hex: Colors.color_F6))
                                                        .multilineTextAlignment(.leading)
                                                        .frame(alignment: .leading)
                                                }
                                                .frame(alignment: .leading)
                                            }
                                        }
                                        
                                    }
                                    .padding()
                                    Divider()
                                    
                                }
                                
                            }
                            
                        }
                        .padding(.top)
                    }
                    .frame(width: geometry.size.width * 0.9)
                    .background()
                    .cornerRadius(20)
                    
                    //                Spacer()
                }.frame(width:geometry.size.width, height:geometry.size.height * 0.97,alignment: .top)
                    .background(Color.init(hex: Colors.color_gr))
                    .cornerRadius(30, corners: [.topLeft, .topRight])
                
                //                .edgesIgnoringSafeArea(.bottom)
                //.padding()
            }
            .showToast(text: $showJobcardText)
            .showProgressView(showProgress: $showProgress)
            .onChange(of: jobCardObserver.showProgress, perform: {_ in
                self.showProgress = jobCardObserver.showProgress
                if !jobCardObserver.showProgress {
                    if jobCardObserver.store.isEmpty{     // if response null
                        self.showJobcardText = "Jobcard Not Created"
                    }else{
                        self.isJobCardOpen.toggle()
                    }
                }
            })
            
            .onAppear(){
                bookingDetailObserver.getBookingDetails(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!), customer_id: (UserDefaults.standard.string(forKey: "customer_id")!))
                bookingDataObserver.getBookingDataSet(customer_id: (UserDefaults.standard.string(forKey: "customer_id")!), booking_id: (UserDefaults.standard.string(forKey: "booking_id")!))
                serviceReport.getServiceReport(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!))
                showProgress = false
                bookingID = bookingDataObserver.bookingDatasetObserver?.booking_id ?? ""
                is_reschedule = bookingDataObserver.bookingDatasetObserver?.is_reschedule ?? -1
            }
            .refreshable {
                print("Do your refresh work here")
                bookingDetailObserver.getBookingDetails(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!), customer_id: (UserDefaults.standard.string(forKey: "customer_id")!))
                bookingDataObserver.getBookingDataSet(customer_id: (UserDefaults.standard.string(forKey: "customer_id")!), booking_id: (UserDefaults.standard.string(forKey: "booking_id")!))
                serviceReport.getServiceReport(booking_id: (UserDefaults.standard.string(forKey: "booking_id")!))
            }
        }
        //        }
    }
}

//struct BookingDetailsView_Previews: PreviewProvider {
//    static var previews: some View {
//        BookingDetailsView(price: .constant(""))
//    }
//}