import {
  Alert,
  Image,
  ScrollView,
  StyleSheet,
  Text,
  View,
  BackHandler,
  Platform,
  Dimensions,
  KeyboardAvoidingView,
  TouchableOpacity,
} from "react-native";
import React, { useEffect, useRef, useState } from "react";
import Header from "react-native-digitcamera/src/Screens/Header";
import SqureRadio from "react-native-digitcamera/src/common/SqureRadio";
import { translate } from "react-native-digitcamera/src/common/localize/i18n";
import {
  TextInput,
  PrimaryButton,
  NewRoundButton,
  Spinner,
  NewRadioButton,
} from "react-native-digitcamera/src/common/ThemedComponents";
import ProductCard from "react-native-digitcamera/src/common/ProductCard";
import Colors from "../common/Colors";
import { renderErrorMsge } from "react-native-digitcamera/src/common/Validation";
import { getActivityid } from "react-native-digitcamera/src/common/Services/getActivityid";
import reactotron from "reactotron-react-native";
import { useDispatch } from "react-redux";
import Database from "../../../../Components/common/DAsyncStorage";
import Modal from "react-native-digitcamera/src/common/Modal";
import Orientation from "react-native-orientation";
import {
  ACTIVITY_TYPE_MOTOR_4W_OD_NB_PRE_INSPECTION_SELF_SURVEY,
  canGoVideoPi,
  is2Wflow,
  isCVFlow,
} from "../common/Constants";
import NetInfo from "@react-native-community/netinfo";

import {
  REGISTRATION_NUMBER_REGX,
  BHSERIES_REGISTRATION_NUMBER_REGX,
  // SCREEN_HEIGHT,
  // SCREEN_WIDTH,
} from "react-native-digitcamera/src/common/Constants";
import {
  errorRecord,
  firebaseAttributes,
  firebaseEvents,
} from "../common/libEventLog/libCrashlytics/libCrashlyticsEvent";
import {
  UELogEvent,
  UELogMessage,
} from "../common/libEventLog/UserExperior/LibUserExperior";
import CommonStyle from "../common/CommonStyle";
import style from "../common/CommonStyle";
import {
  checkInternetSpeed,
  checkMLAvailable,
  getUserType,
} from "react-native-digitcamera/src/Screens/OfflineFlow/CommonFunc";
import moment from "moment";

const girl_selfi = require("../common/Image/girl_selfi.png");
const car = require("../common/Image/new/four_wheeler.png");
const Bike = require("../common/Image/new/two_wheeler.png");
const cv = require("../common/Image/new/cv.png");
const iOS = Platform.OS === "ios";

const NCB_SLABS = [
  { ncb: 0, name: "0%", id: 1, value: "ZERO" },
  { ncb: 20, name: "20%", id: 2, value: "TWENTY" },
  { ncb: 25, name: "25%", id: 3, value: "TWENTY_FIVE" },
  { ncb: 35, name: "35%", id: 4, value: "THIRTY_FIVE" },
  { ncb: 45, name: "45%", id: 5, value: "FORTY_FIVE" },
  { ncb: 50, name: "50%", id: 6, value: "FIFTY" },
].reverse();

const getMinWidth = () => {
  let maxHeight, minWidth;
  minWidth = Math.round(
    Math.min(Dimensions.get("screen").height, Dimensions.get("screen").width)
  );
  maxHeight = Math.round(
    Math.max(Dimensions.get("screen").height, Dimensions.get("screen").width)
  );
  return { maxHeight, minWidth };
};
/*Initial SCREEN_WIDTH*/
const { maxHeight, minWidth } = getMinWidth();

let SCREEN_WIDTH = minWidth;
let SCREEN_HEIGHT = maxHeight;

