//
//  LiveReservationCompleteView.swift
//  SodaLive
//
//  Created by klaus on 2023/08/11.
//

import SwiftUI

struct LiveReservationCompleteView: View {
    
    let reservationCompleteData: MakeLiveReservationResponse
    
    var body: some View {
        BaseView {
            VStack(spacing: 0) {
                DetailNavigationBar(title: "라이브 예약 완료") {
                    AppState.shared.setAppStep(step: .main)
                }
                
                ScrollView(.vertical, showsIndicators: false) {
                    VStack(spacing: 0) {
                        Text("예약이 완료되었습니다.")
                            .font(.custom(Font.bold.rawValue, size: 20))
                            .foregroundColor(Color(hex: "a285eb"))
                            .frame(width: screenSize().width - 26.7, alignment: .leading)
                            .padding(.top, 20)
                        
                        Image("img_compleate_book")
                            .resizable()
                            .scaledToFit()
                            .frame(width: 233.25)
                            .padding(.top, 16.7)
                            .padding(.bottom, 26.7)
                        
                        Text("라이브 예약정보")
                            .font(.custom(Font.bold.rawValue, size: 16.7))
                            .foregroundColor(Color(hex: "eeeeee"))
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                        
                        VStack(spacing: 6.7) {
                            HStack(spacing: 26.7) {
                                Text("채널")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Text(reservationCompleteData.nickname)
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                            
                            HStack(spacing: 26.7) {
                                Text("구매내역")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Text(reservationCompleteData.title)
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                            
                            HStack(spacing: 26.7) {
                                Text("예약일자")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Text(reservationCompleteData.beginDateString)
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                            
                            HStack(spacing: 26.7) {
                                Text("라이브 비용")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Text(reservationCompleteData.price)
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                        }
                        .padding(.top, 16.7)
                        
                        Rectangle()
                            .frame(width: screenSize().width, height: 6.7)
                            .foregroundColor(Color(hex: "232323"))
                            .padding(.vertical, 20)
                        
                        Text("결제정보")
                            .font(.custom(Font.bold.rawValue, size: 16.7))
                            .foregroundColor(Color(hex: "eeeeee"))
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                        
                        VStack(spacing: 13.3) {
                            HStack(spacing: 0) {
                                Text("보유캔")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Spacer()
                                
                                Text("\(reservationCompleteData.haveCan)")
                                    .font(.custom(Font.bold.rawValue, size: 15.3))
                                    .foregroundColor(Color(hex: "eeeeee"))
                                
                                Text(" 캔")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                            
                            HStack(spacing: 0) {
                                Text("결제캔")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Spacer()
                                
                                Text("\(reservationCompleteData.useCan)")
                                    .font(.custom(Font.bold.rawValue, size: 15.3))
                                    .foregroundColor(Color(hex: "eeeeee"))
                                
                                Text(" 캔")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                            
                            HStack(spacing: 0) {
                                Text("잔여캔")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "777777"))
                                
                                Spacer()
                                
                                Text("\(reservationCompleteData.remainingCan)")
                                    .font(.custom(Font.bold.rawValue, size: 15.3))
                                    .foregroundColor(Color(hex: "eeeeee"))
                                
                                Text(" 캔")
                                    .font(.custom(Font.medium.rawValue, size: 14.7))
                                    .foregroundColor(Color(hex: "eeeeee"))
                            }
                            .frame(width: screenSize().width - 53.4, alignment: .leading)
                        }
                        .padding(.top, 20)
                        
                        HStack(spacing: 13.3) {
                            Text("홈으로 이동")
                                .font(.custom(Font.bold.rawValue, size: 18.3))
                                .foregroundColor(Color(hex: "9970ff"))
                                .padding(.vertical, 16)
                                .frame(width: (screenSize().width - 40) / 2)
                                .background(Color(hex: "9970ff").opacity(0.2))
                                .cornerRadius(10)
                                .overlay(
                                    RoundedRectangle(cornerRadius: 10)
                                        .stroke(lineWidth: 1)
                                        .foregroundColor(Color(hex: "9970ff"))
                                )
                                .onTapGesture {
                                    AppState.shared.setAppStep(step: .main)
                                }
                            
                            Text("예약 내역 이동")
                                .font(.custom(Font.bold.rawValue, size: 18.3))
                                .foregroundColor(.white)
                                .padding(.vertical, 16)
                                .frame(width: (screenSize().width - 40) / 2)
                                .background(Color(hex: "9970ff"))
                                .cornerRadius(10)
                                .onTapGesture {
                                    AppState.shared.setAppStep(step: .liveReservation)
                                }
                        }
                        .padding(.vertical, 26.7)
                    }
                }
            }
        }
    }
}

struct LiveReservationCompleteView_Previews: PreviewProvider {
    static var previews: some View {
        LiveReservationCompleteView(
            reservationCompleteData: MakeLiveReservationResponse(
                reservationId: 10,
                nickname: "김상담",
                title: "여자들이 좋아하는 남자 스타일은?",
                beginDateString: "2021년 7월 9일 (금), 오후 02:00",
                price: "무료",
                haveCan: 100,
                useCan: 0,
                remainingCan: 100
            )
        )
    }
}