// Generated by ReScript, PLEASE EDIT WITH CARE

import * as Cx from "rescript-classnames/src/Cx.bs.js";
import * as Curry from "rescript/lib/es6/curry.js";
import * as Icon3 from "../../Icon3.bs.js";
import * as React from "react";
import * as Belt_Option from "rescript/lib/es6/belt_Option.js";
import * as Caml_option from "rescript/lib/es6/caml_option.js";
import * as Types__Import from "../../../common/Types/Types__Import.bs.js";
import * as Table__Import__Upload from "./Table__Import__Upload.bs.js";
import * as Table__Import__Contact from "./Table__Import__Contact.bs.js";
import * as Table__Import__Extract from "./Table__Import__Extract.bs.js";
import * as Table__Import__AddressFull from "./Table__Import__AddressFull.bs.js";
import * as Table__Import__Coordinates from "./Table__Import__Coordinates.bs.js";
import * as Table__Import__AddressSplit from "./Table__Import__AddressSplit.bs.js";
import * as Table__Import__AddressPrompt from "./Table__Import__AddressPrompt.bs.js";
import * as Table__Import__ContactPrompt from "./Table__Import__ContactPrompt.bs.js";
import * as Table__Import__AddressPrompt2 from "./Table__Import__AddressPrompt2.bs.js";
import * as Table__Import__CoordinatesPrompt from "./Table__Import__CoordinatesPrompt.bs.js";

