PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.7.0
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.7.0
1.7.0 1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 All 50 releases
fluent-cart / assets / chunks / reviewBlockShared.js

reviewBlockShared.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.7.0, at assets/chunks/reviewBlockShared.js

2 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as e}from"./jsx-runtime.js?ver=1.7.0";import{E as S}from"./EditorPanel.js?ver=1.7.0";import{E as _}from"./EditorPanelRow.js?ver=1.7.0";import{S as C}from"./SelectProductModal.js?ver=1.7.0";import{b as i}from"./BlockEditorTranslator.js?ver=1.7.0";import{a as g}from"./index6.js?ver=1.7.0";import{u as N}from"./SingleProductContext.js?ver=1.7.0";import{a as k}from"./add-query-args.js?ver=1.7.0";const{__experimentalToggleGroupControl:E,__experimentalToggleGroupControlOption:v}=wp.components,O=({attributes:t,setAttributes:l,selectedProduct:o,setSelectedProduct:c})=>e.jsxs(S,{title:i("Product"),children:[e.jsx(_,{children:e.jsxs(E,{isBlock:!0,label:i("Query type"),value:t.query_type,onChange:r=>{l({query_type:r})},children:[e.jsx(v,{value:"default",label:i("Default")}),e.jsx(v,{value:"custom",label:i("Custom")})]})}),t.query_type==="custom"&&e.jsxs(_,{className:"flex-col",children:[e.jsx(C,{onSelectionConfirmed:r=>{l({product_id:r!=null&&r.ID?String(r.ID):""})},selectedProduct:o,setSelectedProduct:c,isMultiple:!1}),(o==null?void 0:o.post_title)&&e.jsxs("div",{className:"fct-selected-products",children:[e.jsx("span",{className:"fct-selected-products__label",children:i("Selected Product")}),e.jsx("div",{className:"fct-selected-products__list",children:e.jsx("div",{className:"fct-product-chip-group",children:e.jsx("span",{className:"fct-product-chip fct-product-chip--parent",children:o.post_title})})})]})]})]}),{useEffect:w,useState:x}=wp.element,{useSelect:R}=wp.data,{store:D}=wp.blockEditor;var y;const n=((y=window.fluentCartRestVars)==null?void 0:y.rest)||{},Q=t=>R(l=>{const{getBlockParents:o,getBlockName:c}=l(D),r=["fluent-cart/product-reviews","fluent-cart/product-review-summary-group","fluent-cart/product-info","fluent-cart/products","fluent-cart/shopapp-product-container","fluent-cart/shopapp-product-loop","fluent-cart/product-carousel","fluent-cart/product-carousel-loop","fluent-cart/related-product","fluent-cart/product-template"];return o(t).some(a=>r.includes(c(a)))},[t]),W=(t,l,o=!1)=>{const c=N(),[r,a]=x({}),[j,f]=x(null),s=(c==null?void 0:c.product)||null,m=!l&&t.query_type==="custom",d=l?(s==null?void 0:s.ID)||"":m?t.product_id:(s==null?void 0:s.ID)||"";return w(()=>{let u=!1;const p=()=>u;return m?t.product_id&&n.url?g({path:k(n.url+"/products/"+t.product_id,{with:["block_product_detail"]}),headers:{"X-WP-Nonce":n.nonce}}).then(h=>{p()||a(h.product||{})}).catch(()=>{p()||a({})}):a({}):a(s||{}),()=>{u=!0}},[s,m,t.product_id]),w(()=>{let u=!1;const p=()=>u;return o&&d&&n.url?g({path:n.url+"/public/reviews/"+d+"/summary",headers:{"X-WP-Nonce":n.nonce}}).then(h=>{p()||f(h.summary||null)}).catch(()=>{p()||f(null)}):f(null),()=>{u=!0}},[o,d]),{selectedProduct:r,setSelectedProduct:a,reviewSummary:j,effectiveProductId:d}};export{O as R,W as a,Q as u};
2