s-platform-landing-section 0.1.36-beta.10 → 0.1.36-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8501,6 +8501,8 @@ var ModalNotification = function ModalNotification(props) {
8501
8501
  onCloseFormBooking = props.onCloseFormBooking,
8502
8502
  _props$isButtonClose = props.isButtonClose,
8503
8503
  isButtonClose = _props$isButtonClose === void 0 ? true : _props$isButtonClose,
8504
+ _props$isMaskClose = props.isMaskClose,
8505
+ isMaskClose = _props$isMaskClose === void 0 ? false : _props$isMaskClose,
8504
8506
  _props$className = props.className,
8505
8507
  className = _props$className === void 0 ? "" : _props$className,
8506
8508
  _props$style = props.style,
@@ -8515,6 +8517,9 @@ var ModalNotification = function ModalNotification(props) {
8515
8517
  }, []);
8516
8518
  var handleClickOutside = function handleClickOutside(event) {
8517
8519
  event.stopPropagation();
8520
+ if (isMaskClose) {
8521
+ return;
8522
+ }
8518
8523
  if (onClose) {
8519
8524
  onClose === null || onClose === void 0 ? void 0 : onClose();
8520
8525
  }
@@ -16466,5 +16471,192 @@ var NewsDetail1 = function NewsDetail1(props) {
16466
16471
  }))) : null);
16467
16472
  };
16468
16473
 
