@salla.sa/twilight-components 2.14.488 → 2.14.490
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.
- package/dist/cjs/{filepond-05NO31dc.js → filepond-DMNwZGDe.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-poster-BSzyn1DL.js → filepond-plugin-file-poster-CwJqn9cv.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-size-DJKsosMa.js → filepond-plugin-file-validate-size-D8HCq_yt.js} +1 -1
- package/dist/cjs/{filepond-plugin-file-validate-type-C0xLud1P.js → filepond-plugin-file-validate-type-DZHIztrf.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-edit-Dq1zXDYS.js → filepond-plugin-image-edit-DtW6aab5.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-exif-orientation-B84Q7JSN.js → filepond-plugin-image-exif-orientation-DlHuggE7.js} +1 -1
- package/dist/cjs/{filepond-plugin-image-preview-BaE9P79l.js → filepond-plugin-image-preview-rSt0R5Fs.js} +1 -1
- package/dist/cjs/{functions-B-_Pnqnt.js → functions-Cl4vQLXn.js} +1 -1
- package/dist/cjs/{index-f6loD1zL.js → index-CfrGmYJa.js} +17 -5
- package/dist/cjs/{index-BsvV4QQg.js → index-CrTL2nRh.js} +1 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-accordion_6.cjs.entry.js +1 -1
- package/dist/cjs/salla-add-product-button_5.cjs.entry.js +1 -1
- package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
- package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
- package/dist/cjs/salla-badge.cjs.entry.js +1 -1
- package/dist/cjs/salla-booking-field_7.cjs.entry.js +11 -11
- package/dist/cjs/salla-bullet-delivery_2.cjs.entry.js +5 -5
- package/dist/cjs/salla-cart-coupons.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-cart-summary-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-cashback-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-comment-factors.cjs.entry.js +45 -0
- package/dist/cjs/salla-comment-form_8.cjs.entry.js +112 -30
- package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
- package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
- package/dist/cjs/salla-count-down.cjs.entry.js +1 -1
- package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
- package/dist/cjs/salla-delivery-promise.cjs.entry.js +1 -1
- package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters-widget.cjs.entry.js +1 -1
- package/dist/cjs/salla-filters.cjs.entry.js +1 -1
- package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +1 -1
- package/dist/cjs/salla-gifting.cjs.entry.js +1 -1
- package/dist/cjs/salla-hook.cjs.entry.js +1 -1
- package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
- package/dist/cjs/salla-installment.cjs.entry.js +1 -1
- package/dist/cjs/salla-list-tile.cjs.entry.js +1 -1
- package/dist/cjs/salla-localization-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-points-banner.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-points-history.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
- package/dist/cjs/salla-loyalty-reward.cjs.entry.js +2 -2
- package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
- package/dist/cjs/salla-maintenance-alert.cjs.entry.js +1 -1
- package/dist/cjs/salla-map_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-menu.cjs.entry.js +1 -1
- package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +1 -1
- package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-next-order-coupon.cjs.entry.js +1 -1
- package/dist/cjs/salla-notification-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer-modal.cjs.entry.js +1 -1
- package/dist/cjs/salla-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-branch.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-cancel.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-details.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-options-modal_3.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-summary.cjs.entry.js +1 -1
- package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
- package/dist/cjs/salla-orders.cjs.entry.js +1 -1
- package/dist/cjs/salla-payments.cjs.entry.js +1 -1
- package/dist/cjs/salla-placeholder.cjs.entry.js +1 -1
- package/dist/cjs/salla-price-range.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-card-embed.cjs.entry.js +1 -1
- package/dist/cjs/salla-product-size-guide.cjs.entry.js +1 -1
- package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
- package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
- package/dist/cjs/salla-rating-modal-v2.cjs.entry.js +1060 -0
- package/dist/cjs/salla-rating-modal.cjs.entry.js +38 -14
- package/dist/cjs/salla-review-factors-tags.cjs.entry.js +127 -0
- package/dist/cjs/salla-reward-action_4.cjs.entry.js +3 -3
- package/dist/cjs/salla-scopes.cjs.entry.js +1 -1
- package/dist/cjs/salla-search.cjs.entry.js +6 -6
- package/dist/cjs/salla-skeleton.cjs.entry.js +2 -2
- package/dist/cjs/salla-slider.cjs.entry.js +1 -1
- package/dist/cjs/salla-social-share.cjs.entry.js +2 -2
- package/dist/cjs/salla-social.cjs.entry.js +2 -2
- package/dist/cjs/salla-tab-content_3.cjs.entry.js +4 -4
- package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
- package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
- package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-menu.cjs.entry.js +3 -3
- package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
- package/dist/cjs/salla-user-settings.cjs.entry.js +2 -2
- package/dist/cjs/salla-verify.cjs.entry.js +1 -1
- package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
- package/dist/cjs/salla-wishlist-actions.cjs.entry.js +2 -2
- package/dist/cjs/shipping-fast-CsqEQE78.js +13 -0
- package/dist/{esm/star-ZT7ehBBk.js → cjs/star-DMzrN05M.js} +4 -2
- package/dist/cjs/{tracked-promise-We1h_qB4.js → tracked-promise-ClJBjg9o.js} +1 -1
- package/dist/cjs/twilight.cjs.js +2 -2
- package/dist/cjs/{vanilla-picker-Ck8OFt14.js → vanilla-picker-um8NlppX.js} +1 -1
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/salla-comments/salla-comment-factors.js +76 -0
- package/dist/collection/components/salla-comments/salla-comment-item.js +20 -6
- package/dist/collection/components/salla-comments/salla-comments.css +110 -0
- package/dist/collection/components/salla-rating-modal/salla-rating-modal-v2.js +1203 -0
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.css +112 -1
- package/dist/collection/components/salla-rating-modal/salla-rating-modal.js +33 -2
- package/dist/collection/components/salla-rating-stars/salla-rating-stars.css +34 -1
- package/dist/collection/components/salla-rating-stars/salla-rating-stars.js +117 -16
- package/dist/collection/components/salla-review-factors-tags/helpers.js +86 -0
- package/dist/collection/components/salla-review-factors-tags/interfaces.js +1 -0
- package/dist/collection/components/salla-review-factors-tags/salla-review-factors-tags.css +41 -0
- package/dist/collection/components/salla-review-factors-tags/salla-review-factors-tags.js +135 -0
- package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
- package/dist/collection/components/salla-reviews-page/salla-reviews-page.js +1 -1
- package/dist/collection/components/salla-reviews-summary/salla-reviews-summary.css +60 -0
- package/dist/collection/components/salla-reviews-summary/salla-reviews-summary.js +12 -2
- package/dist/collection/components/salla-search/salla-search.js +5 -5
- package/dist/collection/components/salla-searchable-dropdown/salla-searchable-dropdown.js +4 -4
- package/dist/collection/components/salla-skeleton/salla-skeleton.js +1 -1
- package/dist/collection/components/salla-social/salla-social.js +1 -1
- package/dist/collection/components/salla-social-share/salla-social-share.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
- package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
- package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
- package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
- package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
- package/dist/collection/components/salla-wishlist-actions/salla-wishlist-actions.js +1 -1
- package/dist/components/index.js +3 -3
- package/dist/components/salla-comment-factors.d.ts +11 -0
- package/dist/components/salla-comment-factors.js +9 -0
- package/dist/components/salla-comment-factors2.js +66 -0
- package/dist/components/salla-comment-item2.js +29 -9
- package/dist/components/salla-comments.js +9 -3
- package/dist/components/salla-rating-modal-v2.d.ts +11 -0
- package/dist/components/salla-rating-modal-v2.js +9 -0
- package/dist/components/salla-rating-modal-v22.js +1149 -0
- package/dist/components/salla-rating-modal.js +49 -19
- package/dist/components/salla-rating-stars2.js +80 -17
- package/dist/components/salla-review-factors-tags.d.ts +11 -0
- package/dist/components/salla-review-factors-tags.js +149 -0
- package/dist/components/salla-reviews-page.js +1 -1
- package/dist/components/salla-reviews-summary2.js +13 -3
- package/dist/components/salla-reviews.js +1 -1
- package/dist/components/salla-search.js +5 -5
- package/dist/components/salla-searchable-dropdown2.js +4 -4
- package/dist/components/salla-skeleton2.js +1 -1
- package/dist/components/salla-social-share2.js +1 -1
- package/dist/components/salla-social.js +1 -1
- package/dist/components/salla-tab-content2.js +1 -1
- package/dist/components/salla-tab-header2.js +1 -1
- package/dist/components/salla-tabs2.js +1 -1
- package/dist/components/salla-tel-input2.js +1 -1
- package/dist/components/salla-tooltip2.js +1 -1
- package/dist/components/salla-user-settings.js +1 -1
- package/dist/components/salla-wishlist-actions.js +1 -1
- package/dist/esm/{filepond-2lHD_yVt.js → filepond-Cg7o_vnN.js} +1 -1
- package/dist/esm/{filepond-plugin-file-poster-DIjVVIwh.js → filepond-plugin-file-poster-BJ1q5i_Q.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-size-CfcICNJA.js → filepond-plugin-file-validate-size-KAp2gG4p.js} +1 -1
- package/dist/esm/{filepond-plugin-file-validate-type-DsvYMiJr.js → filepond-plugin-file-validate-type-D6KC6aKt.js} +1 -1
- package/dist/esm/{filepond-plugin-image-edit-B7K5Ib7q.js → filepond-plugin-image-edit-CsviUA8z.js} +1 -1
- package/dist/esm/{filepond-plugin-image-exif-orientation-9iz6i-up.js → filepond-plugin-image-exif-orientation-DORQxh2z.js} +1 -1
- package/dist/esm/{filepond-plugin-image-preview-C89IBH1s.js → filepond-plugin-image-preview-DiN_MPtQ.js} +1 -1
- package/dist/esm/{functions-CJdqLH4P.js → functions-ChcWts7Y.js} +1 -1
- package/dist/esm/{index-K0OclOPO.js → index-DkTbP5UX.js} +17 -5
- package/dist/esm/{index-D1YskPUH.js → index-nv62Rr6s.js} +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/salla-accordion-body_2.entry.js +1 -1
- package/dist/esm/salla-accordion_6.entry.js +1 -1
- package/dist/esm/salla-add-product-button_5.entry.js +1 -1
- package/dist/esm/salla-advertisement.entry.js +1 -1
- package/dist/esm/salla-alert_2.entry.js +1 -1
- package/dist/esm/salla-app-install-alert.entry.js +1 -1
- package/dist/esm/salla-apps-icons.entry.js +1 -1
- package/dist/esm/salla-badge.entry.js +1 -1
- package/dist/esm/salla-booking-field_7.entry.js +11 -11
- package/dist/esm/salla-bullet-delivery_2.entry.js +5 -5
- package/dist/esm/salla-cart-coupons.entry.js +1 -1
- package/dist/esm/salla-cart-item-offers_2.entry.js +1 -1
- package/dist/esm/salla-cart-summary-card.entry.js +1 -1
- package/dist/esm/salla-cashback-banner.entry.js +1 -1
- package/dist/esm/salla-comment-factors.entry.js +43 -0
- package/dist/esm/salla-comment-form_8.entry.js +112 -30
- package/dist/esm/salla-conditional-offer.entry.js +1 -1
- package/dist/esm/salla-contacts.entry.js +1 -1
- package/dist/esm/salla-cookies-bar.entry.js +1 -1
- package/dist/esm/salla-count-down.entry.js +1 -1
- package/dist/esm/salla-custom-fields.entry.js +1 -1
- package/dist/esm/salla-delivery-promise.entry.js +1 -1
- package/dist/esm/salla-edit-order-button.entry.js +1 -1
- package/dist/esm/salla-filters-widget.entry.js +1 -1
- package/dist/esm/salla-filters.entry.js +1 -1
- package/dist/esm/salla-fulfillment-methods.entry.js +1 -1
- package/dist/esm/salla-gifting.entry.js +1 -1
- package/dist/esm/salla-hook.entry.js +1 -1
- package/dist/esm/salla-infinite-scroll.entry.js +1 -1
- package/dist/esm/salla-installment.entry.js +1 -1
- package/dist/esm/salla-list-tile.entry.js +1 -1
- package/dist/esm/salla-localization-modal.entry.js +1 -1
- package/dist/esm/salla-login-modal.entry.js +1 -1
- package/dist/esm/salla-loyalty-banner.entry.js +2 -2
- package/dist/esm/salla-loyalty-hero_2.entry.js +2 -2
- package/dist/esm/salla-loyalty-panel.entry.js +3 -3
- package/dist/esm/salla-loyalty-points-banner.entry.js +1 -1
- package/dist/esm/salla-loyalty-points-history.entry.js +1 -1
- package/dist/esm/salla-loyalty-prize-item.entry.js +1 -1
- package/dist/esm/salla-loyalty-program.entry.js +3 -3
- package/dist/esm/salla-loyalty-reward.entry.js +2 -2
- package/dist/esm/salla-loyalty.entry.js +1 -1
- package/dist/esm/salla-maintenance-alert.entry.js +1 -1
- package/dist/esm/salla-map_2.entry.js +1 -1
- package/dist/esm/salla-menu.entry.js +1 -1
- package/dist/esm/salla-metadata.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +1 -1
- package/dist/esm/salla-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-next-order-coupon.entry.js +1 -1
- package/dist/esm/salla-notification-item.entry.js +1 -1
- package/dist/esm/salla-notifications.entry.js +1 -1
- package/dist/esm/salla-offer-modal.entry.js +1 -1
- package/dist/esm/salla-offer.entry.js +1 -1
- package/dist/esm/salla-order-branch.entry.js +1 -1
- package/dist/esm/salla-order-cancel.entry.js +1 -1
- package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
- package/dist/esm/salla-order-details-options.entry.js +1 -1
- package/dist/esm/salla-order-details.entry.js +1 -1
- package/dist/esm/salla-order-edit-item.entry.js +1 -1
- package/dist/esm/salla-order-edit-product-card.entry.js +1 -1
- package/dist/esm/salla-order-edit.entry.js +1 -1
- package/dist/esm/salla-order-options-modal_3.entry.js +1 -1
- package/dist/esm/salla-order-summary.entry.js +1 -1
- package/dist/esm/salla-order-totals-card.entry.js +1 -1
- package/dist/esm/salla-orders.entry.js +1 -1
- package/dist/esm/salla-payments.entry.js +1 -1
- package/dist/esm/salla-placeholder.entry.js +1 -1
- package/dist/esm/salla-price-range.entry.js +1 -1
- package/dist/esm/salla-product-card-embed.entry.js +1 -1
- package/dist/esm/salla-product-size-guide.entry.js +1 -1
- package/dist/esm/salla-products-list.entry.js +1 -1
- package/dist/esm/salla-quick-order.entry.js +1 -1
- package/dist/esm/salla-rating-modal-v2.entry.js +1058 -0
- package/dist/esm/salla-rating-modal.entry.js +36 -12
- package/dist/esm/salla-review-factors-tags.entry.js +125 -0
- package/dist/esm/salla-reward-action_4.entry.js +3 -3
- package/dist/esm/salla-scopes.entry.js +1 -1
- package/dist/esm/salla-search.entry.js +6 -6
- package/dist/esm/salla-skeleton.entry.js +2 -2
- package/dist/esm/salla-slider.entry.js +1 -1
- package/dist/esm/salla-social-share.entry.js +2 -2
- package/dist/esm/salla-social.entry.js +2 -2
- package/dist/esm/salla-tab-content_3.entry.js +4 -4
- package/dist/esm/salla-tiered-offer.entry.js +1 -1
- package/dist/esm/salla-tooltip.entry.js +2 -2
- package/dist/esm/salla-trust-badges.entry.js +1 -1
- package/dist/esm/salla-user-menu.entry.js +5 -5
- package/dist/esm/salla-user-profile.entry.js +1 -1
- package/dist/esm/salla-user-settings.entry.js +2 -2
- package/dist/esm/salla-verify.entry.js +1 -1
- package/dist/esm/salla-wallet.entry.js +1 -1
- package/dist/esm/salla-wishlist-actions.entry.js +2 -2
- package/dist/esm/shipping-fast-lMgMt31Q.js +11 -0
- package/dist/{cjs/star-DGcH7Yso.js → esm/star-CeFAfcTv.js} +2 -4
- package/dist/esm/{tracked-promise-yWzlErXb.js → tracked-promise-BhGtlRVb.js} +1 -1
- package/dist/esm/twilight.js +3 -3
- package/dist/esm/{vanilla-picker-Bwq5IBwq.js → vanilla-picker-CBI_4fLe.js} +1 -1
- package/dist/twilight/{p-997a1fdf.entry.js → p-01240db4.entry.js} +1 -1
- package/dist/twilight/{p-4df90b34.entry.js → p-01cd2407.entry.js} +1 -1
- package/dist/twilight/{p-917bae25.entry.js → p-02b365bd.entry.js} +1 -1
- package/dist/twilight/p-03ab9920.entry.js +4 -0
- package/dist/twilight/{p-1ec309ad.entry.js → p-03cc6665.entry.js} +1 -1
- package/dist/twilight/{p-416e7ea9.entry.js → p-0a32b0d6.entry.js} +1 -1
- package/dist/twilight/{p-52df99a3.entry.js → p-0de58301.entry.js} +1 -1
- package/dist/twilight/{p-c6026f2e.entry.js → p-0e0db003.entry.js} +1 -1
- package/dist/twilight/p-0f853d19.entry.js +4 -0
- package/dist/twilight/{p-0f6a9e5e.entry.js → p-0f859745.entry.js} +1 -1
- package/dist/twilight/{p-680e0dca.entry.js → p-0ff0a5cd.entry.js} +1 -1
- package/dist/twilight/{p-b2a12062.entry.js → p-111e8bd4.entry.js} +1 -1
- package/dist/twilight/{p-bd50d1c4.entry.js → p-1182a8df.entry.js} +1 -1
- package/dist/twilight/{p-eeb0e354.entry.js → p-121dc015.entry.js} +1 -1
- package/dist/twilight/{p-df6739de.entry.js → p-15bc19e7.entry.js} +1 -1
- package/dist/twilight/{p-387e06ce.entry.js → p-18dada14.entry.js} +1 -1
- package/dist/twilight/{p-c1e7fe98.entry.js → p-1a3e548c.entry.js} +1 -1
- package/dist/twilight/{p-12d485db.entry.js → p-1f43ed62.entry.js} +1 -1
- package/dist/twilight/{p-ccbf4eea.entry.js → p-2414aef5.entry.js} +1 -1
- package/dist/twilight/{p-363417b6.entry.js → p-25bfec19.entry.js} +1 -1
- package/dist/twilight/{p-8a274920.entry.js → p-26211933.entry.js} +1 -1
- package/dist/twilight/{p-f97717b9.entry.js → p-2656742a.entry.js} +1 -1
- package/dist/twilight/{p-8b45c13a.entry.js → p-26594c13.entry.js} +1 -1
- package/dist/twilight/{p-5dbdf0e7.entry.js → p-271b69a0.entry.js} +1 -1
- package/dist/twilight/{p-c01100d0.entry.js → p-27ae0022.entry.js} +1 -1
- package/dist/twilight/{p-9efc4b59.entry.js → p-28318fdf.entry.js} +1 -1
- package/dist/twilight/{p-9dc6f28e.entry.js → p-28636b6b.entry.js} +1 -1
- package/dist/twilight/{p-28eea468.entry.js → p-2b6f45d9.entry.js} +1 -1
- package/dist/twilight/{p-04612ed4.entry.js → p-2bcfed29.entry.js} +1 -1
- package/dist/twilight/{p-95c6ca83.entry.js → p-2e2d9a86.entry.js} +1 -1
- package/dist/twilight/{p-72bc40b3.entry.js → p-31c63840.entry.js} +1 -1
- package/dist/twilight/{p-8878ec9e.entry.js → p-38e6442f.entry.js} +1 -1
- package/dist/twilight/p-3956807e.entry.js +4 -0
- package/dist/twilight/{p-CJRTPVPy.js → p-495aeIVH.js} +1 -1
- package/dist/twilight/{p-c497fa37.entry.js → p-4b659dd8.entry.js} +1 -1
- package/dist/twilight/{p-5dc0f3c0.entry.js → p-51be1247.entry.js} +1 -1
- package/dist/twilight/{p-f6c20f25.entry.js → p-556550d6.entry.js} +1 -1
- package/dist/twilight/{p-507e04b3.entry.js → p-57926552.entry.js} +1 -1
- package/dist/twilight/{p-cd11cafc.entry.js → p-583b37a5.entry.js} +1 -1
- package/dist/twilight/{p-fe6e676c.entry.js → p-5932a5aa.entry.js} +1 -1
- package/dist/twilight/{p-2ea6c5c6.entry.js → p-5cd89a8e.entry.js} +1 -1
- package/dist/twilight/{p-3cee41e1.entry.js → p-6c74b5a4.entry.js} +1 -1
- package/dist/twilight/{p-8f204414.entry.js → p-7092d5e9.entry.js} +1 -1
- package/dist/twilight/{p-75345728.entry.js → p-7331a7d0.entry.js} +1 -1
- package/dist/twilight/{p-0be72b27.entry.js → p-75b9780f.entry.js} +1 -1
- package/dist/twilight/{p-44819d23.entry.js → p-75d071f5.entry.js} +1 -1
- package/dist/twilight/{p-868b6dcc.entry.js → p-78364b26.entry.js} +1 -1
- package/dist/twilight/{p-d6ace1e8.entry.js → p-7869e2b4.entry.js} +1 -1
- package/dist/twilight/{p-62e99802.entry.js → p-789ede46.entry.js} +1 -1
- package/dist/twilight/{p-168bfefc.entry.js → p-7cb04076.entry.js} +1 -1
- package/dist/twilight/{p-1abccd80.entry.js → p-7fa40598.entry.js} +1 -1
- package/dist/twilight/{p-f4b040f0.entry.js → p-8430e33c.entry.js} +1 -1
- package/dist/twilight/p-8549ed85.entry.js +4 -0
- package/dist/twilight/{p-d1b3e98b.entry.js → p-88bc9aff.entry.js} +1 -1
- package/dist/twilight/{p-8ba7b32d.entry.js → p-8d83987b.entry.js} +1 -1
- package/dist/twilight/{p-54047fdd.entry.js → p-956be35f.entry.js} +1 -1
- package/dist/twilight/{p-d5bbdd47.entry.js → p-9c27c468.entry.js} +1 -1
- package/dist/twilight/{p-4Xs3NevL.js → p-B4xPvvKC.js} +1 -1
- package/dist/twilight/{p-BgI56yKL.js → p-Bp81rq7T.js} +1 -1
- package/dist/twilight/{p-ZT7ehBBk.js → p-CeFAfcTv.js} +1 -1
- package/dist/twilight/{p-BF7QVpUp.js → p-CszkocSp.js} +2 -2
- package/dist/twilight/{p-3Yh5uCQZ.js → p-CvcP7d1k.js} +1 -1
- package/dist/twilight/{p-DTwxTvVu.js → p-D1tp_3zr.js} +1 -1
- package/dist/twilight/{p-6iwUgroX.js → p-D3lg7_WR.js} +1 -1
- package/dist/twilight/{p-Bnnviqjp.js → p-D68AOZPQ.js} +1 -1
- package/dist/twilight/{p-K0OclOPO.js → p-DkTbP5UX.js} +2 -2
- package/dist/twilight/{p-327d33c2.entry.js → p-a104a885.entry.js} +1 -1
- package/dist/twilight/{p-8b2fb172.entry.js → p-a5310ab5.entry.js} +1 -1
- package/dist/twilight/{p-30796ada.entry.js → p-ab8ffcbf.entry.js} +1 -1
- package/dist/twilight/{p-9d51f43d.entry.js → p-acf6a8f0.entry.js} +1 -1
- package/dist/twilight/{p-4bdd0eab.entry.js → p-ad8111fa.entry.js} +1 -1
- package/dist/twilight/{p-fb9f7001.entry.js → p-af41ebe4.entry.js} +1 -1
- package/dist/twilight/{p-cdfe32c9.entry.js → p-b4fc5871.entry.js} +1 -1
- package/dist/twilight/{p-f5242092.entry.js → p-b7916db2.entry.js} +1 -1
- package/dist/twilight/{p-c19cdf96.entry.js → p-b87ac43c.entry.js} +1 -1
- package/dist/twilight/{p-7cfe5dbf.entry.js → p-bdca0d7a.entry.js} +1 -1
- package/dist/twilight/{p-6e6f4879.entry.js → p-be44f2e4.entry.js} +1 -1
- package/dist/twilight/{p-18c99d79.entry.js → p-bf50723d.entry.js} +1 -1
- package/dist/twilight/{p-283b7a09.entry.js → p-c0dd76e3.entry.js} +1 -1
- package/dist/twilight/{p-7ab11977.entry.js → p-c3c9b136.entry.js} +1 -1
- package/dist/twilight/{p-cb475d27.entry.js → p-c583ab13.entry.js} +1 -1
- package/dist/twilight/p-c71a6e9c.entry.js +4 -0
- package/dist/twilight/{p-24eb59ac.entry.js → p-c774a729.entry.js} +1 -1
- package/dist/twilight/p-c80b8b30.entry.js +4 -0
- package/dist/twilight/{p-76f06b0a.entry.js → p-c9dcf28b.entry.js} +1 -1
- package/dist/twilight/{p-DZu6rifA.js → p-cUujZ85s.js} +1 -1
- package/dist/twilight/{p-5effd85b.entry.js → p-ca1c1c50.entry.js} +2 -2
- package/dist/twilight/{p-e9439252.entry.js → p-cbbfec66.entry.js} +1 -1
- package/dist/twilight/{p-3f1913e0.entry.js → p-ce0d56c1.entry.js} +1 -1
- package/dist/twilight/{p-906dfda7.entry.js → p-d0eb0e3d.entry.js} +1 -1
- package/dist/twilight/{p-7a738892.entry.js → p-d27c3758.entry.js} +1 -1
- package/dist/twilight/p-d617bb3f.entry.js +4 -0
- package/dist/twilight/{p-e30f415c.entry.js → p-d7633d87.entry.js} +1 -1
- package/dist/twilight/{p-bb7d240f.entry.js → p-d981255b.entry.js} +1 -1
- package/dist/twilight/{p-2368ab21.entry.js → p-d9e7a2a9.entry.js} +1 -1
- package/dist/twilight/{p-cb9501dc.entry.js → p-dca909c8.entry.js} +1 -1
- package/dist/twilight/{p-90976775.entry.js → p-df9267ca.entry.js} +1 -1
- package/dist/twilight/{p-44ed9315.entry.js → p-eba770b4.entry.js} +1 -1
- package/dist/twilight/{p-9cb07624.entry.js → p-ee67787c.entry.js} +1 -1
- package/dist/twilight/{p-c1b56f08.entry.js → p-f303739b.entry.js} +1 -1
- package/dist/twilight/{p-3e9bba4f.entry.js → p-f834ded2.entry.js} +1 -1
- package/dist/twilight/{p-b69cc47d.entry.js → p-f855ad35.entry.js} +1 -1
- package/dist/twilight/{p-1695dd23.entry.js → p-faf369b8.entry.js} +1 -1
- package/dist/twilight/{p-4e16be16.entry.js → p-fc26088c.entry.js} +1 -1
- package/dist/twilight/{p-BHY6Sj5y.js → p-jgiIvZFz.js} +1 -1
- package/dist/twilight/p-lMgMt31Q.js +4 -0
- package/dist/twilight/{p-BZ24UYWJ.js → p-qT0_dvbw.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-comments/interfaces.d.ts +6 -0
- package/dist/types/components/salla-comments/salla-comment-factors.d.ts +6 -0
- package/dist/types/components/salla-comments/salla-comment-item.d.ts +3 -0
- package/dist/types/components/salla-comments/salla-comments.d.ts +2 -2
- package/dist/types/components/salla-rating-modal/order-feedback-response.d.ts +32 -0
- package/dist/types/components/salla-rating-modal/salla-rating-modal-v2.d.ts +151 -0
- package/dist/types/components/salla-rating-modal/salla-rating-modal.d.ts +5 -1
- package/dist/types/components/salla-rating-stars/salla-rating-stars.d.ts +13 -0
- package/dist/types/components/salla-review-factors-tags/helpers.d.ts +16 -0
- package/dist/types/components/salla-review-factors-tags/interfaces.d.ts +17 -0
- package/dist/types/components/salla-review-factors-tags/salla-review-factors-tags.d.ts +24 -0
- package/dist/types/components/salla-reviews-summary/interfaces.d.ts +5 -0
- package/dist/types/components/salla-reviews-summary/salla-reviews-summary.d.ts +2 -0
- package/dist/types/components.d.ts +114 -2
- package/package.json +5 -5
- package/dist/twilight/p-38c82b5b.entry.js +0 -4
- package/dist/twilight/p-db3da75c.entry.js +0 -4
- package/dist/twilight/p-e10eed6e.entry.js +0 -4
- package/dist/twilight/p-e52bbc5f.entry.js +0 -4
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Crafted with ❤ by Salla
|
|
3
|
+
*/
|
|
4
|
+
import { r as registerInstance, f as forceUpdate, h, H as Host, a as getElement } from './index-DkTbP5UX.js';
|
|
5
|
+
import { S as Star } from './star-CeFAfcTv.js';
|
|
6
|
+
import { S as ShippingFast } from './shipping-fast-lMgMt31Q.js';
|
|
7
|
+
import { C as CheckCircle2 } from './check-circle2-BV4kqbdL.js';
|
|
8
|
+
import { H as Helper } from './Helper-BQ9mvrt9.js';
|
|
9
|
+
import { I as ImageIcon } from './image-C-tzSDxw.js';
|
|
10
|
+
import { W as WhatsappIcon } from './whatsapp2-CgR-T_ZS.js';
|
|
11
|
+
import { e as email } from './mail-DzAIgzdz.js';
|
|
12
|
+
import './anime.es-CgtvEd63.js';
|
|
13
|
+
|
|
14
|
+
const sallaRatingModalCss = ".s-rating-modal-product-details{padding-bottom:0.5rem}.s-rating-modal-comment{margin-top:0.35rem}.s-rating-modal-product{margin-bottom:1rem}.s-rating-modal-product-img{display:block;width:100%;height:100%;object-fit:cover}.s-rating-modal-product-title{font-size:0.95rem;font-weight:600;line-height:1.5;margin:0}.s-rating-modal-stars-product{margin-top:0.5rem}.s-rating-modal-product-details-main{display:flex;align-items:center;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-info-row{display:flex;align-items:center;gap:0.6rem;margin-bottom:0.5rem;padding-bottom:0;border-bottom:0}.s-rating-modal-product-main-review{width:100%;text-align:right}.s-rating-modal-product-rating-rows{display:grid;gap:0.45rem;margin:0.2rem 0 0.7rem}.s-rating-modal-product-rating-row{display:flex;align-items:center;justify-content:space-between;gap:0.75rem;min-height:2rem}.s-rating-modal-product-rating-row salla-rating-stars{flex-shrink:0}.s-rating-modal-product-rating-row .s-rating-stars-wrapper{align-items:center;min-height:1.75rem}.s-rating-modal-product-rating-row .s-rating-stars-label,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag{min-width:auto;min-height:1.25rem;line-height:1.25rem;font-size:0.8rem;color:#5b6470;white-space:nowrap;text-align:end;transition:opacity 0.15s ease}.s-rating-modal-product-rating-row .s-rating-stars-label--empty,.s-rating-modal-product-rating-row .s-rating-stars-label-without-tag--empty{opacity:0}.s-rating-modal-product-rating-row-main{margin-bottom:0.35rem;padding:0.5rem 0.6rem;border:1px solid #d1d5db;border-radius:0.45rem;background:transparent}.s-rating-modal-product-factor-name{color:#5b6470;font-size:0.9rem;line-height:1.25}.s-rating-modal-product-rating-row-main .s-rating-modal-product-factor-name{font-size:1rem;color:#5b6470}.s-rating-modal-product-factor-required{color:#f87171;margin-inline-start:0.2rem}.s-rating-modal-product-img-wrap{width:5rem;min-width:5rem;height:3.5rem;flex-shrink:0;overflow:hidden;border-radius:0.375rem;background:#f3f4f6}.s-rating-modal-uploader.is-opened{height:auto !important;opacity:1 !important;overflow:visible !important;pointer-events:auto !important;margin-bottom:1rem}";
|
|
15
|
+
|
|
16
|
+
const SallaRatingModalV2 = class {
|
|
17
|
+
constructor(hostRef) {
|
|
18
|
+
registerInstance(this, hostRef);
|
|
19
|
+
this.hasError = false;
|
|
20
|
+
this.showContactWidget = true;
|
|
21
|
+
this.images = [];
|
|
22
|
+
this.productImages = {};
|
|
23
|
+
this.editItemImages = [];
|
|
24
|
+
this.productReviewFactors = {};
|
|
25
|
+
this.editFactorRatings = {};
|
|
26
|
+
this.productMainRatings = {};
|
|
27
|
+
this.productFactorRatings = {};
|
|
28
|
+
this.contact_body = (store, id, customer) => salla.lang.get('pages.rating.contact_subject', { store, id, customer });
|
|
29
|
+
this.editMode = false;
|
|
30
|
+
this.defaultMode = false;
|
|
31
|
+
this.deleteMode = false;
|
|
32
|
+
this.shouldOpenDeleteModal = false;
|
|
33
|
+
this.editItem = null;
|
|
34
|
+
this.allowAttachImages = false;
|
|
35
|
+
this.allowContactSupport = false;
|
|
36
|
+
this.dragAndDropFilesLabel = salla.lang.get('common.uploader.drag_and_drop_files');
|
|
37
|
+
this.contactSubjectLabel = salla.lang.get('pages.rating.contact_subject');
|
|
38
|
+
this.editReviewLabel = salla.lang.get('pages.rating.edit_review');
|
|
39
|
+
this.allowedImagesTypesLabel = salla.lang.get('common.uploader.allowed_images_types');
|
|
40
|
+
this.threeImagesMax = salla.lang.get('common.uploader.max_three_images');
|
|
41
|
+
this.areYouSureLabel = salla.lang.get('pages.rating.are_you_sure_you_want_to_delete_review');
|
|
42
|
+
this.confirmDeletionLabel = salla.lang.get('pages.rating.confirm_deletion');
|
|
43
|
+
this.cancelLabel = salla.lang.get('common.elements.cancel');
|
|
44
|
+
this.confirmDeleteBtn = salla.lang.get('common.elements.confirm_delete');
|
|
45
|
+
this.updatedSuccessfullyLabel = salla.lang.get('pages.rating.review_updated_successfully');
|
|
46
|
+
this.deletedSuccessfullyLabel = salla.lang.get('pages.rating.review_deleted_successfully');
|
|
47
|
+
this.contactUsLabel = salla.lang.get('blocks.footer.social');
|
|
48
|
+
this.requiredFactorsLabel = salla.lang.get('pages.rating.rate_required_factors');
|
|
49
|
+
this.overallProductRatingLabel = salla.lang.get('pages.rating.overall_product_rating');
|
|
50
|
+
this.contentRefs = [];
|
|
51
|
+
this.hiddenInputs = [];
|
|
52
|
+
this.userFilledFactorKeys = {};
|
|
53
|
+
this.boundRatingRows = new WeakSet();
|
|
54
|
+
this.stepsCount = 0;
|
|
55
|
+
this.currentIndex = 0;
|
|
56
|
+
this.submitted = [];
|
|
57
|
+
this.MAX_UPLOAD_LIMIT = 3;
|
|
58
|
+
this.thanksCountdownInterval = null;
|
|
59
|
+
this.scheduleWizardSetup = false;
|
|
60
|
+
salla.lang.onLoaded(() => {
|
|
61
|
+
this.contactUsLabel = salla.lang.get('blocks.footer.social');
|
|
62
|
+
const setNestedAsync = (lang, key, value) => {
|
|
63
|
+
return new Promise(resolve => {
|
|
64
|
+
salla.helpers.setNested(salla.lang.messages[lang], key, value);
|
|
65
|
+
resolve(true);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const setTranslations = async () => {
|
|
69
|
+
await setNestedAsync('ar.trans', 'common.uploader.drag_and_drop_files', 'اسحب الملفات وأفلتها هنا');
|
|
70
|
+
await setNestedAsync('en.trans', 'common.uploader.drag_and_drop_files', 'Drag and drop files here');
|
|
71
|
+
await setNestedAsync('ar.trans', 'common.uploader.allowed_images_types', ' .jpg أو jpeg أو png يُسمح بإضافة صور بصيغة');
|
|
72
|
+
await setNestedAsync('en.trans', 'common.uploader.allowed_images_types', 'Images in jpg, jpeg, or png format are allowed.');
|
|
73
|
+
await setNestedAsync('ar.trans', 'pages.rating.add_images', 'اضافة صور');
|
|
74
|
+
await setNestedAsync('en.trans', 'pages.rating.add_images', 'Add Images');
|
|
75
|
+
await setNestedAsync('ar.trans', 'pages.rating.edit_images', 'تعديل الصور');
|
|
76
|
+
await setNestedAsync('en.trans', 'pages.rating.edit_images', 'Edit Images');
|
|
77
|
+
await setNestedAsync('ar.trans', 'pages.rating.edit_review', 'تعديل التقييم');
|
|
78
|
+
await setNestedAsync('en.trans', 'pages.rating.edit_review', 'Edit review');
|
|
79
|
+
await setNestedAsync('ar.trans', 'pages.rating.confirm_deletion', 'تأكيد حذف التقييم');
|
|
80
|
+
await setNestedAsync('en.trans', 'pages.rating.confirm_deletion', 'Confirm review deletion');
|
|
81
|
+
await setNestedAsync('ar.trans', 'pages.rating.are_you_sure_you_want_to_delete_review', 'هل أنت متأكد من حذف تقييمك؟');
|
|
82
|
+
await setNestedAsync('en.trans', 'pages.rating.are_you_sure_you_want_to_delete_review', 'Are you sure you want to delete your review?');
|
|
83
|
+
await setNestedAsync('ar.trans', 'pages.rating.review_updated_successfully', 'تم تعديل التقييم بنجاح');
|
|
84
|
+
await setNestedAsync('en.trans', 'pages.rating.review_updated_successfully', 'The review has been successfully updated.');
|
|
85
|
+
await setNestedAsync('ar.trans', 'pages.rating.review_deleted_successfully', 'تم حذف التقييم بنجاح');
|
|
86
|
+
await setNestedAsync('en.trans', 'pages.rating.review_deleted_successfully', 'The review has been successfully deleted.');
|
|
87
|
+
await setNestedAsync('ar.trans', 'pages.rating.images_count', 'الصور ( :current من أصل :total )');
|
|
88
|
+
await setNestedAsync('en.trans', 'pages.rating.images_count', 'Images ( :current of :total )');
|
|
89
|
+
await setNestedAsync('ar.trans', 'common.uploader.max_three_images', `.أضف ${this.MAX_UPLOAD_LIMIT} صور كحد أقصى`);
|
|
90
|
+
await setNestedAsync('en.trans', 'common.uploader.max_three_images', `Add up to ${this.MAX_UPLOAD_LIMIT} images maximum.`);
|
|
91
|
+
await setNestedAsync('ar.trans', 'common.elements.confirm_delete', 'تأكيد الحذف');
|
|
92
|
+
await setNestedAsync('en.trans', 'common.elements.confirm_delete', 'Confirm deletion');
|
|
93
|
+
await setNestedAsync('ar.trans', 'pages.rating.rate_required_factors', 'يرجى تقييم جميع المعايير لإتمام مراجعتك.');
|
|
94
|
+
await setNestedAsync('en.trans', 'pages.rating.rate_required_factors', 'Please rate all required factors to complete your review.');
|
|
95
|
+
await setNestedAsync('ar.trans', 'pages.rating.overall_product_rating', 'التقييم العام للمنتج');
|
|
96
|
+
await setNestedAsync('en.trans', 'pages.rating.overall_product_rating', 'Overall product rating');
|
|
97
|
+
this.dragAndDropFilesLabel = salla.lang.get('common.uploader.drag_and_drop_files');
|
|
98
|
+
this.allowedImagesTypesLabel = salla.lang.get('common.uploader.allowed_images_types');
|
|
99
|
+
this.threeImagesMax = salla.lang.get('common.uploader.max_three_images');
|
|
100
|
+
this.contactSubjectLabel = salla.lang.get('pages.rating.contact_subject');
|
|
101
|
+
this.editReviewLabel = salla.lang.get('pages.rating.edit_review');
|
|
102
|
+
this.areYouSureLabel = salla.lang.get('pages.rating.are_you_sure_you_want_to_delete_review');
|
|
103
|
+
this.confirmDeletionLabel = salla.lang.get('pages.rating.confirm_deletion');
|
|
104
|
+
this.cancelLabel = salla.lang.get('common.elements.cancel');
|
|
105
|
+
this.updatedSuccessfullyLabel = salla.lang.get('pages.rating.review_updated_successfully');
|
|
106
|
+
this.deletedSuccessfullyLabel = salla.lang.get('pages.rating.review_deleted_successfully');
|
|
107
|
+
this.confirmDeleteBtn = salla.lang.get('common.elements.confirm_delete');
|
|
108
|
+
this.requiredFactorsLabel = salla.lang.get('pages.rating.rate_required_factors');
|
|
109
|
+
this.overallProductRatingLabel = salla.lang.get('pages.rating.overall_product_rating');
|
|
110
|
+
this.contact_body = (store, id, customer) => salla.lang.get('pages.rating.contact_body', { store, id, customer });
|
|
111
|
+
};
|
|
112
|
+
setTranslations();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Show the rating modal
|
|
117
|
+
*/
|
|
118
|
+
syncStoreSettings() {
|
|
119
|
+
if (!this.orderId) {
|
|
120
|
+
this.orderId = salla.config.get('page.id');
|
|
121
|
+
}
|
|
122
|
+
this.allowAttachImages = !!salla.config.get('store.settings.rating.allow_attach_images');
|
|
123
|
+
this.allowContactSupport = !!salla.config.get('store.settings.rating.allow_contact_support');
|
|
124
|
+
}
|
|
125
|
+
/** Encrypted order id from page config / prop — used to fetch order details. */
|
|
126
|
+
getRatingOrderId() {
|
|
127
|
+
return this.orderId || salla.config.get('page.id');
|
|
128
|
+
}
|
|
129
|
+
/** Numeric order id from API response — used when submitting ratings. */
|
|
130
|
+
getSubmitOrderId() {
|
|
131
|
+
return this.orderId;
|
|
132
|
+
}
|
|
133
|
+
isCustomerOrderShape(value) {
|
|
134
|
+
if (!value || typeof value !== 'object') {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
const record = value;
|
|
138
|
+
return (!!record.rating &&
|
|
139
|
+
(Array.isArray(record.items) ||
|
|
140
|
+
Array.isArray(record.products) ||
|
|
141
|
+
Array.isArray(record.rating?.product) ||
|
|
142
|
+
Array.isArray(record.rating?.products)));
|
|
143
|
+
}
|
|
144
|
+
getBootstrapOrder() {
|
|
145
|
+
const page = salla.config.get('page');
|
|
146
|
+
if (this.isCustomerOrderShape(page)) {
|
|
147
|
+
return page;
|
|
148
|
+
}
|
|
149
|
+
if (page && typeof page === 'object') {
|
|
150
|
+
const pageRecord = page;
|
|
151
|
+
if (Array.isArray(pageRecord.products)) {
|
|
152
|
+
return page;
|
|
153
|
+
}
|
|
154
|
+
const nestedOrder = pageRecord.order;
|
|
155
|
+
if (this.isCustomerOrderShape(nestedOrder)) {
|
|
156
|
+
return nestedOrder;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
161
|
+
async loadCustomerOrderForEdit() {
|
|
162
|
+
const bootstrapOrder = this.getBootstrapOrder();
|
|
163
|
+
if (bootstrapOrder?.rating?.product || bootstrapOrder?.rating?.products) {
|
|
164
|
+
this.order = bootstrapOrder;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const response = await salla.api.withoutNotifier(() => salla.order.api.getDetails(this.getRatingOrderId()));
|
|
169
|
+
if (response?.data) {
|
|
170
|
+
this.order = response.data;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (_error) {
|
|
174
|
+
if (!this.order) {
|
|
175
|
+
const orderResponse = await salla.api.withoutNotifier(() => salla.rating.api.order(this.getRatingOrderId()));
|
|
176
|
+
this.order = orderResponse.data;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
getOrderProductRatings(order = this.order) {
|
|
181
|
+
if (!order?.rating) {
|
|
182
|
+
return [];
|
|
183
|
+
}
|
|
184
|
+
return [
|
|
185
|
+
...this.normalizeToArray(order.rating.product),
|
|
186
|
+
...this.normalizeToArray(order.rating.products),
|
|
187
|
+
];
|
|
188
|
+
}
|
|
189
|
+
getMatchedProductRating(order = this.order, productId, feedbackId) {
|
|
190
|
+
return this.getOrderProductRatings(order).find(entry => Number(entry?.id ?? entry?.feedback_id) === Number(feedbackId) ||
|
|
191
|
+
Number(entry?.product_id ?? entry?.product?.id) === Number(productId));
|
|
192
|
+
}
|
|
193
|
+
hasRatingFeedback(feedback) {
|
|
194
|
+
const rating = feedback?.rating;
|
|
195
|
+
return rating !== undefined && rating !== null && rating !== '' && Number(rating) > 0;
|
|
196
|
+
}
|
|
197
|
+
isTestimonialsEnabled(order = this.order) {
|
|
198
|
+
if (order?.testimonials_enabled === false) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
if (this.hasRatingFeedback(order?.store?.feedback)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
if (order?.testimonials_enabled === true) {
|
|
205
|
+
return true;
|
|
206
|
+
}
|
|
207
|
+
return !!order?.allowed_ratings?.testimonials_enabled;
|
|
208
|
+
}
|
|
209
|
+
isProductsEnabled(order = this.order) {
|
|
210
|
+
if (order?.products_enabled === false) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return this.getRateableProducts(order).length > 0;
|
|
214
|
+
}
|
|
215
|
+
isShippingEnabled(order = this.order) {
|
|
216
|
+
if (order?.shipping_enabled === false) {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
if (this.hasRatingFeedback(order?.shipping?.feedback)) {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if (!order?.shipping?.company) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
if (order?.shipping_enabled === true) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
return !!order?.allowed_ratings?.shipping_enabled;
|
|
229
|
+
}
|
|
230
|
+
getOrderProducts(order = this.order) {
|
|
231
|
+
if (!Array.isArray(order?.products)) {
|
|
232
|
+
return [];
|
|
233
|
+
}
|
|
234
|
+
return order.products.filter(item => item?.product?.id);
|
|
235
|
+
}
|
|
236
|
+
getRateableProducts(order = this.order) {
|
|
237
|
+
return this.getOrderProducts(order).filter(item => !this.hasRatingFeedback(item?.feedback));
|
|
238
|
+
}
|
|
239
|
+
getStepsCount(order = this.order) {
|
|
240
|
+
if (!order) {
|
|
241
|
+
return 0;
|
|
242
|
+
}
|
|
243
|
+
let count = 0;
|
|
244
|
+
if (this.isTestimonialsEnabled(order)) {
|
|
245
|
+
count++;
|
|
246
|
+
}
|
|
247
|
+
if (this.isProductsEnabled(order)) {
|
|
248
|
+
count += this.getRateableProducts(order).length;
|
|
249
|
+
}
|
|
250
|
+
if (this.isShippingEnabled(order) && order.shipping?.company) {
|
|
251
|
+
count++;
|
|
252
|
+
}
|
|
253
|
+
return count;
|
|
254
|
+
}
|
|
255
|
+
afterOrderLoaded() {
|
|
256
|
+
this.stepsCount = this.getStepsCount();
|
|
257
|
+
this.scheduleWizardSetup = true;
|
|
258
|
+
forceUpdate(this);
|
|
259
|
+
}
|
|
260
|
+
async open() {
|
|
261
|
+
await salla.onReady();
|
|
262
|
+
this.syncStoreSettings();
|
|
263
|
+
this.defaultMode = true;
|
|
264
|
+
this.currentIndex = 0;
|
|
265
|
+
this.submitted = [];
|
|
266
|
+
return new Promise(resolve => {
|
|
267
|
+
setTimeout(() => {
|
|
268
|
+
this.modal
|
|
269
|
+
.open()
|
|
270
|
+
.then(() => this.order ||
|
|
271
|
+
salla.api
|
|
272
|
+
.withoutNotifier(() => salla.rating.api.order(this.getRatingOrderId()))
|
|
273
|
+
.then(async (res) => {
|
|
274
|
+
this.order = res.data;
|
|
275
|
+
this.productReviewFactors = await this.fetchAllProductReviewFactors(res.data);
|
|
276
|
+
}))
|
|
277
|
+
.then(() => this.modal.setTitle(`${salla.lang.get('pages.rating.rate_order')} <span class="unicode">(#${this.order.id})</span>`))
|
|
278
|
+
.then(() => {
|
|
279
|
+
// Initialize productImages for all products
|
|
280
|
+
const initialImages = {};
|
|
281
|
+
for (const item of this.getRateableProducts()) {
|
|
282
|
+
initialImages[item.product.id] = [];
|
|
283
|
+
}
|
|
284
|
+
this.productImages = initialImages;
|
|
285
|
+
})
|
|
286
|
+
.then(() => this.modal.stopLoading())
|
|
287
|
+
.then(() => this.afterOrderLoaded())
|
|
288
|
+
.catch(e => {
|
|
289
|
+
resolve(false);
|
|
290
|
+
this.hasError = true;
|
|
291
|
+
this.errorMessage = e.response?.data?.error?.message || e.response?.data;
|
|
292
|
+
this.modal.stopLoading();
|
|
293
|
+
});
|
|
294
|
+
resolve(true);
|
|
295
|
+
}, 50);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
async openEditModal(params) {
|
|
299
|
+
await salla.onReady();
|
|
300
|
+
this.syncStoreSettings();
|
|
301
|
+
this.defaultMode = false;
|
|
302
|
+
this.editMode = true;
|
|
303
|
+
this.editType = params.type;
|
|
304
|
+
this.editFeedbackId = params.feedback_id;
|
|
305
|
+
try {
|
|
306
|
+
await this.fetchEditItem(params.feedback_id);
|
|
307
|
+
if (this.editType === 'product' && this.editItem?.product?.id) {
|
|
308
|
+
await this.loadCustomerOrderForEdit();
|
|
309
|
+
await this.ensureProductFactorsLoaded(this.editItem.product.id);
|
|
310
|
+
this.editFactorRatings = { ...this.buildEditFactorRatings(this.editItem.product.id) };
|
|
311
|
+
this.markExistingFactorRatingsAsUserFilled(this.editItem.product.id, this.editFactorRatings);
|
|
312
|
+
}
|
|
313
|
+
this.editModal.open();
|
|
314
|
+
}
|
|
315
|
+
catch (e) {
|
|
316
|
+
this.hasError = true;
|
|
317
|
+
this.errorMessage = e.response?.data?.error?.message || e.response?.data;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
async fetchEditItem(feedbackId) {
|
|
321
|
+
const endpoint = `rating/${feedbackId}/show`;
|
|
322
|
+
const response = await salla.api.request(endpoint);
|
|
323
|
+
this.editItem = response.data;
|
|
324
|
+
if (this.allowAttachImages && this.editType == 'product' && this.editItem.images.length) {
|
|
325
|
+
this.editItemImages = this.editItem.images.map(img => {
|
|
326
|
+
return { id: `${Math.floor(100 + Math.random() * 900)}`, url: img };
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async editReview() {
|
|
331
|
+
const endpoint = `rating/${this.editFeedbackId}`;
|
|
332
|
+
let data;
|
|
333
|
+
if (this.editType === 'product') {
|
|
334
|
+
const container = this.editModal.querySelector('[data-type="products"]') || this.currentTab;
|
|
335
|
+
data = this.buildProductRatingPayload(this.collectFormData(container), container);
|
|
336
|
+
if (!data.product_id && this.editItem?.product?.id) {
|
|
337
|
+
data.product_id = String(this.editItem.product.id);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
data = this.collectFormData(this.editModal);
|
|
342
|
+
data.images && (data.images = data.images.split(','));
|
|
343
|
+
}
|
|
344
|
+
await salla.api.request(endpoint, data, 'put').then(res => {
|
|
345
|
+
this.editModal.close();
|
|
346
|
+
salla.notify.success(res.message || this.updatedSuccessfullyLabel);
|
|
347
|
+
setTimeout(() => {
|
|
348
|
+
window.location.reload();
|
|
349
|
+
}, 500);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
async openDeleteModal(params) {
|
|
353
|
+
this.defaultMode = false;
|
|
354
|
+
this.deleteMode = true;
|
|
355
|
+
this.deleteFeedbackId = params.feedback_id;
|
|
356
|
+
this.shouldOpenDeleteModal = true;
|
|
357
|
+
return new Promise(resolve => {
|
|
358
|
+
setTimeout(() => {
|
|
359
|
+
this.deleteModal.open().then(() => resolve(true));
|
|
360
|
+
}, 50);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
async deleteReview() {
|
|
364
|
+
const endpoint = `rating/${this.deleteFeedbackId}`;
|
|
365
|
+
await salla.api.request(endpoint, null, 'delete').then(() => {
|
|
366
|
+
this.deleteModal.close();
|
|
367
|
+
salla.notify.success(this.deletedSuccessfullyLabel);
|
|
368
|
+
setTimeout(() => {
|
|
369
|
+
window.location.reload();
|
|
370
|
+
}, 500);
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Show the rating modal
|
|
375
|
+
*/
|
|
376
|
+
async close() {
|
|
377
|
+
return this.modal.close();
|
|
378
|
+
}
|
|
379
|
+
// handle wizard
|
|
380
|
+
handleWizard() {
|
|
381
|
+
this.steps = this.modal.querySelectorAll('.s-rating-modal-step');
|
|
382
|
+
this.dots = this.modal.querySelectorAll('.s-rating-modal-step-dot');
|
|
383
|
+
if (this.stepsCount === 0) {
|
|
384
|
+
this.showThankYou();
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
this.showActiveStep();
|
|
388
|
+
}
|
|
389
|
+
refreshWizardRefs() {
|
|
390
|
+
if (!this.modal) {
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
this.steps = this.modal.querySelectorAll('.s-rating-modal-step');
|
|
394
|
+
this.dots = this.modal.querySelectorAll('.s-rating-modal-step-dot');
|
|
395
|
+
}
|
|
396
|
+
showActiveStep(current = null) {
|
|
397
|
+
this.refreshWizardRefs();
|
|
398
|
+
this.currentTab = current || this.steps[this.currentIndex];
|
|
399
|
+
if (!this.currentTab) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
Helper.toggleClassIf('.s-rating-modal-step-dot', 's-rating-modal-bg-gray', 's-rating-modal-bg-primary', dot => dot != this.dots[this.currentIndex]).toggleClassIf('.s-rating-modal-step', 's-rating-modal-active', 's-rating-modal-hidden', tab => tab == this.currentTab);
|
|
403
|
+
if (this.currentIndex !== 0) {
|
|
404
|
+
// the animation
|
|
405
|
+
Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-unactive', 's-rating-modal-hidden', () => true);
|
|
406
|
+
setTimeout(() => Helper.toggleElementClassIf(this.currentTab, 's-rating-modal-active', 's-rating-modal-unactive', () => true), 300);
|
|
407
|
+
}
|
|
408
|
+
// Btn text
|
|
409
|
+
const nextType = this.steps[this.currentIndex + 1]?.dataset.type;
|
|
410
|
+
this.nextBtn?.setText(nextType
|
|
411
|
+
? `${salla.lang.get('pages.rating.rate')} ${salla.lang.get(`pages.rating.${nextType}`)}`
|
|
412
|
+
: salla.lang.get('pages.rating.send_ratings'));
|
|
413
|
+
setTimeout(() => this.updateBodyHeight(), 0);
|
|
414
|
+
setTimeout(() => this.updateBodyHeight(), 150);
|
|
415
|
+
}
|
|
416
|
+
updateBodyHeight() {
|
|
417
|
+
if (!this.body || !this.currentTab) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
// Product step contains async uploader mount; keep height auto to prevent clipping.
|
|
421
|
+
if (this.currentTab.dataset.type === 'products') {
|
|
422
|
+
this.body.style.height = 'auto';
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const extraHeight = this.editMode ? 60 : 0;
|
|
426
|
+
this.body.style.height = `${this.currentTab.offsetHeight + extraHeight}px`;
|
|
427
|
+
}
|
|
428
|
+
previousTab() {
|
|
429
|
+
this.currentIndex > 0 && this.currentIndex--;
|
|
430
|
+
Helper.toggleElementClassIf(this.backBtn, 's-rating-modal-unvisiable', 'block', () => this.currentIndex == 0);
|
|
431
|
+
this.showActiveStep();
|
|
432
|
+
}
|
|
433
|
+
async submit() {
|
|
434
|
+
this.refreshWizardRefs();
|
|
435
|
+
try {
|
|
436
|
+
if (!this.submittedBefore()) {
|
|
437
|
+
this.validate();
|
|
438
|
+
}
|
|
439
|
+
salla.config.canLeave = false;
|
|
440
|
+
await this.nextBtn.load();
|
|
441
|
+
if (!this.submittedBefore()) {
|
|
442
|
+
await this.sendFeedback();
|
|
443
|
+
}
|
|
444
|
+
this.currentTab
|
|
445
|
+
?.querySelectorAll('[name],.s-rating-modal-btn-star')
|
|
446
|
+
.forEach(el => el.setAttribute('disabled', ''));
|
|
447
|
+
if (this.currentIndex < this.stepsCount) {
|
|
448
|
+
this.currentIndex++;
|
|
449
|
+
}
|
|
450
|
+
this.showActiveStep();
|
|
451
|
+
Helper.toggleClassIf('#prev-btn', 'block', 's-rating-modal-unvisiable', () => true);
|
|
452
|
+
if (this.currentIndex === this.stepsCount) {
|
|
453
|
+
this.showThankYou();
|
|
454
|
+
this.showContactWidget = false;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
finally {
|
|
458
|
+
this.nextBtn.stop();
|
|
459
|
+
salla.config.canLeave = true;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
submittedBefore() {
|
|
463
|
+
return this.submitted.includes(this.currentIndex);
|
|
464
|
+
}
|
|
465
|
+
getRatingHiddenInput(container) {
|
|
466
|
+
const element = container;
|
|
467
|
+
const directInput = element.querySelector?.('.rating_hidden_input');
|
|
468
|
+
if (directInput?.name) {
|
|
469
|
+
return directInput;
|
|
470
|
+
}
|
|
471
|
+
const starsComponent = element.querySelector?.('salla-rating-stars');
|
|
472
|
+
return (starsComponent?.shadowRoot?.querySelector('.rating_hidden_input') ||
|
|
473
|
+
null);
|
|
474
|
+
}
|
|
475
|
+
collectNamedInputs(container) {
|
|
476
|
+
const seen = new Set();
|
|
477
|
+
const inputs = [];
|
|
478
|
+
const addInput = (input) => {
|
|
479
|
+
if (!input?.name || seen.has(input)) {
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
seen.add(input);
|
|
483
|
+
inputs.push(input);
|
|
484
|
+
};
|
|
485
|
+
container.querySelectorAll('[name]').forEach((input) => {
|
|
486
|
+
addInput(input);
|
|
487
|
+
});
|
|
488
|
+
container.querySelectorAll('salla-rating-stars').forEach((stars) => {
|
|
489
|
+
addInput(this.getRatingHiddenInput(stars));
|
|
490
|
+
});
|
|
491
|
+
return inputs;
|
|
492
|
+
}
|
|
493
|
+
normalizeFactorsList(factors) {
|
|
494
|
+
if (!factors) {
|
|
495
|
+
return [];
|
|
496
|
+
}
|
|
497
|
+
if (Array.isArray(factors)) {
|
|
498
|
+
return factors;
|
|
499
|
+
}
|
|
500
|
+
if (typeof factors === 'object') {
|
|
501
|
+
return Object.values(factors).filter(entry => entry && typeof entry === 'object');
|
|
502
|
+
}
|
|
503
|
+
return [];
|
|
504
|
+
}
|
|
505
|
+
validate(rating = null, type = null) {
|
|
506
|
+
if (!rating && this.currentTab.dataset.type === 'products') {
|
|
507
|
+
const ratingForms = this.currentTab.querySelectorAll('.rating-outer-form');
|
|
508
|
+
ratingForms.forEach(ratingForm => this.validate(ratingForm, 'product'));
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
rating = rating || this.currentTab;
|
|
512
|
+
const mainRatingRow = rating.querySelector('.s-rating-modal-product-rating-row-main');
|
|
513
|
+
const mainRatingInput = this.getRatingHiddenInput(mainRatingRow || rating);
|
|
514
|
+
const stars = mainRatingInput?.value;
|
|
515
|
+
const validationMessage = rating.querySelector('.s-rating-modal-validation-msg');
|
|
516
|
+
type = type || rating.dataset.type;
|
|
517
|
+
if (!stars) {
|
|
518
|
+
validationMessage.innerHTML = salla.lang
|
|
519
|
+
.get(`pages.rating.rate_${type}_stars`)
|
|
520
|
+
.replace(' (:item)', '');
|
|
521
|
+
throw new Error(validationMessage.innerHTML);
|
|
522
|
+
}
|
|
523
|
+
if (type === 'product') {
|
|
524
|
+
const requiredFactorRows = Array.from(rating.querySelectorAll('.s-rating-modal-product-factor-row[data-required="true"]'));
|
|
525
|
+
const hasMissingRequiredFactor = requiredFactorRows.some((row) => {
|
|
526
|
+
const factorStarsInput = this.getRatingHiddenInput(row);
|
|
527
|
+
return !factorStarsInput?.value;
|
|
528
|
+
});
|
|
529
|
+
if (hasMissingRequiredFactor) {
|
|
530
|
+
validationMessage.innerHTML = this.requiredFactorsLabel;
|
|
531
|
+
throw new Error(validationMessage.innerHTML);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
validationMessage.innerHTML = '';
|
|
535
|
+
}
|
|
536
|
+
collectFormData(container = this.currentTab) {
|
|
537
|
+
const data = {};
|
|
538
|
+
this.collectNamedInputs(container).forEach((input) => {
|
|
539
|
+
const inputData = salla.helpers.inputData(input.name, input.value, data);
|
|
540
|
+
data[inputData.name] = inputData.value;
|
|
541
|
+
});
|
|
542
|
+
return data;
|
|
543
|
+
}
|
|
544
|
+
buildProductRatingPayload(data, container = this.currentTab) {
|
|
545
|
+
if (!data.rating) {
|
|
546
|
+
const mainRatingRow = container.querySelector('.s-rating-modal-product-rating-row-main');
|
|
547
|
+
const mainRatingInput = this.getRatingHiddenInput(mainRatingRow || container);
|
|
548
|
+
if (mainRatingInput?.value) {
|
|
549
|
+
data.rating = mainRatingInput.value;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
const productId = Number(data.product_id);
|
|
553
|
+
let images = [];
|
|
554
|
+
if (data.images) {
|
|
555
|
+
images =
|
|
556
|
+
typeof data.images === 'string' ? data.images.split(',').filter(Boolean) : data.images;
|
|
557
|
+
}
|
|
558
|
+
else if (this.editMode && this.allowAttachImages && productId) {
|
|
559
|
+
images = this.editItemImages.map(img => img.url);
|
|
560
|
+
}
|
|
561
|
+
else if (this.allowAttachImages && productId) {
|
|
562
|
+
images = (this.productImages[productId] || []).map(img => img.url);
|
|
563
|
+
}
|
|
564
|
+
const factors = this.normalizeFactorsList(data.factors)
|
|
565
|
+
.filter(factor => factor?.id && factor?.rating)
|
|
566
|
+
.map(factor => ({
|
|
567
|
+
id: String(factor.id),
|
|
568
|
+
rating: String(factor.rating),
|
|
569
|
+
}));
|
|
570
|
+
return {
|
|
571
|
+
order_id: this.getSubmitOrderId(),
|
|
572
|
+
product_id: String(data.product_id),
|
|
573
|
+
rating: String(data.rating),
|
|
574
|
+
comment: data.comment || data.content || '',
|
|
575
|
+
images,
|
|
576
|
+
factors,
|
|
577
|
+
type: 'products',
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
async sendFeedback() {
|
|
581
|
+
this.refreshWizardRefs();
|
|
582
|
+
const stepType = this.currentTab?.dataset?.type;
|
|
583
|
+
if (stepType === 'products') {
|
|
584
|
+
const data = this.collectFormData(this.currentTab);
|
|
585
|
+
const payload = this.buildProductRatingPayload(data, this.currentTab);
|
|
586
|
+
if (!payload.product_id || !payload.rating) {
|
|
587
|
+
throw new Error('Missing product rating data');
|
|
588
|
+
}
|
|
589
|
+
const res = await salla.rating.api.products(payload);
|
|
590
|
+
this.submitted.push(this.currentIndex);
|
|
591
|
+
return res;
|
|
592
|
+
}
|
|
593
|
+
const data = this.collectFormData(this.currentTab);
|
|
594
|
+
if (Object.keys(data).length === 0) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
data.order_id = this.getSubmitOrderId();
|
|
598
|
+
data.type = stepType;
|
|
599
|
+
const res = await salla.rating.api[stepType](data);
|
|
600
|
+
this.submitted.push(this.currentIndex);
|
|
601
|
+
return res;
|
|
602
|
+
}
|
|
603
|
+
clearThanksCountdown() {
|
|
604
|
+
if (this.thanksCountdownInterval !== null) {
|
|
605
|
+
clearInterval(this.thanksCountdownInterval);
|
|
606
|
+
this.thanksCountdownInterval = null;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
showThankYou() {
|
|
610
|
+
let seconds = 10;
|
|
611
|
+
this.clearThanksCountdown();
|
|
612
|
+
this.thanksCountdownInterval = setInterval(() => {
|
|
613
|
+
this.thanksTime.innerHTML = `00:0${seconds--}`;
|
|
614
|
+
if (seconds > 0) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
this.clearThanksCountdown();
|
|
618
|
+
this.thanksTime.remove();
|
|
619
|
+
this.close().then(() => window.location.reload());
|
|
620
|
+
}, 1000);
|
|
621
|
+
this.modal.querySelector('.s-rating-modal-footer').classList.add('s-rating-modal-unvisiable');
|
|
622
|
+
this.showActiveStep(this.thanksTab);
|
|
623
|
+
}
|
|
624
|
+
getFilepondPlaceholder() {
|
|
625
|
+
return `<div class="s-rating-modal-filepond-placeholder"><span class="s-rating-modal-filepond-placeholder-icon">${ImageIcon}</span><p class="s-rating-modal-filepond-placeholder-text">${this.dragAndDropFilesLabel}<br>
|
|
626
|
+
<span> ${this.allowedImagesTypesLabel} <br> ${this.threeImagesMax} </span></p></div>`;
|
|
627
|
+
}
|
|
628
|
+
getCustomerName() {
|
|
629
|
+
let firstName = salla.config.get('user.first_name') || salla.storage.get('user.first_name') || '';
|
|
630
|
+
let lasName = salla.config.get('user.last_name') || salla.storage.get('user.last_name') || '';
|
|
631
|
+
return `${firstName} ${lasName}`;
|
|
632
|
+
}
|
|
633
|
+
normalizeReviewFactorsPayload(payload) {
|
|
634
|
+
const data = payload?.data ?? payload?.factors;
|
|
635
|
+
if (!Array.isArray(data)) {
|
|
636
|
+
return [];
|
|
637
|
+
}
|
|
638
|
+
return data.flatMap(entry => {
|
|
639
|
+
const items = Array.isArray(entry?.items) ? [...entry.items] : null;
|
|
640
|
+
// Nested form shape: only use items[].id, ignore parent entry id
|
|
641
|
+
if (items?.length) {
|
|
642
|
+
items.sort((a, b) => (Number(a?.sort) || 0) - (Number(b?.sort) || 0));
|
|
643
|
+
const isRequired = !!entry?.is_required;
|
|
644
|
+
return items
|
|
645
|
+
.filter(item => item?.id != null && item?.id !== '')
|
|
646
|
+
.map(item => ({
|
|
647
|
+
id: item.id,
|
|
648
|
+
name: item?.name,
|
|
649
|
+
required: isRequired,
|
|
650
|
+
}));
|
|
651
|
+
}
|
|
652
|
+
// Legacy flat shape (no items array)
|
|
653
|
+
if (entry?.id == null || entry?.id === '') {
|
|
654
|
+
return [];
|
|
655
|
+
}
|
|
656
|
+
return [
|
|
657
|
+
{
|
|
658
|
+
id: entry.id,
|
|
659
|
+
name: entry?.name,
|
|
660
|
+
required: entry?.required ?? entry?.is_required ?? false,
|
|
661
|
+
},
|
|
662
|
+
];
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
async fetchProductReviewFactors(productId) {
|
|
666
|
+
try {
|
|
667
|
+
const response = await salla.api.request(`review/factors/${productId}/form`);
|
|
668
|
+
return this.normalizeReviewFactorsPayload(response);
|
|
669
|
+
}
|
|
670
|
+
catch (_error) {
|
|
671
|
+
return [];
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
async fetchAllProductReviewFactors(order) {
|
|
675
|
+
const products = this.getRateableProducts(order);
|
|
676
|
+
if (!products.length) {
|
|
677
|
+
return {};
|
|
678
|
+
}
|
|
679
|
+
const pairs = await Promise.all(products.map(async (item) => {
|
|
680
|
+
const factors = await this.fetchProductReviewFactors(item.product.id);
|
|
681
|
+
return [item.product.id, factors];
|
|
682
|
+
}));
|
|
683
|
+
return Object.fromEntries(pairs);
|
|
684
|
+
}
|
|
685
|
+
async ensureProductFactorsLoaded(productId) {
|
|
686
|
+
if (!productId || this.productReviewFactors[productId]) {
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
const factors = await this.fetchProductReviewFactors(productId);
|
|
690
|
+
this.productReviewFactors = {
|
|
691
|
+
...this.productReviewFactors,
|
|
692
|
+
[productId]: factors,
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
getFactorFieldName(prefix, factorIndex, field) {
|
|
696
|
+
return prefix
|
|
697
|
+
? `${prefix}[factors][${factorIndex}][${field}]`
|
|
698
|
+
: `factors[${factorIndex}][${field}]`;
|
|
699
|
+
}
|
|
700
|
+
normalizeToArray(value) {
|
|
701
|
+
if (value === null || value === undefined) {
|
|
702
|
+
return [];
|
|
703
|
+
}
|
|
704
|
+
return Array.isArray(value) ? value : [value];
|
|
705
|
+
}
|
|
706
|
+
isFactorReviewsList(value) {
|
|
707
|
+
return (Array.isArray(value) &&
|
|
708
|
+
value.length > 0 &&
|
|
709
|
+
value.every(item => item &&
|
|
710
|
+
typeof item === 'object' &&
|
|
711
|
+
(item['rating'] !== undefined ||
|
|
712
|
+
item['stars'] !== undefined ||
|
|
713
|
+
item['value'] !== undefined)));
|
|
714
|
+
}
|
|
715
|
+
getFactorReviewsFromRecord(record) {
|
|
716
|
+
if (!record) {
|
|
717
|
+
return [];
|
|
718
|
+
}
|
|
719
|
+
for (const key of ['factor_reviews', 'review_factors', 'factors']) {
|
|
720
|
+
const value = record[key];
|
|
721
|
+
if (this.isFactorReviewsList(value)) {
|
|
722
|
+
return value;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return [];
|
|
726
|
+
}
|
|
727
|
+
getEditFactorReviewsList(productId) {
|
|
728
|
+
const orderSources = [this.order, this.getBootstrapOrder()].filter(Boolean);
|
|
729
|
+
for (const order of orderSources) {
|
|
730
|
+
const matchedRating = this.getMatchedProductRating(order, productId, this.editFeedbackId);
|
|
731
|
+
const reviews = this.getFactorReviewsFromRecord(matchedRating);
|
|
732
|
+
if (reviews.length) {
|
|
733
|
+
return reviews;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
const matchedOrderProduct = this.getOrderProducts(this.order).find(item => Number(item.product?.id) === Number(productId));
|
|
737
|
+
const sources = [
|
|
738
|
+
this.editItem?.factor_reviews,
|
|
739
|
+
this.editItem?.review_factors,
|
|
740
|
+
this.editItem?.product?.review_factors,
|
|
741
|
+
this.editItem?.product?.factor_reviews,
|
|
742
|
+
this.editItem?.factors,
|
|
743
|
+
matchedOrderProduct?.factor_reviews,
|
|
744
|
+
matchedOrderProduct?.review_factors,
|
|
745
|
+
matchedOrderProduct?.feedback?.factor_reviews,
|
|
746
|
+
];
|
|
747
|
+
for (const source of sources) {
|
|
748
|
+
if (Array.isArray(source) && source.length > 0) {
|
|
749
|
+
return source;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return [];
|
|
753
|
+
}
|
|
754
|
+
getFactorKey(factor, factorIndex) {
|
|
755
|
+
if (factor.id !== undefined && factor.id !== null && factor.id !== '') {
|
|
756
|
+
return `id:${factor.id}`;
|
|
757
|
+
}
|
|
758
|
+
if (factor.name) {
|
|
759
|
+
return `name:${factor.name.trim()}`;
|
|
760
|
+
}
|
|
761
|
+
return `index:${factorIndex}`;
|
|
762
|
+
}
|
|
763
|
+
getFactorRatingsForProduct(productId) {
|
|
764
|
+
return this.editMode ? this.editFactorRatings : this.productFactorRatings[productId] || {};
|
|
765
|
+
}
|
|
766
|
+
setFactorRatingsForProduct(productId, ratings) {
|
|
767
|
+
if (this.editMode) {
|
|
768
|
+
this.editFactorRatings = ratings;
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
this.productFactorRatings = { ...this.productFactorRatings, [productId]: ratings };
|
|
772
|
+
}
|
|
773
|
+
markExistingFactorRatingsAsUserFilled(productId, factorRatings) {
|
|
774
|
+
const factors = this.productReviewFactors[productId] || [];
|
|
775
|
+
const userFilled = new Set();
|
|
776
|
+
factors.forEach((factor, index) => {
|
|
777
|
+
const key = this.getFactorKey(factor, index);
|
|
778
|
+
const byId = factor.id !== undefined ? factorRatings[String(factor.id)] : undefined;
|
|
779
|
+
const byName = factor.name ? factorRatings[factor.name.trim()] : undefined;
|
|
780
|
+
const byIndex = factorRatings[`__index_${index}`];
|
|
781
|
+
if (byId !== undefined || byName !== undefined || byIndex !== undefined) {
|
|
782
|
+
userFilled.add(key);
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
this.userFilledFactorKeys[productId] = userFilled;
|
|
786
|
+
}
|
|
787
|
+
shouldAutofillFactors(mainRating) {
|
|
788
|
+
return mainRating === 4 || mainRating === 5;
|
|
789
|
+
}
|
|
790
|
+
autofillUnfilledFactors(productId, mainRating) {
|
|
791
|
+
const factors = this.productReviewFactors[productId] || [];
|
|
792
|
+
if (!factors.length) {
|
|
793
|
+
return;
|
|
794
|
+
}
|
|
795
|
+
const userFilled = this.userFilledFactorKeys[productId] || new Set();
|
|
796
|
+
const currentRatings = { ...this.getFactorRatingsForProduct(productId) };
|
|
797
|
+
const shouldAutofill = this.shouldAutofillFactors(mainRating);
|
|
798
|
+
let updated = false;
|
|
799
|
+
factors.forEach((factor, index) => {
|
|
800
|
+
const key = this.getFactorKey(factor, index);
|
|
801
|
+
if (userFilled.has(key)) {
|
|
802
|
+
return;
|
|
803
|
+
}
|
|
804
|
+
if (shouldAutofill) {
|
|
805
|
+
if (factor.id !== undefined) {
|
|
806
|
+
currentRatings[String(factor.id)] = mainRating;
|
|
807
|
+
}
|
|
808
|
+
if (factor.name) {
|
|
809
|
+
currentRatings[factor.name.trim()] = mainRating;
|
|
810
|
+
}
|
|
811
|
+
currentRatings[`__index_${index}`] = mainRating;
|
|
812
|
+
updated = true;
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (factor.id !== undefined && currentRatings[String(factor.id)] !== undefined) {
|
|
816
|
+
delete currentRatings[String(factor.id)];
|
|
817
|
+
updated = true;
|
|
818
|
+
}
|
|
819
|
+
if (factor.name && currentRatings[factor.name.trim()] !== undefined) {
|
|
820
|
+
delete currentRatings[factor.name.trim()];
|
|
821
|
+
updated = true;
|
|
822
|
+
}
|
|
823
|
+
if (currentRatings[`__index_${index}`] !== undefined) {
|
|
824
|
+
delete currentRatings[`__index_${index}`];
|
|
825
|
+
updated = true;
|
|
826
|
+
}
|
|
827
|
+
});
|
|
828
|
+
if (updated) {
|
|
829
|
+
this.setFactorRatingsForProduct(productId, currentRatings);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
handleMainRatingChange(productId, rating) {
|
|
833
|
+
if (this.editMode) {
|
|
834
|
+
this.editMainRating = rating;
|
|
835
|
+
}
|
|
836
|
+
else {
|
|
837
|
+
this.productMainRatings = { ...this.productMainRatings, [productId]: rating };
|
|
838
|
+
}
|
|
839
|
+
this.autofillUnfilledFactors(productId, rating);
|
|
840
|
+
}
|
|
841
|
+
handleFactorRatingChange(productId, factorKey, rating) {
|
|
842
|
+
if (!this.userFilledFactorKeys[productId]) {
|
|
843
|
+
this.userFilledFactorKeys[productId] = new Set();
|
|
844
|
+
}
|
|
845
|
+
this.userFilledFactorKeys[productId].add(factorKey);
|
|
846
|
+
const factors = this.productReviewFactors[productId] || [];
|
|
847
|
+
const factorIndex = factors.findIndex((factor, index) => this.getFactorKey(factor, index) === factorKey);
|
|
848
|
+
if (factorIndex < 0) {
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
const factor = factors[factorIndex];
|
|
852
|
+
const currentRatings = { ...this.getFactorRatingsForProduct(productId) };
|
|
853
|
+
if (factor.id !== undefined) {
|
|
854
|
+
currentRatings[String(factor.id)] = rating;
|
|
855
|
+
}
|
|
856
|
+
if (factor.name) {
|
|
857
|
+
currentRatings[factor.name.trim()] = rating;
|
|
858
|
+
}
|
|
859
|
+
currentRatings[`__index_${factorIndex}`] = rating;
|
|
860
|
+
this.setFactorRatingsForProduct(productId, currentRatings);
|
|
861
|
+
}
|
|
862
|
+
setupProductRatingAutofill(container, productId) {
|
|
863
|
+
if (!container || this.boundRatingRows.has(container)) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
this.boundRatingRows.add(container);
|
|
867
|
+
container.addEventListener('click', event => {
|
|
868
|
+
const target = event.target;
|
|
869
|
+
if (!target.closest('.s-rating-stars-btn-star')) {
|
|
870
|
+
return;
|
|
871
|
+
}
|
|
872
|
+
const mainRow = target.closest('.s-rating-modal-product-rating-row-main');
|
|
873
|
+
const factorRow = target.closest('.s-rating-modal-product-factor-row');
|
|
874
|
+
requestAnimationFrame(() => {
|
|
875
|
+
if (mainRow && container.contains(mainRow)) {
|
|
876
|
+
const rating = Number(this.getRatingHiddenInput(mainRow)?.value);
|
|
877
|
+
if (rating > 0) {
|
|
878
|
+
this.handleMainRatingChange(productId, rating);
|
|
879
|
+
}
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
if (factorRow && container.contains(factorRow)) {
|
|
883
|
+
const factorKey = factorRow.getAttribute('data-factor-key');
|
|
884
|
+
const rating = Number(this.getRatingHiddenInput(factorRow)?.value);
|
|
885
|
+
if (factorKey && rating > 0) {
|
|
886
|
+
this.handleFactorRatingChange(productId, factorKey, rating);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
buildEditFactorRatings(productId) {
|
|
893
|
+
const factorReviews = this.getEditFactorReviewsList(productId);
|
|
894
|
+
return factorReviews.reduce((acc, factor, index) => {
|
|
895
|
+
const rating = Number(factor?.rating ?? factor?.stars ?? factor?.value);
|
|
896
|
+
if (Number.isNaN(rating)) {
|
|
897
|
+
return acc;
|
|
898
|
+
}
|
|
899
|
+
const factorId = factor?.id ?? factor?.factor_id;
|
|
900
|
+
if (factorId !== undefined && factorId !== null && factorId !== '') {
|
|
901
|
+
acc[String(factorId)] = rating;
|
|
902
|
+
}
|
|
903
|
+
if (factor?.name) {
|
|
904
|
+
acc[factor.name.trim()] = rating;
|
|
905
|
+
}
|
|
906
|
+
acc[`__index_${index}`] = rating;
|
|
907
|
+
return acc;
|
|
908
|
+
}, {});
|
|
909
|
+
}
|
|
910
|
+
renderProductStep(item, index) {
|
|
911
|
+
return (h("section", { class: "s-rating-modal-step s-rating-modal-hidden", "data-type": "products", "data-product-id": item.product.id, key: item.product.id }, h("div", { class: "s-rating-modal-product" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars') }, h("div", { class: "s-rating-modal-product-details" }, h("div", { class: "s-rating-modal-product-info-row" }, h("div", { class: "s-rating-modal-product-img-wrap" }, h("img", { src: item.product.thumbnail, alt: item.product.name, class: "s-rating-modal-product-img" })), h("h3", { class: "s-rating-modal-product-title" }, item.product.name)), this.renderProductReviewFactors(item.product.id, 0, { fieldPrefix: '' }), h("input", { type: "hidden", name: "product_id", value: item.product.id }), h("textarea", { placeholder: salla.lang.get('pages.rating.write_product_rate'), name: "comment", class: "s-rating-modal-comment" }), h("small", { class: "s-rating-modal-validation-msg" }))), this.allowAttachImages && (h("div", { class: "s-rating-modal-uploader is-opened", ref: el => (this.contentRefs[index] = el) }, h("salla-file-upload", { name: "image", maxFilesCount: this.MAX_UPLOAD_LIMIT, imagePreviewHeight: 117, "instant-upload": true, type: "feedback", payloadName: "files[]", id: `file-${item.product.id}`, title: item.product.name, allowMultiple: true, instantUpload: true, accept: "image/png, image/jpeg, image/jpg", url: salla.url.api('upload'), onUploaded: e => {
|
|
912
|
+
this.productImages = {
|
|
913
|
+
...this.productImages,
|
|
914
|
+
[item.product.id]: [...(this.productImages[item.product.id] || []), e.detail],
|
|
915
|
+
};
|
|
916
|
+
this.hiddenInputs[index].value = this.productImages[item.product.id]
|
|
917
|
+
.map(img => img.url)
|
|
918
|
+
.join(',');
|
|
919
|
+
}, onRemoved: e => {
|
|
920
|
+
const removedId = e.detail;
|
|
921
|
+
if (!removedId || !this.productImages[item.product.id])
|
|
922
|
+
return;
|
|
923
|
+
this.productImages = {
|
|
924
|
+
...this.productImages,
|
|
925
|
+
[item.product.id]: this.productImages[item.product.id].filter(img => img.id !== removedId),
|
|
926
|
+
};
|
|
927
|
+
this.hiddenInputs[index].value = this.productImages[item.product.id]
|
|
928
|
+
.map(img => img.url)
|
|
929
|
+
.join(',');
|
|
930
|
+
}, labelIdle: this.getFilepondPlaceholder() }), h("input", { type: "hidden", name: "images", value: (this.productImages[item.product.id] || []).map(img => img.url).join(','), ref: el => (this.hiddenInputs[index] = el) }), this.renderUploadedImagesCount(item.product.id))))));
|
|
931
|
+
}
|
|
932
|
+
renderProductReviewFactors(productId, index, options = {}) {
|
|
933
|
+
const factors = this.productReviewFactors[productId] || [];
|
|
934
|
+
const fieldPrefix = options.fieldPrefix ?? `products[${index}]`;
|
|
935
|
+
const mainRatingName = fieldPrefix ? `${fieldPrefix}[rating]` : 'rating';
|
|
936
|
+
const factorRatings = {
|
|
937
|
+
...(this.editMode ? {} : this.productFactorRatings[productId] || {}),
|
|
938
|
+
...(options.factorRatings || {}),
|
|
939
|
+
};
|
|
940
|
+
const normalizedMainRating = Number(options.mainRating ??
|
|
941
|
+
(this.editMode ? this.editMainRating : this.productMainRatings[productId]));
|
|
942
|
+
const hasMainRating = !Number.isNaN(normalizedMainRating);
|
|
943
|
+
const getPrefilledFactorRating = (factor, factorIndex) => {
|
|
944
|
+
const byId = factor.id !== undefined ? factorRatings[String(factor.id)] : undefined;
|
|
945
|
+
const byName = factor.name ? factorRatings[factor.name.trim()] : undefined;
|
|
946
|
+
const byIndex = factorRatings[`__index_${factorIndex}`];
|
|
947
|
+
const normalized = Number(byId ?? byName ?? byIndex);
|
|
948
|
+
return Number.isNaN(normalized) ? undefined : normalized;
|
|
949
|
+
};
|
|
950
|
+
return (h("div", { class: "s-rating-modal-product-rating-rows", ref: el => this.setupProductRatingAutofill(el, productId) }, h("div", { class: "s-rating-modal-product-rating-row s-rating-modal-product-rating-row-main" }, h("span", { class: "s-rating-modal-product-factor-name" }, this.overallProductRatingLabel, h("span", { class: "s-rating-modal-product-factor-required" }, "*")), h("salla-rating-stars", { size: "medium", name: mainRatingName, key: hasMainRating ? `main-rating-${normalizedMainRating}` : 'main-rating-empty', value: hasMainRating ? normalizedMainRating : undefined, editable: hasMainRating, withLabel: true, labelBeforeStars: true, tag: false })), factors.map((factor, factorIndex) => (h("div", { class: "s-rating-modal-product-rating-row s-rating-modal-product-factor-row px-3", "data-required": factor.required ? 'true' : 'false', "data-factor-key": this.getFactorKey(factor, factorIndex) }, h("input", { type: "hidden", name: this.getFactorFieldName(fieldPrefix, factorIndex, 'name'), value: factor.name }), !!factor.id && (h("input", { type: "hidden", name: this.getFactorFieldName(fieldPrefix, factorIndex, 'id'), value: String(factor.id) })), h("span", { class: "s-rating-modal-product-factor-name" }, factor.name, factor.required ? h("span", { class: "s-rating-modal-product-factor-required" }, "*") : ''), h("salla-rating-stars", { size: "medium", name: this.getFactorFieldName(fieldPrefix, factorIndex, 'rating'), key: `factor-rating-${factor.id ?? factorIndex}-${getPrefilledFactorRating(factor, factorIndex) ?? 0}`, value: getPrefilledFactorRating(factor, factorIndex), editable: options.alwaysEditable ||
|
|
951
|
+
typeof getPrefilledFactorRating(factor, factorIndex) === 'number', withLabel: true, labelBeforeStars: true, tag: false }))))));
|
|
952
|
+
}
|
|
953
|
+
handleSendEmail() {
|
|
954
|
+
const subject = `${this.contactSubjectLabel} #${this.order.id}`;
|
|
955
|
+
const body = this.contact_body(salla.config.get('store.name'), this.order.id, this.getCustomerName());
|
|
956
|
+
const mailtoLink = `mailto:${salla.config.get('store.contacts.email')}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
|
|
957
|
+
window.open(mailtoLink, '_blank');
|
|
958
|
+
}
|
|
959
|
+
handleSendWhatsApp() {
|
|
960
|
+
const body = this.contact_body(salla.config.get('store.name'), this.order.id, this.getCustomerName());
|
|
961
|
+
const whatsappLink = `https://wa.me/${salla.config.get('store.contacts.whatsapp')}?text=${encodeURIComponent(body)}`;
|
|
962
|
+
window.open(whatsappLink, '_blank');
|
|
963
|
+
}
|
|
964
|
+
resetData(isOpen) {
|
|
965
|
+
if (isOpen.detail) {
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
this.clearThanksCountdown();
|
|
969
|
+
this.modal?.close();
|
|
970
|
+
this.editItem = null;
|
|
971
|
+
this.editItemImages = [];
|
|
972
|
+
this.editFactorRatings = {};
|
|
973
|
+
this.productMainRatings = {};
|
|
974
|
+
this.productFactorRatings = {};
|
|
975
|
+
this.editMainRating = undefined;
|
|
976
|
+
this.userFilledFactorKeys = {};
|
|
977
|
+
this.hiddenInputs[1] && (this.hiddenInputs[1].value = '');
|
|
978
|
+
this.deleteFeedbackId = null;
|
|
979
|
+
this.editFeedbackId = null;
|
|
980
|
+
this.shouldOpenDeleteModal = false;
|
|
981
|
+
this.editMode = false;
|
|
982
|
+
this.deleteMode = false;
|
|
983
|
+
this.defaultMode = false;
|
|
984
|
+
this.currentIndex = 0;
|
|
985
|
+
this.submitted = [];
|
|
986
|
+
this.scheduleWizardSetup = false;
|
|
987
|
+
}
|
|
988
|
+
getDeleteModal() {
|
|
989
|
+
return (h("salla-modal", { ref: modal => (this.deleteModal = modal), width: "xs", onModalVisibilityChanged: isOpen => this.resetData(isOpen) }, h("div", { class: "s-rating-modal-delete-wrapper", ref: el => (this.body = el) }, h("h3", null, this.confirmDeletionLabel), h("p", null, this.areYouSureLabel), h("div", { class: "s-rating-modal-delete-actions" }, h("salla-button", { loaderPosition: "center", onClick: () => this.deleteReview() }, this.confirmDeleteBtn), h("salla-button", { color: "danger", fill: "outline", onClick: () => this.deleteModal.close() }, this.cancelLabel)))));
|
|
990
|
+
}
|
|
991
|
+
renderUploadedImagesCount(productId) {
|
|
992
|
+
// In edit mode, use editItemImages; in default mode, use productImages
|
|
993
|
+
const imageCount = this.editMode
|
|
994
|
+
? this.editItemImages.length
|
|
995
|
+
: (this.productImages[productId] || []).length;
|
|
996
|
+
return (h("span", { class: "s-rating-modal-upload-count" }, salla.lang.choice('pages.rating.images_count', imageCount, {
|
|
997
|
+
current: imageCount,
|
|
998
|
+
total: this.MAX_UPLOAD_LIMIT,
|
|
999
|
+
})));
|
|
1000
|
+
}
|
|
1001
|
+
getEditModal() {
|
|
1002
|
+
return (h("salla-modal", { ref: modal => (this.editModal = modal), width: "md", onModalVisibilityChanged: isOpen => this.resetData(isOpen) }, h("div", { class: "s-rating-modal-edit-wrapper", ref: el => (this.body = el) }, this.editType === 'store' && this.editItem ? (h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step", "data-type": "store", ref: currentTab => (this.currentTab = currentTab) }, h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: salla.config.get('store.logo', 'https://assets.salla.sa/cp/assets/images/logo-new.png'), alt: "store name", class: "s-rating-modal-store-logo" })), h("h2", { class: "s-rating-modal-title" }, salla.lang.get('pages.rating.rate_the_store')), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { withLabel: true, size: "large", editable: true, value: this.editItem.stars })), h("textarea", { name: "content", value: this.editItem.content, class: "s-rating-modal-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "s-rating-modal-validation-msg" }))) : null, this.editType === 'shipping' && this.editItem ? (h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step", "data-type": "shipping", ref: currentTab => (this.currentTab = currentTab) }, this.editItem.shipping.logo ? (h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: this.editItem.shipping.logo, class: "s-rating-modal-shipping-logo", alt: this.editItem.shipping.name }))) : (h("span", { class: "s-rating-modal-icon", innerHTML: ShippingFast })), h("div", { class: "s-rating-modal-title" }, ' ', `${salla.lang.get('pages.rating.rate_shipping')} ${this.editItem.shipping.name}`), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { withLabel: true, size: "large", editable: true, value: this.editItem.stars })), h("textarea", { name: "content", class: "s-rating-modal-comment", value: this.editItem.content, placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "s-rating-modal-validation-msg" }))) : null, this.editType == 'product' && this.editItem ? (h("section", { class: "s-rating-modal-step", "data-type": "products", ref: currentTab => (this.currentTab = currentTab) }, h("div", { class: "s-rating-modal-product" }, h("div", { class: "rating-outer-form", "data-stars-error": salla.lang.get('pages.rating.rate_product_stars') }, h("div", { class: "s-rating-modal-product-details" }, h("div", { class: "s-rating-modal-product-info-row" }, h("div", { class: "s-rating-modal-product-img-wrap" }, h("img", { src: this.editItem.product.image.url, alt: this.editItem.product.name, class: "s-rating-modal-product-img" })), h("h3", { class: "s-rating-modal-product-title" }, this.editItem.product.name)), this.renderProductReviewFactors(this.editItem.product.id, 0, {
|
|
1003
|
+
fieldPrefix: '',
|
|
1004
|
+
mainRating: this.editMainRating ?? Number(this.editItem.stars ?? this.editItem.rating),
|
|
1005
|
+
factorRatings: this.editFactorRatings,
|
|
1006
|
+
alwaysEditable: true,
|
|
1007
|
+
}), h("input", { type: "hidden", name: "product_id", value: this.editItem.product.id }), h("textarea", { value: this.editItem.content, placeholder: salla.lang.get('pages.rating.write_product_rate'), name: "comment", class: "s-rating-modal-comment" }), h("small", { class: "s-rating-modal-validation-msg" }))), this.allowAttachImages && (h("div", { class: "s-rating-modal-uploader is-opened", ref: el => (this.contentRefs[1] = el) }, h("salla-file-upload", { name: "images", allowMultiple: true, maxFilesCount: this.MAX_UPLOAD_LIMIT, imagePreviewHeight: 117, filePosterHeight: 117, "instant-upload": true, type: "feedback", files: JSON.stringify(this.editItemImages), payloadName: "files[]", id: `file-${this.editItem.product.id}`, title: this.editItem.product.name, instantUpload: true, accept: "image/png, image/jpeg, image/jpg", url: salla.url.api('upload'), onUploaded: e => {
|
|
1008
|
+
this.editItemImages = [
|
|
1009
|
+
...this.editItemImages,
|
|
1010
|
+
e.detail,
|
|
1011
|
+
];
|
|
1012
|
+
this.hiddenInputs[1].value = this.editItemImages.map(img => img.url).join();
|
|
1013
|
+
}, onRemoved: e => {
|
|
1014
|
+
const removedId = e.detail;
|
|
1015
|
+
if (!removedId)
|
|
1016
|
+
return;
|
|
1017
|
+
this.editItemImages = this.editItemImages.filter(img => img.id !== removedId);
|
|
1018
|
+
this.hiddenInputs[1].value = this.editItemImages.map(img => img.url).join();
|
|
1019
|
+
}, labelIdle: this.getFilepondPlaceholder() }), h("input", { type: "hidden", name: "images", value: this.editItemImages.map(img => img.url).join(','), ref: el => (this.hiddenInputs[1] = el) }), this.renderUploadedImagesCount(this.editItem.product.id)))))) : null, h("div", { class: "s-rating-modal-footer s-rating-modal-footer-end" }, h("salla-button", { "loader-position": "center", onClick: () => this.editReview() }, this.editReviewLabel)))));
|
|
1020
|
+
}
|
|
1021
|
+
render() {
|
|
1022
|
+
if (this.deleteMode) {
|
|
1023
|
+
return h(Host, { class: "s-rating-modal" }, this.getDeleteModal());
|
|
1024
|
+
}
|
|
1025
|
+
if (this.editMode) {
|
|
1026
|
+
return h(Host, { class: "s-rating-modal" }, this.getEditModal());
|
|
1027
|
+
}
|
|
1028
|
+
if (this.defaultMode) {
|
|
1029
|
+
return (h(Host, { class: "s-rating-modal" }, h("salla-modal", { class: "s-rating-modal-wrap", onModalVisibilityChanged: isOpen => this.resetData(isOpen), isLoading: true, width: "md", ref: modal => (this.modal = modal) }, h("div", { slot: "loading" }, h("div", { class: "s-rating-modal-skeleton" }, h("salla-skeleton", { type: "circle", height: "80px", width: "80px" }), h("salla-skeleton", { height: "15px", width: "60%" }), h("salla-skeleton", { height: "10px", width: "30%" }), h("div", { class: "s-rating-modal-skeleton-stars" }, [...Array(5)].map(v => (h("div", { key: v, innerHTML: Star })))), h("salla-skeleton", { height: "100px", width: "100%" }), h("div", { class: "s-rating-modal-skeleton-footer" }, h("salla-skeleton", { height: "40px", width: "30%" })))), !this.hasError && this.order ? ([
|
|
1030
|
+
h("div", { class: "s-rating-modal-wrapper", ref: el => (this.body = el) }, this.isTestimonialsEnabled() ? (h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "store" }, h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: salla.config.get('store.logo', 'https://assets.salla.sa/cp/assets/images/logo-new.png'), alt: "store name", class: "s-rating-modal-store-logo" })), h("h2", { class: "s-rating-modal-title" }, salla.lang.get('pages.rating.rate_the_store')), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { withLabel: true, size: "large" })), h("textarea", { name: "comment", class: "s-rating-modal-comment", placeholder: salla.lang.get('pages.rating.write_store_rate') }), h("small", { class: "s-rating-modal-validation-msg" }))) : (''), this.isProductsEnabled() &&
|
|
1031
|
+
this.getRateableProducts().map((item, index) => this.renderProductStep(item, index)), this.isShippingEnabled() && this.order.shipping?.company ? (h("div", { class: "rating-outer-form s-rating-modal-step-wrap s-rating-modal-step s-rating-modal-hidden", "data-type": "shipping" }, h("input", { type: "hidden", name: "shipping_company_id", value: this.order.shipping.company.id }), this.order.shipping.company.logo ? (h("div", { class: "s-rating-modal-rounded-icon" }, h("img", { src: this.order.shipping.company.logo, class: "s-rating-modal-shipping-logo", alt: this.order.shipping.company.name }))) : (h("span", { class: "s-rating-modal-icon", innerHTML: ShippingFast })), h("div", { class: "s-rating-modal-title" }, ' ', `${salla.lang.get('pages.rating.rate_shipping')} ${this.order.shipping.company.name}`), h("div", { class: "s-rating-modal-stars-company" }, h("salla-rating-stars", { withLabel: true, size: "large" })), h("textarea", { name: "comment", class: "s-rating-modal-comment", placeholder: salla.lang.get('pages.rating.write_shipping_rate') }), h("small", { class: "s-rating-modal-validation-msg" }))) : (''), h("div", { class: "s-rating-modal-thanks s-rating-modal-hidden", ref: el => (this.thanksTab = el) }, h("span", { class: "s-rating-modal-icon", innerHTML: CheckCircle2 }), h("h3", { class: "s-rating-modal-thanks-title" }, salla.lang.get('pages.rating.thanks')), h("div", { class: "s-rating-modal-thanks-msg", innerHTML: this.order.thanks_message }), h("time", { class: "s-rating-modal-thanks-time", ref: el => (this.thanksTime = el) }))),
|
|
1032
|
+
this.allowContactSupport &&
|
|
1033
|
+
this.showContactWidget &&
|
|
1034
|
+
(salla.config.get('store.contacts.whatsapp') ||
|
|
1035
|
+
salla.config.get('store.contacts.email')) ? (h("div", { class: "s-rating-modal-contact" }, h("p", null, this.contactUsLabel), h("div", { class: "s-rating-modal-contact-icons" }, salla.config.get('store.contacts.whatsapp') && (h("span", { onClick: () => this.handleSendWhatsApp(), innerHTML: WhatsappIcon })), salla.config.get('store.contacts.email') && (h("span", { onClick: () => this.handleSendEmail(), innerHTML: email }))))) : (''),
|
|
1036
|
+
h("div", { class: "s-rating-modal-footer" }, h("button", { ref: el => (this.backBtn = el), onClick: () => this.previousTab(), class: "s-rating-modal-btn s-rating-modal-unvisiable" }, salla.lang.get('common.elements.back')), this.stepsCount > 1 ? (h("ul", { class: "s-rating-modal-dots" }, [...Array(this.stepsCount)].map((_, v) => (h("li", { key: v, class: "s-rating-modal-bg-gray s-rating-modal-step-dot" }))))) : (''), h("salla-button", { "loader-position": "center", ref: el => (this.nextBtn = el), onClick: () => this.submit() }, salla.lang.get('common.elements.next'))),
|
|
1037
|
+
]) : (h("salla-placeholder", { alignment: "center" })))));
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
async componentWillLoad() {
|
|
1041
|
+
await salla.onReady();
|
|
1042
|
+
this.syncStoreSettings();
|
|
1043
|
+
}
|
|
1044
|
+
componentDidRender() {
|
|
1045
|
+
if (!this.scheduleWizardSetup || !this.defaultMode || !this.order) {
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
this.scheduleWizardSetup = false;
|
|
1049
|
+
requestAnimationFrame(() => this.handleWizard());
|
|
1050
|
+
}
|
|
1051
|
+
disconnectedCallback() {
|
|
1052
|
+
this.clearThanksCountdown();
|
|
1053
|
+
}
|
|
1054
|
+
get host() { return getElement(this); }
|
|
1055
|
+
};
|
|
1056
|
+
SallaRatingModalV2.style = sallaRatingModalCss;
|
|
1057
|
+
|
|
1058
|
+
export { SallaRatingModalV2 as salla_rating_modal_v2 };
|