package com.nivesh.production.partnerOnBoarding.ui.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.nivesh.production.partnerOnBoarding.R
import com.nivesh.production.partnerOnBoarding.databinding.FragmentPaymentBinding
import com.nivesh.production.partnerOnBoarding.ui.activities.BaseActivity
import com.nivesh.production.partnerOnBoarding.ui.activities.SignUpActivity

class PaymentFragment : BaseFragment() {

    private var _binding: FragmentPaymentBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        _binding = FragmentPaymentBinding.inflate(inflater,container,false)
        return binding.root
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        init()
    }

    private fun init() {

        binding.btnApplyNow.setOnClickListener{
            setUpFragment()
        }

        binding.header.tvSkip.setOnClickListener{
            setUpFragment()
        }

        binding.header.ivBack.setOnClickListener{
            (activity as SignUpActivity).onBackPressedDispatcher.onBackPressed()
        }

        binding.header.tvSkip.setOnClickListener{
            setUpFragment()
        }
    }

    private fun setUpFragment() {
        val bundle = Bundle()
        bundle.putSerializable("mobile", arguments?.getString("mobile")!!)
        bundle.putSerializable("email", arguments?.getString("email")!!)
        bundle.putString("arnType",arguments?.getString("arnType"))
        var fragment = SaveEAgreementFragment()
        fragment.arguments = bundle
        replaceFragment(
            activity as BaseActivity,
            R.id.signUpContainer,
            fragment,
            "AlmostThereFragment",
            true
        )
    }
}