16469
- export { About1, About5, About6, Address1, Banner1, Banner2, Banner3, Banner4, Banner7, BannerFull1, BannerFull2, Booking1, BookingForm6, BookingTable1, Breadcrumb1, Button, Carts1, Contact1, CustomerRating1, CustomerRating10, CustomerRating5, CustomerRating6, CustomerRating8, CustomerRating9, DateTimePicker, Employees1, Features2, Features3, Footer1, Footer7, Gallery1, Gallery2, Gallery3, Hero1, Hero10, Hero11, Hero12, Hero13, Hero14, Hero15, Hero16, Hero2, Hero5, Hero6, Input, InputPhoneNumber, Links1, ModalNotification, NavBar1, NavBar7, News1, NewsDetail1, NewsHighlight1, PageTitle1, PageTitle2, PageTitle3, Partner1, ProductCategory2, ProductDetail10, ProductDetail11, ProductHighlight1, ProductHot1, ProductHot3, ProductImage, ProductItem10, ProductItem11, ProductItem2, ProductItem3, ProductItem4, ProductItem5, ProductItem6, ProductItem7, ProductItem8, ProductItem9, ProductList5, ProductList7, ProductSale2, ProductSearch1, Products10, Products11, Products12, Products14, Products2, Products3, Products9, ProductsTop1, SearchBar2, SearchBar5, SearchBar6, SearchProduct1, SectionTitle1, SectionTitle2, SectionTitle3, SectionTitle4, SectionTitle5, Select$1 as Select, ServiceDetail1, ShopHighlights10, ShopHighlights2, ShopHighlights5, ShopHighlights6, ShopHighlights7, ShopHighlights8, ShopHighlights9, TextArea, TreatmentDetail1, TreatmentItem1, TreatmentsCategory7, TreatmentsList6, TreatmentsList7, VideoFull1 };
16474
+ var submitFormApi = function submitFormApi(landingShopConfigId, data) {
16475
+ return api({
16476
+ method: "post",
16477
+ url: endpointLandingShop + "/" + landingShopConfigId + "/form",
16478
+ data: data
16479
+ });
16480
+ };
16481
+
16482
+ var Form = function Form(props) {
16483
+ var _data$data, _data$data2, _data$data3;
16484
+ var _props$shopConfigStyl = props.shopConfigStyle,
16485
+ shopConfigStyle = _props$shopConfigStyl === void 0 ? {} : _props$shopConfigStyl,
16486
+ _props$shopConfig = props.shopConfig,
16487
+ shopConfig = _props$shopConfig === void 0 ? {} : _props$shopConfig,
16488
+ _props$data = props.data,
16489
+ data = _props$data === void 0 ? {} : _props$data,
16490
+ _props$SectionTitle = props.SectionTitle,
16491
+ SectionTitle = _props$SectionTitle === void 0 ? null : _props$SectionTitle,
16492
+ _props$router = props.router,
16493
+ router = _props$router === void 0 ? function () {} : _props$router;
16494
+ var _shopConfigStyle$colo = shopConfigStyle.color,
16495
+ _shopConfigStyle$colo2 = _shopConfigStyle$colo === void 0 ? {} : _shopConfigStyle$colo,
16496
+ _shopConfigStyle$colo3 = _shopConfigStyle$colo2.background,
16497
+ background = _shopConfigStyle$colo3 === void 0 ? "#fff" : _shopConfigStyle$colo3;
16498
+ var fields = (data === null || data === void 0 ? void 0 : (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.fields) || [];
16499
+ var redirectUrl = (data === null || data === void 0 ? void 0 : (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.redirect_url) || "";
16500
+ var srcImage = data === null || data === void 0 ? void 0 : (_data$data3 = data.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.srcImage;
16501
+ var _useState = useState(false),
16502
+ isLoading = _useState[0],
16503
+ setIsLoading = _useState[1];
16504
+ var fieldRefs = useRef({});
16505
+ var getFieldRef = function getFieldRef(key) {
16506
+ if (!fieldRefs.current[key]) {
16507
+ fieldRefs.current[key] = React__default.createRef();
16508
+ }
16509
+ return fieldRefs.current[key];
16510
+ };
16511
+ var formatFieldsWithValue = function formatFieldsWithValue() {
16512
+ return fields.map(function (field, index) {
16513
+ var _ref$current;
16514
+ var key = (field === null || field === void 0 ? void 0 : field.title) || "field-" + index;
16515
+ var ref = getFieldRef(key);
16516
+ var getValue = ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.getValue;
16517
+ var value = getValue ? getValue() : undefined;
16518
+ return _extends({}, field, {
16519
+ value: value
16520
+ });
16521
+ });
16522
+ };
16523
+ var handleSubmit = function handleSubmit() {
16524
+ try {
16525
+ setIsLoading(true);
16526
+ return Promise.resolve(_finallyRethrows(function () {
16527
+ return _catch(function () {
16528
+ var isValid = true;
16529
+ var payload = {};
16530
+ fields.forEach(function (field, index) {
16531
+ var _ref$current2, _ref$current3;
16532
+ var key = (field === null || field === void 0 ? void 0 : field.title) || "field-" + index;
16533
+ var ref = getFieldRef(key);
16534
+ var validate = ref === null || ref === void 0 ? void 0 : (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.validateData;
16535
+ var getValue = ref === null || ref === void 0 ? void 0 : (_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.getValue;
16536
+ var ok = validate ? validate() : true;
16537
+ if (ok === false) {
16538
+ isValid = false;
16539
+ }
16540
+ payload[key] = getValue ? getValue() : undefined;
16541
+ });
16542
+ if (!isValid) return;
16543
+ var fieldsWithValue = formatFieldsWithValue();
16544
+ var body = {
16545
+ title: data === null || data === void 0 ? void 0 : data.sectionTitle,
16546
+ data: JSON.stringify(fieldsWithValue)
16547
+ };
16548
+ var _temp = function () {
16549
+ if (shopConfig !== null && shopConfig !== void 0 && shopConfig.landingShopConfigId) {
16550
+ return Promise.resolve(submitFormApi(shopConfig === null || shopConfig === void 0 ? void 0 : shopConfig.landingShopConfigId, body)).then(function (res) {
16551
+ var _res$data, _res$data$status;
16552
+ if ((res === null || res === void 0 ? void 0 : (_res$data = res.data) === null || _res$data === void 0 ? void 0 : (_res$data$status = _res$data.status) === null || _res$data$status === void 0 ? void 0 : _res$data$status.code) == '200') {
16553
+ router === null || router === void 0 ? void 0 : router.push(redirectUrl || "/");
16554
+ }
16555
+ });
16556
+ }
16557
+ }();
16558
+ if (_temp && _temp.then) return _temp.then(function () {});
16559
+ }, function (error) {
16560
+ console.log(error);
16561
+ });
16562
+ }, function (_wasThrown, _result) {
16563
+ setIsLoading(false);
16564
+ if (_wasThrown) throw _result;
16565
+ return _result;
16566
+ }));
16567
+ } catch (e) {
16568
+ return Promise.reject(e);
16569
+ }
16570
+ };
16571
+ var renderField = function renderField(field, index) {
16572
+ var _field$title;
16573
+ var key = (field === null || field === void 0 ? void 0 : field.title) || "field-" + index;
16574
+ var commonProps = {
16575
+ label: field === null || field === void 0 ? void 0 : field.title,
16576
+ placeholder: "Nh\u1EADp " + ((field === null || field === void 0 ? void 0 : (_field$title = field.title) === null || _field$title === void 0 ? void 0 : _field$title.toLowerCase()) || ""),
16577
+ className: "!bg-bgSecondary",
16578
+ rules: field !== null && field !== void 0 && field.required ? [{
16579
+ type: "required",
16580
+ message: "Bắt buộc nhập"
16581
+ }] : [],
16582
+ labelClassName: "font-medium"
16583
+ };
16584
+ if ((field === null || field === void 0 ? void 0 : field.type) === "phone") {
16585
+ return /*#__PURE__*/React__default.createElement(InputPhoneNumber, _extends({
16586
+ key: key
16587
+ }, commonProps, {
16588
+ rules: [].concat(commonProps.rules, [{
16589
+ type: "pattern",
16590
+ pattern: pattern === null || pattern === void 0 ? void 0 : pattern.phoneNumberPattern,
16591
+ message: "Số điện thoại không hợp lệ!"
16592
+ }]),
16593
+ className: "bg-white",
16594
+ wrapClassName: "w-full",
16595
+ ref: getFieldRef(key)
16596
+ }));
16597
+ }
16598
+ if ((field === null || field === void 0 ? void 0 : field.type) === "area") {
16599
+ return /*#__PURE__*/React__default.createElement(TextArea, _extends({
16600
+ key: key
16601
+ }, commonProps, {
16602
+ className: "w-full",
16603
+ textareaClassName: "w-full p-3 bg-white",
16604
+ ref: getFieldRef(key)
16605
+ }));
16606
+ }
16607
+ var extraRules = [];
16608
+ if ((field === null || field === void 0 ? void 0 : field.type) === "email") {
16609
+ extraRules.push({
16610
+ type: "pattern",
16611
+ pattern: /\S+@\S+\.\S+/,
16612
+ message: "Email không hợp lệ"
16613
+ });
16614
+ }
16615
+ return /*#__PURE__*/React__default.createElement(Input, _extends({
16616
+ key: key
16617
+ }, commonProps, {
16618
+ type: (field === null || field === void 0 ? void 0 : field.type) === "email" ? "email" : "text",
16619
+ ref: getFieldRef(key),
16620
+ rules: [].concat(commonProps.rules, extraRules)
16621
+ }));
16622
+ };
16623
+ return /*#__PURE__*/React__default.createElement("div", {
16624
+ className: "relative w-full px-4 xl:px-20 py-12",
16625
+ style: {
16626
+ backgroundColor: background
16627
+ }
16628
+ }, SectionTitle ? /*#__PURE__*/React__default.createElement(SectionTitle, {
16629
+ data: data,
16630
+ shopConfigStyle: shopConfigStyle
16631
+ }) : null, /*#__PURE__*/React__default.createElement("div", {
16632
+ className: "mt-12 grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-12 items-start"
16633
+ }, /*#__PURE__*/React__default.createElement("div", {
16634
+ className: "space-y-4"
16635
+ }, srcImage ? /*#__PURE__*/React__default.createElement("div", {
16636
+ className: "w-full"
16637
+ }, /*#__PURE__*/React__default.createElement("img", {
16638
+ src: srcImage,
16639
+ alt: "form-banner",
16640
+ className: "w-full h-auto rounded-xl object-cover"
16641
+ })) : null), /*#__PURE__*/React__default.createElement("div", {
16642
+ className: "grid gap-4 rounded-2xl p-6 border bg-white"
16643
+ }, fields !== null && fields !== void 0 && fields.length ? /*#__PURE__*/React__default.createElement("div", {
16644
+ className: "grid grid-cols-1 gap-4"
16645
+ }, fields === null || fields === void 0 ? void 0 : fields.map(renderField)) : /*#__PURE__*/React__default.createElement("div", null, "Ch\u01B0a c\xF3 c\u1EA5u h\xECnh tr\u01B0\u1EDDng"), /*#__PURE__*/React__default.createElement("div", {
16646
+ className: "text-center"
16647
+ }, isLoading ? /*#__PURE__*/React__default.createElement("div", {
16648
+ className: "flex gap-2 justify-center items-center"
16649
+ }, /*#__PURE__*/React__default.createElement(Loading, {
16650
+ size: 24
16651
+ }), /*#__PURE__*/React__default.createElement("span", {
16652
+ className: "ml-2"
16653
+ }, "\u0110ang g\u1EEDi th\xF4ng tin...")) : /*#__PURE__*/React__default.createElement(Button, {
16654
+ label: "Gửi thông tin",
16655
+ shopConfigStyle: shopConfigStyle,
16656
+ onClick: handleSubmit,
16657
+ disabled: isLoading
16658
+ })))));
16659
+ };
16660
+
16661
+ export { About1, About5, About6, Address1, Banner1, Banner2, Banner3, Banner4, Banner7, BannerFull1, BannerFull2, Booking1, BookingForm6, BookingTable1, Breadcrumb1, Button, Carts1, Contact1, CustomerRating1, CustomerRating10, CustomerRating5, CustomerRating6, CustomerRating8, CustomerRating9, DateTimePicker, Employees1, Features2, Features3, Footer1, Footer7, Form, Gallery1, Gallery2, Gallery3, Hero1, Hero10, Hero11, Hero12, Hero13, Hero14, Hero15, Hero16, Hero2, Hero5, Hero6, Input, InputPhoneNumber, Links1, ModalNotification, NavBar1, NavBar7, News1, NewsDetail1, NewsHighlight1, PageTitle1, PageTitle2, PageTitle3, Partner1, ProductCategory2, ProductDetail10, ProductDetail11, ProductHighlight1, ProductHot1, ProductHot3, ProductImage, ProductItem10, ProductItem11, ProductItem2, ProductItem3, ProductItem4, ProductItem5, ProductItem6, ProductItem7, ProductItem8, ProductItem9, ProductList5, ProductList7, ProductSale2, ProductSearch1, Products10, Products11, Products12, Products14, Products2, Products3, Products9, ProductsTop1, SearchBar2, SearchBar5, SearchBar6, SearchProduct1, SectionTitle1, SectionTitle2, SectionTitle3, SectionTitle4, SectionTitle5, Select$1 as Select, ServiceDetail1, ShopHighlights10, ShopHighlights2, ShopHighlights5, ShopHighlights6, ShopHighlights7, ShopHighlights8, ShopHighlights9, TextArea, TreatmentDetail1, TreatmentItem1, TreatmentsCategory7, TreatmentsList6, TreatmentsList7, VideoFull1 };
16470
16662
  //# sourceMappingURL=index.modern.js.map