package kr.co.compcarecompany.Fragment.Join;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import kr.co.compcarecompany.Activity.FragmentActivity;
import kr.co.compcarecompany.R;

@SuppressLint("ValidFragment")
public class Join_Step_First_Fragment extends Fragment {

    private Handler handler, hdr;
    TextView join_pt_nameTV, join_pt_ceoTV, join_pt_codeTV, join_pt_telTV, join_pt_conditionTV, join_pt_addressTV, join_nextTV;
//    ArrayItem_<Partner> partnerItems;
//    Partner partnerData;
    FragmentActivity fa;
    String ag_idx, pt_idx, pt_name, pt_ceo, pt_code, pt_tel, pt_condition, pt_addr, pt_addr_sub;
    Bundle bundle;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        fa = (FragmentActivity) getActivity();
    }

    @Override
    public void onDetach() {
        super.onDetach();
        fa = null;
    }

    @SuppressLint("ValidFragment")
    public Join_Step_First_Fragment(Handler handler, Bundle bundle) {
        this.handler = handler;
        this.bundle = bundle;

    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.frag_join_step_first, container, false);

        join_pt_nameTV = v.findViewById(R.id.join_pt_nameTV);
        join_pt_ceoTV = v.findViewById(R.id.join_pt_ceoTV);
        join_pt_codeTV = v.findViewById(R.id.join_pt_codeTV);
        join_pt_telTV = v.findViewById(R.id.join_pt_telTV);
        join_pt_conditionTV = v.findViewById(R.id.join_pt_conditionTV);
        join_pt_addressTV = v.findViewById(R.id.join_pt_addressTV);
        join_nextTV = v.findViewById(R.id.join_nextTV);

        init_Listener();
        Set_Contents();

        return v;
    }

    void Set_Contents () {

        ag_idx = bundle.getString("ag_idx");
        pt_idx = bundle.getString("pt_idx");
        join_pt_nameTV.setText(bundle.getString("pt_name"));
        join_pt_ceoTV.setText(bundle.getString("pt_ceo"));
        join_pt_codeTV.setText(bundle.getString("pt_code"));
        join_pt_telTV.setText(bundle.getString("pt_tel"));
        join_pt_conditionTV.setText(bundle.getString("pt_condition"));
        join_pt_addressTV.setText(bundle.getString("pt_addr")+" "+bundle.getString("pt_addr_sub"));

    }

    void init_Listener() {

        join_nextTV.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(getContext(), FragmentActivity.class);
                intent.putExtra("title", "회원가입");
                intent.putExtra("type", "join_step_second");
                intent.putExtra("value1", ag_idx);
                intent.putExtra("value2", pt_idx);
                startActivity(intent);
                getActivity().finish();
            }
        });
    }

}