function Table__Import__Index(Props) {
  var onClose = Props.onClose;
  var onComplete = Props.onComplete;
  var spaceId = Props.spaceId;
  var teamId = Props.teamId;
  var match = React.useState(function () {
        var init = Types__Import.defaultImport.schema;
        return {
                NAME: "upload",
                VAL: {
                  file: Types__Import.defaultImport.file,
                  sourceColumns: Types__Import.defaultImport.sourceColumns,
                  targetColumns: Types__Import.defaultImport.targetColumns,
                  schema: {
                    targetTeamId: init.targetTeamId,
                    maptableName: init.maptableName,
                    existingMaptableId: spaceId !== undefined ? Caml_option.valFromOption(spaceId) : undefined,
                    source: init.source,
                    locate: init.locate,
                    contacts: init.contacts,
                    fields: init.fields,
                    isTemplate: init.isTemplate
                  }
                }
              };
      });
  var setImportState = match[1];
  var importState = match[0];
  var handleBack = function ($$import) {
    var data = Belt_Option.getWithDefault($$import, Types__Import.defaultImport);
    if (typeof importState !== "object") {
      return ;
    }
    var variant = importState.NAME;
    if (variant === "contactPrompt") {
      return Curry._1(setImportState, (function (param) {
                    return {
                            NAME: "addressPrompt",
                            VAL: data
                          };
                  }));
    } else if (variant === "coordinates") {
      return Curry._1(setImportState, (function (param) {
                    return {
                            NAME: "coordinatesPrompt",
                            VAL: data
                          };
                  }));
    } else if (variant === "contact" || variant === "extract") {
      return Curry._1(setImportState, (function (param) {
                    return {
                            NAME: "contactPrompt",
                            VAL: data
                          };
                  }));
    } else if (variant === "coordinatesPrompt") {
      return Curry._1(setImportState, (function (param) {
                    return {
                            NAME: "upload",
                            VAL: data
                          };
                  }));
    } else if (variant === "addressPrompt") {
      if (Belt_Option.isSome(data.schema.locate)) {
        return Curry._1(setImportState, (function (param) {
                      return {
                              NAME: "coordinates",
                              VAL: data
                            };
                    }));
      } else {
        return Curry._1(setImportState, (function (param) {
                      return {
                              NAME: "coordinatesPrompt",
                              VAL: data
                            };
                    }));
      }
    } else if (variant === "addressSplit" || variant === "addressFull") {
      return Curry._1(setImportState, (function (param) {
                    return {
                            NAME: "addressPrompt2",
                            VAL: data
                          };
                  }));
    } else if (variant === "addressPrompt2") {
      return Curry._1(setImportState, (function (param) {
                    return {
                            NAME: "addressPrompt",
                            VAL: data
                          };
                  }));
    } else {
      return ;
    }
  };
  var tmp;
  var exit = 0;
  if (typeof importState === "object" && importState.NAME === "upload") {
    tmp = React.createElement(Icon3.RadioFilled.make, {});
  } else {
    exit = 1;
  }
  if (exit === 1) {
    tmp = React.createElement(Icon3.RadioCheckmark.make, {});
  }
  var variant = importState.NAME;
  var tmp$1;
  if (typeof importState === "object") {
    var variant$1 = importState.NAME;
    tmp$1 = variant$1 === "addressPrompt2" || variant$1 === "addressSplit" || variant$1 === "contact" || variant$1 === "addressFull" || variant$1 === "addressPrompt" || variant$1 === "coordinatesPrompt" || variant$1 === "coordinates" || variant$1 === "contactPrompt" ? "text-blue" : "";
  } else {
    tmp$1 = "";
  }
  var tmp$2;
  if (typeof importState === "object") {
    var variant$2 = importState.NAME;
    tmp$2 = variant$2 === "addressPrompt2" || variant$2 === "addressSplit" || variant$2 === "contact" || variant$2 === "addressFull" || variant$2 === "addressPrompt" || variant$2 === "coordinatesPrompt" || variant$2 === "extract" || variant$2 === "coordinates" || variant$2 === "contactPrompt" ? "bg-blue" : "bg-light-gray";
  } else {
    tmp$2 = "bg-light-gray";
  }
  var variant$3 = importState.NAME;
  return React.createElement("div", {
              className: "relative mx-8 flex h-full w-full flex-col items-center justify-center rounded-16 bg-white"
            }, React.createElement("div", {
                  className: "flex w-full flex-1 flex-col items-center"
                }, React.createElement("div", {
                      className: "absolute top-7 left-4 flex w-full flex-row items-center justify-start"
                    }, React.createElement("div", {
                          className: "cursor-pointer rounded p-2 hover:bg-F7F7F8",
                          onClick: (function (param) {
                              Curry._1(onClose, undefined);
                            })
                        }, React.createElement(Icon3.Cross2.make, {})), React.createElement("div", {
                          className: "ml-4 text-xl font-bold"
                        }, "Import Mapsheet")), React.createElement("div", {
                      className: "flex items-center justify-center py-8"
                    }, tmp, React.createElement("div", {
                          className: Cx.cx([
                                "ml-2",
                                typeof importState === "object" && importState.NAME === "upload" ? "text-blue" : ""
                              ])
                        }, "Upload File"), React.createElement(Icon3.ArrowRight2.make, {
                          className: "ml-8 text-gray"
                        }), React.createElement("div", {
                          className: "ml-8"
                        }, variant === "extract" ? React.createElement(Icon3.RadioCheckmark.make, {}) : (
                            variant === "upload" ? React.createElement(Icon3.RadioEmpty.make, {}) : React.createElement(Icon3.RadioFilled.make, {})
                          )), React.createElement("div", {
                          className: Cx.cx([
                                "ml-2",
                                tmp$1
                              ])
                        }, "Import Type"), React.createElement(Icon3.ArrowRight2.make, {
                          className: "ml-8 text-gray"
                        }), React.createElement("div", {
                          className: "ml-8"
                        }, importState.NAME === "extract" ? React.createElement(Icon3.RadioFilled.make, {}) : React.createElement(Icon3.RadioEmpty.make, {})), React.createElement("div", {
                          className: Cx.cx([
                                "ml-2",
                                typeof importState === "object" && importState.NAME === "extract" ? "text-blue" : ""
                              ])
                        }, "Map Columns")), React.createElement("div", {
                      className: "flex min-h-[4px] w-full"
                    }, React.createElement("div", {
                          className: "flex flex-1 bg-blue"
                        }), React.createElement("div", {
                          className: Cx.cx([
                                "flex flex-1",
                                tmp$2
                              ])
                        }), React.createElement("div", {
                          className: Cx.cx([
                                "flex flex-1",
                                typeof importState === "object" && importState.NAME === "extract" ? "bg-blue" : "bg-light-gray"
                              ])
                        })), React.createElement("div", {
                      className: "flex h-full w-full flex-col items-center justify-center px-40"
                    }, variant$3 === "coordinates" ? React.createElement(Table__Import__Coordinates.make, {
                            importData: importState.VAL,
                            setImportState: setImportState,
                            handleBack: handleBack
                          }) : (
                        variant$3 === "extract" ? React.createElement(Table__Import__Extract.make, {
                                importData: importState.VAL,
                                onClose: onClose,
                                onComplete: onComplete,
                                teamId: teamId,
                                handleBack: handleBack
                              }) : (
                            variant$3 === "coordinatesPrompt" ? React.createElement(Table__Import__CoordinatesPrompt.make, {
                                    importData: importState.VAL,
                                    setImportState: setImportState,
                                    handleBack: handleBack
                                  }) : (
                                variant$3 === "upload" ? React.createElement(Table__Import__Upload.make, {
                                        setImportState: setImportState,
                                        importData: importState.VAL,
                                        spaceId: spaceId
                                      }) : (
                                    variant$3 === "addressPrompt" ? React.createElement(Table__Import__AddressPrompt.make, {
                                            importData: importState.VAL,
                                            setImportState: setImportState,
                                            handleBack: handleBack
                                          }) : (
                                        variant$3 === "addressFull" ? React.createElement(Table__Import__AddressFull.make, {
                                                importData: importState.VAL,
                                                setImportState: setImportState,
                                                handleBack: handleBack
                                              }) : (
                                            variant$3 === "contact" ? React.createElement(Table__Import__Contact.make, {
                                                    importData: importState.VAL,
                                                    setImportState: setImportState,
                                                    handleBack: handleBack
                                                  }) : (
                                                variant$3 === "addressSplit" ? React.createElement(Table__Import__AddressSplit.make, {
                                                        importData: importState.VAL,
                                                        setImportState: setImportState,
                                                        handleBack: handleBack
                                                      }) : (
                                                    variant$3 === "addressPrompt2" ? React.createElement(Table__Import__AddressPrompt2.make, {
                                                            importData: importState.VAL,
                                                            setImportState: setImportState,
                                                            handleBack: handleBack
                                                          }) : React.createElement(Table__Import__ContactPrompt.make, {
                                                            importData: importState.VAL,
                                                            setImportState: setImportState,
                                                            handleBack: handleBack
                                                          })
                                                  )
                                              )
                                          )
                                      )
                                  )
                              )
                          )
                      ))));
}

var make = Table__Import__Index;

export {
  make ,
}
/* Icon3 Not a pure module */
