{"ast":null,"code":"import _regeneratorRuntime from \"@babel/runtime-corejs2/regenerator\";\nimport _toConsumableArray from \"@babel/runtime-corejs2/helpers/esm/toConsumableArray\";\nimport _asyncToGenerator from \"@babel/runtime-corejs2/helpers/esm/asyncToGenerator\";\nimport React from \"react\";\nimport Head from 'next/head';\nimport Link from 'next/link';\nimport Container from '@flui/ui-components/src/UIView/UI/Container/Container';\nimport Heading from '@flui/ui-components/src/UIView/Heading/Heading';\nimport SectionTitle from '@flui/ui-components/src/hotel/components/SectionTitle/SectionTitle';\nimport SearchArea from '../container/Home/Search/Search';\nimport LocationGrid from '../container/Home/Location/Location';\nimport SectionGrid from '@flui/ui-components/src/hotel/components/SectionGrid/SectionGrid';\nimport GetAPIData from '../helpers/get_api_data';\nimport { getDeviceType } from '../helpers/get_devide_type';\nimport { LISTING_POSTS_PAGE, SINGLE_POST_PAGE } from '../settings/constant';\nimport { HOME_PAGE_SECTIONS_ITEM_LIMIT_FOR_MOBILE_DEVICE, HOME_PAGE_SECTIONS_ITEM_LIMIT_FOR_TABLET_DEVICE, HOME_PAGE_SECTIONS_ITEM_LIMIT_FOR_DESKTOP_DEVICE, HOME_PAGE_SECTIONS_COLUMNS_RESPONSIVE_WIDTH } from '../settings/config';\nexport default function HomePage(_ref) {\n  var deviceType = _ref.deviceType,\n      locationData = _ref.locationData,\n      topHotelData = _ref.topHotelData,\n      luxaryHotelData = _ref.luxaryHotelData;\n  var limit;\n\n  if (deviceType === 'mobile') {\n    limit = HOME_PAGE_SECTIONS_ITEM_LIMIT_FOR_MOBILE_DEVICE;\n  }\n\n  if (deviceType === 'tablet') {\n    limit = HOME_PAGE_SECTIONS_ITEM_LIMIT_FOR_TABLET_DEVICE;\n  }\n\n  if (deviceType === 'desktop') {\n    limit = HOME_PAGE_SECTIONS_ITEM_LIMIT_FOR_DESKTOP_DEVICE;\n  }\n\n  return React.createElement(React.Fragment, null, React.createElement(Head, null, React.createElement(\"title\", null, \"Hotel | A react next listing template\")), React.createElement(SearchArea, null), React.createElement(LocationGrid, {\n    data: locationData,\n    deviceType: deviceType\n  }), React.createElement(Container, {\n    fluid: false\n  }, React.createElement(SectionTitle, {\n    title: React.createElement(Heading, {\n      content: \"Travelers\\u2019 Choice: Top hotels\"\n    }),\n    link: React.createElement(Link, {\n      href: LISTING_POSTS_PAGE\n    }, React.createElement(\"a\", null, \"Show all\"))\n  }), React.createElement(SectionGrid, {\n    link: SINGLE_POST_PAGE,\n    columnWidth: HOME_PAGE_SECTIONS_COLUMNS_RESPONSIVE_WIDTH,\n    data: topHotelData.slice(0, limit),\n    limit: limit,\n    deviceType: deviceType\n  }), React.createElement(SectionTitle, {\n    title: React.createElement(Heading, {\n      content: \"Best Rated: Luxary hotels\"\n    }),\n    link: React.createElement(Link, {\n      href: LISTING_POSTS_PAGE\n    }, React.createElement(\"a\", null, \"Show all\"))\n  }), React.createElement(SectionGrid, {\n    link: SINGLE_POST_PAGE,\n    columnWidth: HOME_PAGE_SECTIONS_COLUMNS_RESPONSIVE_WIDTH,\n    data: luxaryHotelData.slice(0, limit),\n    limit: limit,\n    deviceType: deviceType\n  })));\n}\n\nHomePage.getInitialProps =\n/*#__PURE__*/\nfunction () {\n  var _ref3 = _asyncToGenerator(\n  /*#__PURE__*/\n  _regeneratorRuntime.mark(function _callee(_ref2) {\n    var req, apiUrl, deviceType, pageData, locationData, topHotelData, luxaryHotelData;\n    return _regeneratorRuntime.wrap(function _callee$(_context) {\n      while (1) {\n        switch (_context.prev = _context.next) {\n          case 0:\n            req = _ref2.req;\n            apiUrl = [{\n              endpoint: 'hotel',\n              name: 'luxaryHotelData'\n            }, {\n              endpoint: 'top-hotel',\n              name: 'topHotelData'\n            }, {\n              endpoint: 'location',\n              name: 'locationData'\n            }];\n            deviceType = getDeviceType(req);\n            _context.next = 5;\n            return GetAPIData(apiUrl);\n\n          case 5:\n            pageData = _context.sent;\n            locationData = [], topHotelData = [], luxaryHotelData = [];\n\n            if (pageData) {\n              pageData.forEach(function (item, key) {\n                if (item.name === 'locationData') {\n                  locationData = item.data ? _toConsumableArray(item.data) : [];\n                } else if (item.name === 'topHotelData') {\n                  topHotelData = item.data ? _toConsumableArray(item.data) : [];\n                } else if (item.name === 'luxaryHotelData') {\n                  luxaryHotelData = item.data ? _toConsumableArray(item.data) : [];\n                }\n              });\n            }\n\n            return _context.abrupt(\"return\", {\n              deviceType: deviceType,\n              locationData: locationData,\n              topHotelData: topHotelData,\n              luxaryHotelData: luxaryHotelData\n            });\n\n          case 9:\n          case \"end\":\n            return _context.stop();\n        }\n      }\n    }, _callee);\n  }));\n\n  return function (_x) {\n    return _ref3.apply(this, arguments);\n  };\n}();","map":null,"metadata":{},"sourceType":"module"}