const WithoutQuoteScreen = ({ navigation, route }) => {
  const [, updateState] = React.useState();
  const forceUpdate = React.useCallback(() => updateState({}), []);
  const [_4Wclicked, set4wclicked] = useState(true); // default FourWheller selected
  const [_2Wclicked, set2wclicked] = useState(false);
  const [cvclicked, setCVclicked] = useState(false);
  const [ncbDisabled, setncbDisabled] = useState(false);
  const [selectedNCB, setselectedNCB] = useState({ id: true, ncb: 0 });
  const [isVechicleTypeSelected, setIsVechicleTypeSelected] = useState(true);
  const [registrationNumber, setRegistrationNumber] = useState("");
  const [activityTypeId, setActivityTypeId] = useState(5);
  const [isLoading, setISsLoading] = useState(false);
  const [isPIModalVisible, setisPIModalVisible] = useState(false);
  const [vechicleType, setVechicleType] = useState("FourWheller");
  const [vechicleData, setVechicleData] = useState();
  const [PICompleteStatus, setPICompleteStatus] = useState();
  const [isNetworkAvailable, setIsNetworkAvailable] = useState(true);
  const [selected, setSelected] = useState(undefined);

  const dispatch = useDispatch();
  var unsubscribeNetInfo;

  useEffect(() => {
    // Orientation fix
    const { maxHeight, minWidth } = getMinWidth();
    SCREEN_WIDTH = minWidth;
    SCREEN_HEIGHT = maxHeight;

    if (!iOS) {
      const Immersive = require("react-native-immersive").Immersive;
      Immersive.setImmersive(false);
    }

    const getCustomer = async () => {
      const vehData = await Database.get("PIVechicleData");
      setVechicleData(vehData);
      const status = await Database.get("PICompleteStatus");
      setPICompleteStatus(status);
    };
    getCustomer();
    let unsubscribe = navigation.addListener("focus", () => {
      Orientation.lockToPortrait();
      unsubscribeNetInfo = NetInfo.addEventListener(async (state) => {
        console.log("In NetInfo ");
        if (state.isInternetReachable != null) {
          if (state.isInternetReachable && (await checkInternetSpeed())) {
            // Alert.alert("Connected")
            console.log(" WithOutQuote connected");
            setIsNetworkAvailable(true);
          } else {
            // Alert.alert("Not Connected")
            console.log(" WithOutQuote Not connected");
            setIsNetworkAvailable(false);

            UELogEvent("Offline Flow : withOutQuote.js", { mode: "offline" });
          }
        }
      });
    });
    return () => {
      unsubscribe();
      unsubscribeNetInfo && unsubscribeNetInfo();
    };
  }, []);
  const { agentEmail, agentName, agentMobile, toWithQuote, toTutorial } =
    route.params;

  var activityData;

  //to get activity id and activityTypeid
  const callGetActivityid = async () => {
    UELogMessage("callGetActivityId started");
    try {
      const { getUserDetails } = require("../common/Who");
      await getUserDetails();
      const {
        emailId,
        name,
        phoneNo,
        panHolderName,
        panNo,
        agentNumber,
      } = require("../common/Who");

      /*
       * For Customer phoneNo,panHolderName,panNo,agentId not required
       * Agent Flow Requires above fields
       *
       */

      const AppLoginStatus = await Database.get("AppLoginStatus");
      const USERTYPE = AppLoginStatus?.userType;

      let body;
      var userType = await getUserType();

      if (USERTYPE === "Customer") {
        body = {
          activityTypeId: activityTypeId,
          customerDetailData: {
            emailId: emailId,
            name: name,
            phoneNo: phoneNo,
          },
          licensePlateNumber: registrationNumber,
          previousPolicyExpired: true,
          quoteNumber: "",
          usrNcb: selectedNCB?.ncb,
          requestedBy: userType,
          appName: "Quick Scan",
        };
      } else if (USERTYPE === "DealerOrAgent") {
        body = {
          activityTypeId: activityTypeId,
          customerDetailData: {
            emailId: emailId,
            name: name,
            phoneNo: phoneNo,
            panHolderName: panHolderName,
            panNo: panNo,
          },
          agentId: agentNumber,
          licensePlateNumber: registrationNumber,
          previousPolicyExpired: true,
          quoteNumber: "",
          usrNcb: selectedNCB?.ncb,
          requestedBy: userType,
          appName: "Quick Scan",
        };
      }

      UELogEvent("callGetActivityid stoped in try", {
        body: JSON.stringify(body),
      });

      activityData = await getActivityid({ body });
      // Check if GDD
      getIsGDD(activityData?.activityTypeId);

      if (activityData.flag === "Manual Inspection") {
        UELogEvent("callGetActivityid stoped in flag Manual Inspection", {
          body: JSON.stringify(activityData),
        });
        setTimeout(() => {
          Alert.alert(
            "Alert!",
            "This make and model requires a manual inspection. We request you to reach out to your agent or Digit team at hello@godigit.com",
            [{ text: "OKAY", onPress: () => null }]
          );
        }, 100);
        setISsLoading(false);
        return;
      }

      // added data in redux
      dispatch({
        type: "ACTIVITY_DATA",
        payload: {
          activityId: activityData?.activityID,
          activityTypeId: activityTypeId,
          licensePlateNumber: registrationNumber,
          toWithQuote: true,
          quoteNumber: "",
        },
      });
      console.log("activityData?.activityTypeId", activityData?.activityTypeId);
      await Database.update("PIVechicleData", {
        activityId: activityData?.activityID,
        activityTypeId: activityData?.activityTypeId,
        licensePlateNumber: registrationNumber,
        toWithQuote: toWithQuote,
        toTutorial: toTutorial,
        quoteNumber: "",
        ncb: selectedNCB?.ncb,
        vechicleType: vechicleType,
      });
      await Database.update("PICompleteStatus", {
        piStatus: false,
      });

      setISsLoading(false);
      navigation.navigate("Toturial");
    } catch (error) {
      UELogEvent("callGetActivityid stopped in catch", {
        Error: JSON.stringify(error),
      });

      firebaseAttributes(error);
      errorRecord(error);
      console.log("@@@@@@@@@@@@", error);
      setTimeout(() => {
        Alert.alert(
          "Oops! Unable to proceed",
          "We are experiencing technical issue, Please try after sometime"
        );
      }, 100);
      setISsLoading(false);
    }
  };

  /* Check if the case is GDD then change the Header */
  const getIsGDD = async (activityTypeId) => {
    if (
      activityTypeId &&
      activityTypeId == ACTIVITY_TYPE_MOTOR_4W_OD_NB_PRE_INSPECTION_SELF_SURVEY
    ) {
      await Database.set("PIAppTitle", { title: "PAYD App" });
    } else {
      await Database.set("PIAppTitle", { title: "Pre Inspection" });
    }
  };

  const PreinspectionAlertUx = () => {
    return (
      <ScrollView>
        <View style={{ marginLeft: 16, marginRight: 16 }}>
          <Text
            style={{
              fontSize: 14,
              fontFamily: "Muli-Regular",
              marginBottom: 16,
              lineHeight: 22,
              marginTop: SCREEN_HEIGHT / 10,
            }}
          >
            {translate(
              "It seems like you are already in middle of a pre-inspection process You can either continue from where you left off or start from begining"
            )}
          </Text>
          {console.log("vechicleData?.piStatus", vechicleData?.piStatus)}
          {PICompleteStatus?.piStatus == true ? null : (
            <PrimaryButton
              onPress={async () => {
                firebaseEvents(
                  "Continue_Existing_Flow",
                  {
                    registrationNumber: registrationNumber,
                    vechicleType: vechicleType,
                    ncb: selectedNCB?.ncb,
                  },
                  activityData?.activityID,
                  activityTypeId,
                  ""
                );
                await realmStoreStartOver(false);
                setisPIModalVisible(false);
                navigation.navigate("Toturial");
              }}
            >
              {translate("Continue")}
            </PrimaryButton>
          )}

          <PrimaryButton
            onPress={async () => {
              firebaseEvents(
                "StartOver_Existing_Flow",
                {
                  registrationNumber: registrationNumber,
                  vechicleType: vechicleType,
                  ncb: selectedNCB?.ncb,
                },
                activityData?.activityID,
                activityTypeId,
                ""
              );
              setisPIModalVisible(false);
              setISsLoading(true);
              await clearAllRealmData();
              await clearRedux();
              await realmStoreStartOver(true);
              if (isNetworkAvailable) {
                callGetActivityid();
              } else {
                setISsLoading(false);
                saveDataInOfflineDb();
              }
            }}
            style={{
              backgroundColor: "#FFFFFF",
              borderWidth: 1,
              marginTop: 16,
              marginBottom: SCREEN_WIDTH / 10,
            }}
          >
            {translate("Start Over")}
          </PrimaryButton>
        </View>
      </ScrollView>
    );
  };

  const preInspectionAlert = () => {
    return (
      <View>
        <Modal
          isVisible={isPIModalVisible}
          onBackdropPress={() => setisPIModalVisible(false)}
          onClose={() => isPIModalVisible}
          heading={"Preinspection Alert!"}
          isTranslate={true}
          headerImageVisible={false}
        >
          {PreinspectionAlertUx()}
        </Modal>
      </View>
    );
  };

  // save vechicle details
  const saveDataInOfflineDb = async () => {
    var timeStamp = new Date().getTime();
    console.log("@@@@@", timeStamp);
    await Database.update("PIVechicleData", {
      activityId: "Offline_" + timeStamp,
      activityTypeId: activityTypeId,
      licensePlateNumber: registrationNumber,
      toWithQuote: toWithQuote,
      toTutorial: toTutorial,
      quoteNumber: "",
      ncb: 0,
      vechicleType: "",
    });
    navigation.navigate("Toturial", {
      isPAYD: selected === "Pay as you drive" ? true : false,
    });
  };

  const clearAllRealmData = async () => {
    try {
      await Database.remove("PIOfflineData");
      // await Database.remove("PIVechicleData");
      await Database.remove("PIVechicleInstruction");
      await Database.remove("PICompleteStatus");
      await Database.remove("PIOfflineVechicleData");
      await Database.remove("PIVideoCompleteStatus");
      await Database.update("PIRetryCount", {
        retryCount: 0,
        index: 0,
        isAddNewImageData: false,
      });

      await Database.update("PIGonePoseDetection", {
        GoneposeDetectionCount: 0,
      });

      await Database.update("PIPoseDetectionCompleted", {
        poseDetectionCompletedCount: 0,
      });

      await Database.update("PIclickedCount", {
        clickedCount: 0,
      });
      await Database.update("PIUploadedCount", {
        uploadedCount: 0,
      });
      // await Database.remove("PIMediaStatus"); //for Mult Activity
      await Database.remove("PIOnProgress");
      await Database.remove("PISuccessFlag");
      await Database.remove("PIReUploadFailed");
      await Database.remove("PIShouldCreateActivity");
    } catch (error) {
      firebaseAttributes(error);
      errorRecord(error);
    }
  };

  const clearRedux = () => {
    try {
      dispatch({
        type: "CLEAR_ACTIVITY_DATA",
      });
      dispatch({
        type: "CLEAR_IMAGE_CLICKED_COUNT_REDUX",
      });
      dispatch({
        type: "CLEAR_LAST_DATA_REDUX",
      });
      dispatch({
        type: "CLEAR_SENSOR_DETAILS_REDUX",
      });
      dispatch({
        type: "CLEAR_UPLOAD_IMAGE_REDUX",
      });
      dispatch({
        type: "CLEAR_UPLOAD_IMAGE_DATA_REDUX",
      });
      dispatch({
        type: "CLEAR_VEHICLE_DETAILS_REDUX",
      });
      dispatch({
        type: "CLEAR_RETRY_COUNT_REDUX",
      });
      dispatch({
        type: "CLEAR_RETRY_IMAGE_STATE",
      });
      dispatch({
        type: "CLEAR_RCB_DATA",
      });
      dispatch({
        type: "CLEAR_FAILED_DATA",
      });
      dispatch({
        type: "CLEAR_UPLOADING_DATA",
      });
      dispatch({
        type: "CLEAR_COMMON_FLAGS",
      });
    } catch (error) {
      firebaseAttributes(error);
      errorRecord(error);
    }
  };

  const checkPICondition = async () => {
    UELogEvent("checkPICondition Started", {
      "Registration Number": registrationNumber,
      NCB: 0,
      "Vehicle Type": vechicleType,
    });

    console.log(
      "*****************",
      vechicleData?.licensePlateNumber,
      registrationNumber
    );
    if (
      vechicleData?.licensePlateNumber == registrationNumber &&
      vechicleData?.ncb == selectedNCB?.ncb &&
      vechicleData?.vechicleType == vechicleType &&
      false // false indicates it will not ask "Continue" option if previously any pre-inspection done
    ) {
      UELogEvent("checkPICondition Ended in IF", {
        "Registration Number": registrationNumber,
        NCB: JSON.stringify(selectedNCB?.ncb),
        "Vehicle Type": vechicleType,
      });

      console.log("))))))))))))))))))))))))))))))))))))))))", selectedNCB?.ncb);
      setisPIModalVisible(true);
    } else {
      UELogEvent("checkPICondition ended in Else", {
        "Registration Number": registrationNumber,
        NCB: 0,
        "Vehicle Type": vechicleType,
      });

      UELogMessage("Continuing New Flow", {
        "Registration Number": registrationNumber,
        NCB: 0,
        "Vehicle Type": vechicleType,
        "Activity Id": activityData?.activityID,
        "Actiity Type Id": JSON.stringify(activityTypeId),
      });

      firebaseEvents(
        "Continue_New_Flow",
        {
          registrationNumber: registrationNumber,
          vechicleType: vechicleType,
          ncb: selectedNCB?.ncb,
        },
        activityData?.activityID,
        activityTypeId,
        ""
      );
      setISsLoading(true);
      setisPIModalVisible(false);
      await clearAllRealmData();
      await clearRedux();
      if (isNetworkAvailable) {
        callGetActivityid();
      } else {
        setISsLoading(false);
        saveDataInOfflineDb();
      }
    }
  };

  const realmStoreStartOver = async (status) => {
    try {
      await Database.update("PIStartOver", {
        isStartOver: status,
      });
    } catch (error) {
      firebaseAttributes(error);
      errorRecord(error);
    }
  };

  const logutAndNavigate = async () => {
    try {
      await Database.remove("AppLoginStatus");
      // Database.set("AppLoginStatus", {
      //   userType: undefined, // No one is logged in
      //   isAppLoging: false,
      // });

      try {
        const { name, routes } = route.params.props.navigation.getState();
        console.log("**** logutAndNavigate: " + JSON.stringify(routes));
        route.params.props.navigation.replace("CustomerDetails");
      } catch (error) {}
    } catch (error) {
      firebaseAttributes(error);
      console.log(error);
      console.log("Error : ", error);
    }
  };

  const logoutAlertModal = () => {
    Alert.alert("Logout", "Are you sure ?", [
      {
        text: "Yes",
        onPress: () => {
          logutAndNavigate();
        },
        style: "cancel",
      },
      {
        text: "No",
        onPress: () => {
          console.log("on No pressed");
        },
      },
    ]);
  };

  return (
    <KeyboardAvoidingView
      style={{ flex: 1, backgroundColor: Colors.white }}
      behavior={"padding"}
      enabled
    >
      <ScrollView
        style={{ flex: 1, backgroundColor: Colors.white }}
        keyboardShouldPersistTaps={iOS ? "always" : "handled"}
        keyboardDismissMode="on-drag"
      >
        <View style={styles.main}>
          <Spinner loading={isLoading} />
          <View style={{ marginHorizontal: 16 }}>
            <Header
              customTitle=""
              hideArrowBackButton={false}
              onlanguagechange={() => {
                forceUpdate();
              }}
              onbackPress={() => {
                navigation.goBack();
              }}
              isLogoutVisible={false}
              onLogoutPress={() => {
                logoutAlertModal();
              }}
            />
          </View>
          <View style={styles.subView}>
            {/* Image view */}
            <View style={styles.imageView}>
              <Text style={styles.subHeaderText}>
                {translate("Choose vehicle type")}
              </Text>

              <View
                style={{
                  flexDirection: "row",
                  justifyContent: "space-between",
                }}
              >
                {/* 4 W */}
                <ProductCard
                  imageSource={car}
                  title={translate("4 wheeler")}
                  key={"4 wheeler"}
                  onPress={() => {
                    set4wclicked(true);
                    set2wclicked(false);
                    setCVclicked(false);
                    setIsVechicleTypeSelected(true);
                    if (isNetworkAvailable) {
                      setActivityTypeId(5);
                    } else {
                      if (selected === "Pre Inspection") {
                        setActivityTypeId(5);
                      } else if (selected === "Pay as you drive") {
                        setActivityTypeId(63);
                      } else {
                        setActivityTypeId(5); //as nothing is selected
                        setSelected(undefined);
                      }
                    }
                    setVechicleType("FourWheller");
                  }}
                  style={{
                    width: "28%",
                    borderColor: _4Wclicked ? Colors.digitYellow : "#DDDDDD",
                    borderWidth: 1,
                    borderRadius: 4,
                    backgroundColor: "white",
                  }}
                />

                {/* 2 W */}
                <ProductCard
                  imageSource={Bike}
                  title={translate("2 wheeler")}
                  key={"2 wheeler"}
                  onPress={() => {
                    set4wclicked(false);
                    set2wclicked(true);
                    setCVclicked(false);
                    setIsVechicleTypeSelected(true);
                    setActivityTypeId(26);
                    setVechicleType("TwoWheeler");
                    setSelected("");
                  }}
                  style={{
                    width: "28%",
                    borderColor: _2Wclicked ? Colors.digitYellow : "#DDDDDD",
                    borderWidth: 1,
                    borderRadius: 4,
                    backgroundColor: "white",
                    marginRight: 8,
                  }}
                />

                <ProductCard
                  imageSource={cv}
                  title={translate("Commercial")}
                  key={"Commercial"}
                  onPress={() => {
                    set4wclicked(false);
                    set2wclicked(false);
                    setCVclicked(true);
                    setIsVechicleTypeSelected(true);
                    setActivityTypeId(30);
                    setVechicleType("Commercial");
                    setSelected("");
                  }}
                  style={{
                    width: "28%",
                    borderColor: cvclicked ? Colors.digitYellow : "#DDDDDD",
                    borderWidth: 1,
                    borderRadius: 4,
                    backgroundColor: "white",
                    marginRight: 8,
                  }}
                />
              </View>
              {!isVechicleTypeSelected ? (
                <Text
                  style={[
                    CommonStyle.errorText,
                    { marginLeft: 8, marginTop: -8 },
                  ]}
                >
                  {translate("Select Vechicle Type")}
                </Text>
              ) : null}

              {/* only available if device is offline */}
              {!isNetworkAvailable && !_2Wclicked && !cvclicked && (
                <View>
                  <Text style={styles.subHeaderText}>{"You are here for"}</Text>
                  <View
                    style={{
                      flexDirection: "row",
                      justifyContent: "space-between",
                      marginHorizontal: 8,
                    }}
                  >
                    <NewRadioButton
                      onPress={() => {
                        setSelected("Pre Inspection");
                      }}
                      enabled={selected === "Pre Inspection" ? true : false}
                      onSelected={() => {
                        setActivityTypeId(5);
                      }}
                    >
                      Pre Inspection
                    </NewRadioButton>
                    <NewRadioButton
                      onPress={() => {
                        setSelected("Pay as you drive");
                      }}
                      enabled={selected === "Pay as you drive" ? true : false}
                      onSelected={() => {
                        setActivityTypeId(63);
                      }}
                    >
                      Pay as you drive
                    </NewRadioButton>
                  </View>
                </View>
              )}

              <TextInput
                autoCapitalize="characters"
                style={{ marginLeft: 8, marginRight: 8, marginTop: 23 }}
                onChangeText={(value) => {
                  const newValue = value.replace(/ +/g, "");
                  setRegistrationNumber(newValue);
                }}
                label={"Enter Vehicle Registration Number"}
                maxLength={11}
                errorMsge={
                  registrationNumber.slice(0, 2).match("[A-Z]{2}")
                    ? registrationNumber.match(REGISTRATION_NUMBER_REGX) == null
                      ? renderErrorMsge({
                          type: "input",
                          text: "Registration Number",
                          style: { marginTop: 5 },
                        })
                      : null
                    : registrationNumber.match(
                        BHSERIES_REGISTRATION_NUMBER_REGX
                      ) == null
                    ? renderErrorMsge({
                        type: "input",
                        text: "Registration Number",
                        style: { marginTop: 5 },
                      })
                    : null
                }
              />
            </View>
            {/* <View
            style={{
              width: SCREEN_WIDTH - 48,
              height: 1,
              borderRightWidth: 1,
              borderColor: "#F5F5F5",
              backgroundColor: "#F5F5F5",
            }}
          /> */}
            {preInspectionAlert()}
            {/* Button view */}
            <View style={styles.buttonView}>
              <PrimaryButton
                style={{ marginTop: 24 }}
                disabled={
                  (isNetworkAvailable && canGoVideoPi(activityTypeId)) ||
                  is2Wflow(activityTypeId) ||
                  isCVFlow(activityTypeId)
                    ? isVechicleTypeSelected &&
                      registrationNumber.match(REGISTRATION_NUMBER_REGX)
                      ? false
                      : true
                    : isVechicleTypeSelected &&
                      registrationNumber.match(REGISTRATION_NUMBER_REGX) &&
                      !!selected
                    ? false
                    : true
                }
                onPress={async () => {
                  console.log(
                    "[Info] . WithoutQuoteScreen . Calling . activityTypeId: ",
                    activityTypeId
                  );
                  await realmStoreStartOver(true);
                  checkPICondition();
                }}
              >
                {translate("Continue")}
              </PrimaryButton>
              <NewRoundButton
                style={{
                  width: "80%",
                }}
                onPress={() => {
                  navigation.navigate("WithQuote");
                }}
              >
                I have a Quote/Policy Number
              </NewRoundButton>
            </View>
          </View>
        </View>
      </ScrollView>
    </KeyboardAvoidingView>
  );
};
export default WithoutQuoteScreen;

const styles = StyleSheet.create({
  main: {
    flex: 1,
    backgroundColor: "#FFFFFF",
  },
  imageView: {
    flex: 0.3,
    marginTop: 8,
  },
  textView: {
    flex: 0.55,
    marginLeft: 8,
  },
  buttonView: {
    flex: 0.15,
    marginLeft: 8,
  },
  welcomeText: {
    fontSize: 18,
    fontFamily: "Muli-ExtraBold",
    marginBottom: 9,
    marginTop: 52,
  },
  subText: {
    fontFamily: "Muli-Regular",
    fontSize: 14,
    marginBottom: 23,
  },
  subView: {
    flex: 1,
    marginLeft: 24,
    marginRight: 24,
  },
  subHeaderText: {
    fontSize: 16,
    fontFamily: "Muli-Bold",
    marginLeft: 8,
    marginBottom: 12,
  },
  ncbHeading: {
    fontFamily: "Muli-Bold",
    fontSize: 16,
    marginTop: 18,
    marginBottom: 12,
  },
});
