import { Collapse, Form, Input, InputNumber, Select, Switch } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectBodyshop } from "../../redux/user/user.selectors";
import FormDatePicker from "../form-date-picker/form-date-picker.component";
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
import FormItemEmail from "../form-items-formatted/email-form-item.component";
import FormItemPhone, {
  PhoneItemFormatterValidation,
} from "../form-items-formatted/phone-form-item.component";
import JobsDetailRatesChangeButton from "../jobs-detail-rates-change-button/jobs-detail-rates-change-button.component";
import JobsDetailRatesParts from "../jobs-detail-rates/jobs-detail-rates.parts.component";
import JobsMarkPstExempt from "../jobs-mark-pst-exempt/jobs-mark-pst-exempt.component";
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
const mapStateToProps = createStructuredSelector({
  //currentUser: selectCurrentUser
  bodyshop: selectBodyshop,
});
const mapDispatchToProps = (dispatch) => ({
  //setUserLanguage: language => dispatch(setUserLanguage(language))
});

export function JobsCreateJobsInfo({ bodyshop, form, selected }) {
  const { t } = useTranslation();
  const { getFieldValue } = form;
  return (
    <div>
      <Collapse defaultActiveKey="insurance">
        <Collapse.Panel
          key="insurance"
          header={t("menus.jobsdetail.insurance")}
        >
          <LayoutFormRow>
            <Form.Item label={t("jobs.fields.ins_co_id")} name="ins_co_id">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.policy_no")} name="policy_no">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.clm_no")} name="clm_no">
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.regie_number")}
              name="regie_number"
            >
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.loss_date")} name="loss_date">
              <FormDatePicker />
            </Form.Item>
            <Form.Item label={t("jobs.fields.ins_co_nm")} name="ins_co_nm">
              <Select>
                {bodyshop.md_ins_cos.map((s) => (
                  <Select.Option key={s.name} value={s.name}>
                    {s.name}
                  </Select.Option>
                ))}
              </Select>
            </Form.Item>
            <Form.Item label={t("jobs.fields.ins_addr1")} name="ins_addr1">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.ins_city")} name="ins_city">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.ins_ct_ln")} name="ins_ct_ln">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.ins_ct_fn")} name="ins_ct_fn">
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.ins_ph1")}
              name="ins_ph1"
              rules={[
                ({ getFieldValue }) =>
                  PhoneItemFormatterValidation(getFieldValue, "ins_ph1"),
              ]}
            >
              <FormItemPhone />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.ins_ea")}
              name="ins_ea"
              rules={[
                {
                  type: "email",
                  message: "This is not a valid email address.",
                },
              ]}
            >
              <FormItemEmail email={getFieldValue("ins_ea")} />
            </Form.Item>

            <Form.Item label={t("jobs.fields.est_co_nm")} name="est_co_nm">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.est_ct_fn")} name="est_ct_fn">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.est_ct_ln")} name="est_ct_ln">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.est_ph1")} name="est_ph1">
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.est_ea")}
              name="est_ea"
              rules={[
                {
                  type: "email",
                  message: "This is not a valid email address.",
                },
              ]}
            >
              <FormItemEmail email={getFieldValue("est_ea")} />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.selling_dealer")}
              name="selling_dealer"
            >
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.servicing_dealer")}
              name="servicing_dealer"
            >
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.selling_dealer_contact")}
              name="selling_dealer_contact"
            >
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.servicing_dealer_contact")}
              name="servicing_dealer_contact"
            >
              <Input />
            </Form.Item>
          </LayoutFormRow>
        </Collapse.Panel>
        <Collapse.Panel key="claim" header={t("menus.jobsdetail.claimdetail")}>
          <LayoutFormRow>
            <Form.Item label={t("jobs.fields.loss_desc")} name="loss_desc">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.loss_of_use")} name="loss_of_use">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.ponumber")} name="po_number">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.unitnumber")} name="unit_number">
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.specialcoveragepolicy")}
              valuePropName="checked"
              name="special_coverage_policy"
            >
              <Switch />
            </Form.Item>
            <Form.Item label={t("jobs.fields.kmin")} name="kmin">
              <Input />
            </Form.Item>
            <Form.Item label={t("jobs.fields.kmout")} name="kmout">
              <Input />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.referralsource")}
              name="referral_source"
            >
              <Select>
                {bodyshop.md_referral_sources.map((s) => (
                  <Select.Option key={s} value={s}>
                    {s}
                  </Select.Option>
                ))}
              </Select>
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.referral_source_extra")}
              name="referral_source_extra"
            >
              <Input />
            </Form.Item>
          </LayoutFormRow>
        </Collapse.Panel>
        <Collapse.Panel
          key="financial"
          header={t("menus.jobsdetail.financials")}
        >
          <JobsDetailRatesChangeButton form={form} />
          <JobsMarkPstExempt form={form} />
          <LayoutFormRow>
            <Form.Item label={t("jobs.fields.ded_amt")} name="ded_amt">
              <CurrencyInput min={0} />
            </Form.Item>
            <Form.Item label={t("jobs.fields.ded_status")} name="ded_status">
              <Select>
                <Select.Option value="W">
                  {t("jobs.labels.deductible.waived")}
                </Select.Option>
                <Select.Option value="Y">
                  {t("jobs.labels.deductible.stands")}
                </Select.Option>
              </Select>
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.depreciation_taxes")}
              name="depreciation_taxes"
            >
              <CurrencyInput />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.ca_gst_registrant")}
              name="ca_gst_registrant"
              valuePropName="checked"
            >
              <Switch />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.other_amount_payable")}
              name="other_amount_payable"
            >
              <CurrencyInput />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.towing_payable")}
              name="towing_payable"
            >
              <CurrencyInput />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.storage_payable")}
              name="storage_payable"
            >
              <CurrencyInput />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.adjustment_bottom_line")}
              name="adjustment_bottom_line"
            >
              <CurrencyInput />
            </Form.Item>
          </LayoutFormRow>
          <LayoutFormRow>
            <Form.Item
              label={t("jobs.fields.federal_tax_rate")}
              name="federal_tax_rate"
            >
              <InputNumber min={0} max={1} precision={2} />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.state_tax_rate")}
              name="state_tax_rate"
            >
              <InputNumber min={0} max={1} precision={2} />
            </Form.Item>
            <Form.Item
              label={t("jobs.fields.local_tax_rate")}
              name="local_tax_rate"
            >
              <InputNumber min={0} max={1} precision={2} />
            </Form.Item>
          </LayoutFormRow>
          <LayoutFormRow>
            <Form.Item label={t("jobs.fields.rate_lab")} name="rate_lab">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_lad")} name="rate_lad">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_lae")} name="rate_lae">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_lar")} name="rate_lar">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_las")} name="rate_las">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_laf")} name="rate_laf">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_lam")} name="rate_lam">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_lag")} name="rate_lag">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_lau")} name="rate_lau">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_la1")} name="rate_la1">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_la2")} name="rate_la2">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_la3")} name="rate_la3">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_la4")} name="rate_la4">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_mapa")} name="rate_mapa">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_mash")} name="rate_mash">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_mahw")} name="rate_mahw">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_ma2s")} name="rate_ma2s">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_ma3s")} name="rate_ma3s">
              <CurrencyInput />
            </Form.Item>
            {
              // <Form.Item label={t("jobs.fields.rate_mabl")} name="rate_mabl">
              //   <CurrencyInput />
              // </Form.Item>
              // <Form.Item label={t("jobs.fields.rate_macs")} name="rate_macs">
              //   <CurrencyInput />
              // </Form.Item>
            }
            <Form.Item label={t("jobs.fields.rate_matd")} name="rate_matd">
              <CurrencyInput />
            </Form.Item>
            <Form.Item label={t("jobs.fields.rate_laa")} name="rate_laa">
              <CurrencyInput />
            </Form.Item>
          </LayoutFormRow>
        </Collapse.Panel>
      </Collapse>
      <JobsDetailRatesParts
        jobRO={false}
        expanded
        required={selected && true}
        form={form}
      />
    </div>
  );
}
export default connect(mapStateToProps, mapDispatchToProps)(JobsCreateJobsInfo);
