{"ast":null,"code":"import _extends from \"@babel/runtime-corejs2/helpers/esm/extends\";\nimport _JSON$stringify from \"@babel/runtime-corejs2/core-js/json/stringify\";\nimport _slicedToArray from \"@babel/runtime-corejs2/helpers/esm/slicedToArray\";\nimport _Promise from \"@babel/runtime-corejs2/core-js/promise\";\nimport React from \"react\";\nimport { useState } from 'react';\nimport { Field } from 'formik';\nimport FormStepper from '@flui/ui-components/src/UIView/Steppers/FormStepper';\nimport { AntInput, AntTextArea } from '@flui/ui-components/src/UIView/Antd/AntdInputWithFormik';\nimport InputIncDec from '@flui/ui-components/src/UIView/InputIncDec/InputIncDec';\nimport Row from '@flui/ui-components/src/UIView/Antd/Grid/Row';\nimport Col from '@flui/ui-components/src/UIView/Antd/Grid/Col';\nimport Heading from '@flui/ui-components/src/UIView/Heading/Heading';\nimport Text from '@flui/ui-components/src/UIView/Text/Text';\nimport { PorpertyType, Parking, Pool, AirCondition, ExtraBed } from '@flui/ui-components/src/hotel/components/Listing/RenderAmenitiesForm';\nimport { PhotoUploadComponent } from '@flui/ui-components/src/hotel/components/Listing/RenderUploadPhotosForm';\nimport { FormMapComponent } from '@flui/ui-components/src/hotel/components/Listing/RenderLocationInputForm';\nimport StepperWrapper, { UploaderWrapper, LocationWrapper, AmenitiesWrapper, HeaderSection, Title, Description } from '@flui/ui-components/src/hotel/components/Listing/AddListing.style';\n\nvar sleep = function sleep(ms) {\n  return new _Promise(function (resolve) {\n    return setTimeout(resolve, ms);\n  });\n};\n\nvar required = function required(value) {\n  return value ? undefined : 'Required';\n};\n\nvar formValue = {\n  hotelName: '',\n  priceParNight: '',\n  hotelDetails: '',\n  guest: 0,\n  beds: 0,\n  price: 0,\n  hotelPhotos: [],\n  location: [],\n  locationDescription: '',\n  contactNumber: null,\n  wifiAvailability: '',\n  airCondition: '',\n  parking: '',\n  poolAvailability: '',\n  extraBed: ''\n};\n\nvar QuantityInput = function QuantityInput(_ref) {\n  var field = _ref.field,\n      form = _ref.form;\n\n  var _useState = useState(field ? field.value : 0),\n      _useState2 = _slicedToArray(_useState, 2),\n      state = _useState2[0],\n      setState = _useState2[1];\n\n  var handleIncrement = function handleIncrement() {\n    var currentValue = state;\n    setState(++currentValue);\n    form.setFieldValue(field.name, ++currentValue);\n  };\n\n  var handleDecrement = function handleDecrement() {\n    var currentValue = state;\n\n    if (currentValue <= 0) {\n      return false;\n    }\n\n    setState(--currentValue);\n    form.setFieldValue(field.name, --currentValue);\n  };\n\n  var handleOnChange = function handleOnChange(e) {\n    setState(e.target.value);\n    form.setFieldValue(field.name, e.target.value);\n  };\n\n  return React.createElement(InputIncDec, {\n    value: state,\n    name: field && field.name,\n    onChange: handleOnChange,\n    increment: handleIncrement,\n    decrement: handleDecrement\n  });\n};\n\nvar RenderCreateOrUpdateForm = function RenderCreateOrUpdateForm(_ref2) {\n  var fieldLabel = _ref2.fieldLabel;\n  return React.createElement(StepperWrapper, {\n    className: \"hotel-submission-form\"\n  }, React.createElement(FormStepper, {\n    initialValues: formValue,\n    onSubmit: function onSubmit(values, actions) {\n      sleep(300).then(function () {\n        window.alert(_JSON$stringify(values, null, 2));\n        actions.setSubmitting(false);\n      });\n    }\n  }, React.createElement(FormStepper.Page, null, React.createElement(HeaderSection, null, React.createElement(Title, null, \"Step 1: Start with the basics\")), React.createElement(Row, {\n    gutter: 30\n  }, React.createElement(Col, {\n    sm: 12\n  }, React.createElement(Field, {\n    component: AntInput,\n    name: \"hotelName\",\n    type: \"text\",\n    label: \"Hotel Name\",\n    validate: required,\n    placeholder: \"Write your hotel name here\",\n    hasFeedback: true\n  })), React.createElement(Col, {\n    sm: 12\n  }, React.createElement(Field, {\n    component: AntInput,\n    name: \"priceParNight\",\n    type: \"number\",\n    label: \"Price Per Night (USD)\",\n    validate: required,\n    placeholder: \"$00\",\n    hasFeedback: true\n  }))), React.createElement(Field, {\n    component: AntTextArea,\n    name: \"hotelDetails\",\n    type: \"text\",\n    label: \"Hotel Description\",\n    validate: required,\n    placeholder: \"Tell people about your hotel: your room, location, amenities?\",\n    hasFeedback: true,\n    rows: 4\n  }), React.createElement(Heading, _extends({\n    as: \"h3\"\n  }, fieldLabel, {\n    content: \"How Many guests can your Hotel accommodate?\"\n  })), React.createElement(Field, {\n    component: QuantityInput,\n    name: \"guest\",\n    label: \"Guest Input\",\n    hasFeedback: true,\n    rows: 4\n  }), React.createElement(Heading, _extends({}, fieldLabel, {\n    as: \"h3\",\n    content: \"How Many beds can guests use?\"\n  })), React.createElement(Field, {\n    component: QuantityInput,\n    name: \"beds\",\n    label: \"Bed Input\",\n    hasFeedback: true,\n    rows: 4\n  })), React.createElement(FormStepper.Page, null, React.createElement(HeaderSection, null, React.createElement(Title, null, \"Step 2: Hotel Photos\")), React.createElement(UploaderWrapper, null, React.createElement(Field, {\n    component: PhotoUploadComponent,\n    name: \"hotelPhotos\",\n    type: \"file\",\n    label: \"Hotel Photos\",\n    validate: required,\n    hasFeedback: true,\n    rows: 4\n  }))), React.createElement(FormStepper.Page, {\n    validate: function validate(values) {\n      var errors = {};\n\n      if (!values.locationDescription) {\n        errors.locationDescription = 'Required';\n      }\n\n      if (!values.contactNumber) {\n        errors.contactNumber = 'Required';\n      }\n\n      return errors;\n    }\n  }, React.createElement(HeaderSection, null, React.createElement(Title, null, \"Step 3: Hotel Location\")), React.createElement(LocationWrapper, null, React.createElement(Row, {\n    gutter: 30\n  }, React.createElement(Col, {\n    sm: 12\n  }, React.createElement(Field, {\n    component: AntInput,\n    name: \"contactNumber\",\n    type: \"number\",\n    label: \"Contact Number\",\n    placeholder: \"Phone\",\n    hasFeedback: true\n  }))), React.createElement(Field, {\n    component: AntTextArea,\n    name: \"locationDescription\",\n    type: \"textarea\",\n    label: \"Details description for Hotel Component\",\n    placeholder: \"Write your hotel direction in details , it may help traveler to find your hotel easily\",\n    hasFeedback: true,\n    rows: 4\n  }), React.createElement(Field, {\n    component: FormMapComponent,\n    type: \"text\",\n    name: \"location\",\n    label: \"Choose Location\",\n    hasFeedback: true\n  }))), React.createElement(FormStepper.Page, null, React.createElement(AmenitiesWrapper, null, React.createElement(HeaderSection, null, React.createElement(Title, null, \"Step 4: Hotel Amenities \", React.createElement(\"span\", null, \" (optional)\")), React.createElement(Description, null, \"Add your hotel amenities , it can help travelers to choose their perfect hotel. Thanks.\")), React.createElement(Row, {\n    gutter: 30\n  }, React.createElement(Col, {\n    md: 8\n  }, React.createElement(Text, _extends({\n    as: \"h3\"\n  }, fieldLabel, {\n    content: \"Wifi Availability\"\n  })), React.createElement(Field, {\n    name: \"wifiAvailability\",\n    component: PorpertyType,\n    placeholder: \"Wifi Availability\"\n  })), React.createElement(Col, {\n    md: 8\n  }, React.createElement(Text, _extends({\n    as: \"h3\"\n  }, fieldLabel, {\n    content: \"Parking Availability\"\n  })), React.createElement(Field, {\n    name: \"parking\",\n    component: Parking,\n    placeholder: \"Parking Availability\"\n  })), React.createElement(Col, {\n    md: 8\n  }, React.createElement(Text, _extends({\n    as: \"h3\"\n  }, fieldLabel, {\n    content: \"Pool Availability\"\n  })), React.createElement(Field, {\n    name: \"poolAvailability\",\n    component: Pool,\n    placeholder: \"Pool Availability\"\n  })), React.createElement(Col, {\n    md: 8\n  }, React.createElement(Text, _extends({\n    as: \"h3\"\n  }, fieldLabel, {\n    content: \"Air-Conditioner\"\n  })), React.createElement(Field, {\n    name: \"airCondition\",\n    component: AirCondition,\n    placeholder: \"Air-Conditioner\"\n  })), React.createElement(Col, {\n    md: 8\n  }, React.createElement(Text, _extends({\n    as: \"h3\"\n  }, fieldLabel, {\n    content: \"Extra Bed Availability\"\n  })), React.createElement(Field, {\n    name: \"extraBed\",\n    component: ExtraBed,\n    placeholder: \"Extra Bed Availability\"\n  })))))));\n};\n\nRenderCreateOrUpdateForm.defaultProps = {\n  fieldLabel: {\n    color: '#2C2C2C',\n    fontSize: '15px',\n    lineHeight: '18px',\n    fontWeight: '700',\n    mt: ['30px', '47px'],\n    mb: ['15px', '30px']\n  }\n};\nexport default RenderCreateOrUpdateForm;","map":null,"metadata":{},"sourceType":"module"}