"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5514],{15514:function(e,t,n){n.r(t),n.d(t,{default:function(){return w}});var u=n(81862),r=n(5163),l=n(52322),i=n(63756),a=n(98317),c=n(2784),o=n(80843),s=n(90379),d=n(89290),h=n(8226),v=n(85481),f=n(87766),p=n(18588),x=n(54137),y=n(88739),b=n(85333),g=n(6692),m=n(39875),k=n(441),_=n(32032),j=function(e){var t,n=e.values,i=e.changeValues,a=n.find(function(t){return t.value===e.value}),c=(t=(0,u._)(function(){var e,t,u;return(0,r.__generator)(this,function(r){switch(r.label){case 0:return[4,null===(e=(0,k.H)())||void 0===e?void 0:e.getPhoto()];case 1:return(t=r.sent())&&((u=(0,h._)(null!=n?n:[]).map(function(e){return(0,b._)({},e)})).forEach(function(e,n){e===a&&(u[n].icon=t)}),i(u)),[2]}})}),function(){return t.apply(this,arguments)});return(0,l.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,l.jsx)(_.o,{style:{marginRight:"15px"},defaultValue:e.value,onChange:function(e){i((0,h._)(null!=n?n:[]).map(function(t){return t===a?(0,g._)((0,b._)({},t),{value:e.target.value}):t}))},baseSize:"small"}),(0,l.jsx)(p.Z,{title:"Change icon",children:(0,l.jsx)(x.h,{onClick:c,children:a.icon?(0,l.jsx)("div",{style:{width:"20px",height:"20px",background:'url("'.concat(a.icon,'") center center no-repeat'),backgroundSize:"contain"}}):(0,l.jsx)(m.Z,{className:"w-4 h-4"})})}),(0,l.jsx)(p.Z,{title:"Delete value",children:(0,l.jsx)(x.h,{onClick:function(){i((0,h._)(null!=n?n:[]).filter(function(e){return e.value!==a.value}))},children:(0,l.jsx)(f.Z,{className:"w-4 h-4"})})})]})},C=function(e){var t,n=e.values,i=void 0===n?[]:n,a=e.changeValues,o=(0,d._)((0,c.useState)([]),2),s=o[0],b=o[1],g=(t=(0,u._)(function(){return(0,r.__generator)(this,function(e){return a(i.filter(function(e){return!s.includes(e.value)})),b([]),[2]})}),function(){return t.apply(this,arguments)});return(0,l.jsx)(y.S,{title:"Values",items:i.map(function(e){return e.value}),checked:s,setChecked:function(e){b(e)},fullWidthToggle:!1,actions:(0,l.jsxs)("div",{style:{marginLeft:"30px",display:"flex"},children:[(0,l.jsx)(p.Z,{title:"Add new value",children:(0,l.jsx)(x.h,{onClick:function(){var e=(0,h._)(null!=i?i:[]);e.push({value:""}),a(e)},children:(0,l.jsx)(v.Z,{className:"w-5 h-5"})})}),(0,l.jsx)(p.Z,{title:"Remove checked values",children:(0,l.jsx)(x.h,{onClick:g,disabled:!(null==s?void 0:s.length),children:(0,l.jsx)(f.Z,{className:"w-5 h-5"})})})]}),itemComp:j,itemProps:{changeValues:a,values:i}})};function w(){var e,t=(0,a.getGraphQLClient)(),n=c.useRef(),d=c.useRef(!0),h=(0,a.useForceUpdate)();return(0,l.jsx)(o.Z,{entityCategory:i.EDBEntity.Attribute,entityListRoute:s.Cz.route,entityBaseRoute:s.HT.baseRoute,listLabel:"Attributes",entityLabel:"Attribute",getById:t.getAttributeById,update:t.updateAttribute,create:t.createAttribute,deleteOne:t.deleteAttribute,onSave:(e=(0,u._)(function(e){return(0,r.__generator)(this,function(t){return"text_input"===e.type&&(e.values=[{value:"text_input"}]),[2,e]})}),function(t){return e.apply(this,arguments)}),fields:[{key:"key",type:"Simple text",label:"Key",required:!0},{key:"title",type:"Simple text",label:"Title"},{key:"icon",type:"Image",label:"Icon"},{key:"type",type:"Select",label:"Attribute type",width:{sm:6},options:[{value:"radio",label:"Radio"},{value:"checkbox",label:"Checkbox"},{value:"text_input",label:"Text input"}],getInitialValue:function(e){return n.current||(n.current=e||"radio","text_input"===e?d.current=!1:d.current=!0,h()),e||"radio"},onChange:function(e){return"text_input"===e?d.current=!1:d.current=!0,h(),e},saveValue:function(e){return{type:e||"radio"}}},{key:"values",type:"custom",component:function(e){var t=e.value,n=e.onChange;return d.current?(0,l.jsx)(C,{values:t,changeValues:n}):(0,l.jsx)(l.Fragment,{})},customGraphQlProperty:{values:{value:!0,icon:!0}},saveValue:function(e){var t={};return null==e||e.forEach(function(e){t[e.value]||(t[e.value]={value:e.value,title:e.title,icon:e.icon})}),{values:Object.values(t)}}},{key:"required",type:"Checkbox",tooltip:"A customer will be required to pick a value of this attribute to add a product to the cart",label:"Required to fill",saveValue:function(e){return{required:!!e}}}]})}},85481:function(e,t,n){var u=n(2784);let r=u.forwardRef(function({title:e,titleId:t,...n},r){return u.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",ref:r,"aria-labelledby":t},n),e?u.createElement("title",{id:t},e):null,u.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"}))});t.Z=r}}]);