"use strict";(self.webpackChunk_cromwell_admin_panel=self.webpackChunk_cromwell_admin_panel||[]).push([[318],{51498:(e,a,t)=>{t.d(a,{Z:()=>i});var r=t(82609),l=t.n(r)()((function(e){return e[1]}));l.push([e.id,'.text_MLN5k{font-family:"Roboto","sans-serif"}.center__Hju9{display:flex;align-items:center;justify-content:center}.paper_DX_yH{box-shadow:0 2px 3px 0 rgba(0,0,0,.05),0 0 11px 5px rgba(0,0,0,.05);background-color:#fff;border-radius:5px}.page_jPuxg{display:flex;flex-direction:column;height:100%}.pageHeader_GnZna{display:inline-block}.pageContent_rWRO_{display:inline-block;height:100%;overflow:auto}.pageTitle_oBigZ{display:flex;align-items:center;font-weight:500}.pageTitle_oBigZ::before{content:"";width:5px;height:5px;background-color:#333;margin-right:8px;display:block;border-radius:100%}.modeDark .pageTitle_oBigZ::before{background-color:#eee}.TagPage_ps1hx{padding:20px;max-width:900px;margin:0 auto;width:100%}.header_duS0_{box-shadow:0 2px 3px 0 rgba(0,0,0,.05),0 0 11px 5px rgba(0,0,0,.05);background-color:#fff;border-radius:5px;padding:5px 10px 5px 0;width:100%;margin-bottom:15px;display:flex;justify-content:space-between;align-items:center}.headerLeft_ByrnD{display:flex;align-items:center}.fields_NrUah{box-shadow:0 2px 3px 0 rgba(0,0,0,.05),0 0 11px 5px rgba(0,0,0,.05);background-color:#fff;border-radius:5px;padding:20px;margin-bottom:15px}.textField_BgYeL,.imageField_OC_aY{margin-bottom:15px}.descriptionEditor_z9TG_{border:1px solid #bbb;border-radius:5px;max-height:400px;overflow:auto;padding:15px 40px}.descriptionEditor_z9TG_::-webkit-scrollbar{width:.5em;height:.5em}.descriptionEditor_z9TG_::-webkit-scrollbar-track{border-radius:30px;background-color:rgba(0,0,0,.1)}.descriptionEditor_z9TG_::-webkit-scrollbar-thumb{background-color:#888;outline:none;border-radius:30px}.descriptionEditor_z9TG_::-webkit-scrollbar-thumb:hover{background-color:#666}.descriptionEditor_z9TG_::-webkit-scrollbar-thumb:active{background-color:#444}.modeDark .header_duS0_,.modeDark .fields_NrUah{background-color:#333}.modeDark .header_duS0_ *,.modeDark .fields_NrUah *{color:#eee}',""]),l.locals={text:"text_MLN5k",center:"center__Hju9",paper:"paper_DX_yH",page:"page_jPuxg",pageHeader:"pageHeader_GnZna",pageContent:"pageContent_rWRO_",pageTitle:"pageTitle_oBigZ",TagPage:"TagPage_ps1hx",header:"header_duS0_",headerLeft:"headerLeft_ByrnD",fields:"fields_NrUah",textField:"textField_BgYeL",imageField:"imageField_OC_aY",descriptionEditor:"descriptionEditor_z9TG_"};const i=l},80033:(e,a,t)=>{t.r(a),t.d(a,{default:()=>M});var r=t(65040),l=t(63756),i=t(49352),n=t(20355),o=t(58568),d=t(87037),s=t(23883),c=t(38677),g=t(31117),m=t(63735),p=t(53242),u=t(92768),b=t(2784),x=t(63884),h=t(75465),_=t(68109),v=t(86661),f=t(7736),E=t(45795),y=t(59691),w=t(14812),k=t(84073),T=t(46062),Z=t.n(T),N=t(44036),P=t.n(N),D=t(96793),C=t.n(D),F=t(9978),S=t.n(F),B=t(11173),z=t.n(B),O=t(42464),L=t.n(O),A=t(51498),G={attributes:{"data-meta":"crw-admin-style"}};G.styleTagTransform=L(),G.setAttributes=S(),G.insert=C().bind(null,"head"),G.domAPI=P(),G.insertStyleElement=z(),Z()(A.Z,G);const H=A.Z&&A.Z.locals?A.Z.locals:void 0,M=()=>{var e,a,t,T;const{id:Z}=(0,x.UO)(),N=(0,i.getGraphQLClient)(),[P,D]=(0,b.useState)(null),[C,F]=(0,b.useState)(!1),[S,B]=(0,b.useState)(!1),[z,O]=(0,b.useState)(!1),L=(0,x.k6)(),[A,G]=(0,b.useState)(!1),M="tag-description-editor",R=async e=>{let a;try{a=await N.getTagById(e,r.gql`
                    fragment AdminPanelTagFragment on Tag {
                        id
                        slug
                        createDate
                        updateDate
                        pageTitle
                        pageDescription
                        meta {
                            keywords
                        }
                        isEnabled
                        name
                        color
                        image
                        description
                        descriptionDelta
                        customMeta (keys: ${JSON.stringify((0,E.He)(l.EDBEntity.Tag))})
                    }`,"AdminPanelTagFragment"),a&&D(a)}catch(e){console.error(e)}return a||F(!0),a};(0,b.useEffect)((()=>{(async()=>{let e={};if(O(!0),Z&&"new"!==Z){const a=await R(parseInt(Z));try{(null==a?void 0:a.descriptionDelta)&&(e=JSON.parse(null==a?void 0:a.descriptionDelta))}catch(e){console.error(e)}}"new"===Z&&D({}),O(!1),await(0,y.V$)({htmlId:M,data:e,placeholder:"Tag description..."})})()}),[]);const j=e=>e&&""!==e,I=(e,a)=>{P&&D((t=>{const r=Object.assign({},t);return r[e]=a,r}))};if(C)return b.createElement("div",{className:H.TagPage},b.createElement("div",{className:H.notFoundPage},b.createElement("p",{className:H.notFoundText},"Tag not found")));let U;return P&&(U=l.serviceLocator.getFrontendUrl()+(0,l.resolvePageRoute)("tag",{slug:null!==(e=P.slug)&&void 0!==e?e:P.id+""})),b.createElement("div",{className:H.TagPage},b.createElement("div",{className:H.header},b.createElement("div",{className:H.headerLeft},b.createElement(d.Z,{onClick:()=>window.history.back()},b.createElement(n.Z,{style:{fontSize:"18px"}})),b.createElement("p",{className:k.Z.pageTitle},"tag")),b.createElement("div",{className:H.headerActions},U&&b.createElement(s.Z,{title:"Open tag in the new tab"},b.createElement(d.Z,{style:{marginRight:"10px"},className:H.openPageBtn,"aria-label":"open",onClick:()=>{window.open(U,"_blank")}},b.createElement(o.Z,null))),b.createElement(c.Z,{variant:"contained",color:"primary",className:H.saveBtn,size:"small",disabled:S,onClick:async()=>{if(G(!0),!j(null==P?void 0:P.name))return;B(!0);const e={slug:P.slug,pageTitle:P.pageTitle,pageDescription:P.pageDescription,meta:P.meta&&{keywords:P.meta.keywords},name:P.name,color:P.color,image:P.image,isEnabled:P.isEnabled,description:await(0,y.eZ)(M),descriptionDelta:JSON.stringify(await(0,y.Hd)(M)),customMeta:Object.assign({},P.customMeta,await(0,E.Q7)(l.EDBEntity.Tag))};if("new"===Z)try{const a=await(null==N?void 0:N.createTag(e));v.A.success("Created tag!"),L.replace(`${f.O_.baseRoute}/${a.id}`),await R(a.id)}catch(e){v.A.error("Failed to create tag"),(0,w.z)(e),console.error(e)}else try{await(null==N?void 0:N.updateTag(P.id,e)),await R(P.id),v.A.success("Saved!")}catch(e){v.A.error("Failed to save"),(0,w.z)(e),console.error(e)}B(!1),G(!1)}},"Save"))),b.createElement("div",{className:H.fields},z&&Array(8).fill(1).map(((e,a)=>b.createElement(g.Z,{style:{marginBottom:"10px"},key:a,height:"50px"}))),!z&&b.createElement(m.ZP,{container:!0,spacing:3},b.createElement(m.ZP,{item:!0,xs:12,sm:6},b.createElement(p.Z,{label:"Name",value:(null==P?void 0:P.name)||"",fullWidth:!0,variant:"standard",className:H.textField,onChange:e=>{I("name",e.target.value)},error:A&&!j(null==P?void 0:P.name)})),b.createElement(m.ZP,{item:!0,xs:12,sm:6},b.createElement(h.z,{className:H.textField,label:"Color",value:null!==(a=null==P?void 0:P.color)&&void 0!==a?a:"#fff",onChange:e=>I("color",e)})),b.createElement(m.ZP,{item:!0,xs:12,sm:12},b.createElement(p.Z,{label:"Page URL",className:H.textField,fullWidth:!0,variant:"standard",value:(null==P?void 0:P.slug)||"",helperText:U,onChange:e=>{I("slug",e.target.value)}})),b.createElement(m.ZP,{item:!0,xs:12,sm:12},b.createElement(_.u,{label:"Image",className:H.imageField,onChange:e=>I("image",e),value:null==P?void 0:P.image,backgroundSize:"cover",showRemove:!0})),b.createElement(m.ZP,{item:!0,xs:12},b.createElement("div",{className:H.descriptionEditor},b.createElement("div",{style:{minHeight:"300px"},id:M}))),b.createElement(m.ZP,{item:!0,xs:12},b.createElement(p.Z,{label:"Meta title",className:H.textField,fullWidth:!0,variant:"standard",value:(null==P?void 0:P.pageTitle)||"",onChange:e=>{I("pageTitle",e.target.value)}})),b.createElement(m.ZP,{item:!0,xs:12},b.createElement(p.Z,{label:"Meta description",className:H.textField,fullWidth:!0,variant:"standard",value:(null==P?void 0:P.pageDescription)||"",onChange:e=>{I("pageDescription",e.target.value)}})),b.createElement(m.ZP,{item:!0,xs:12},b.createElement(u.Z,{multiple:!0,freeSolo:!0,options:[],className:H.textField,value:null!==(T=null===(t=null==P?void 0:P.meta)||void 0===t?void 0:t.keywords)&&void 0!==T?T:[],getOptionLabel:e=>e,onChange:(e,a)=>{var t;I("meta",{...null!==(t=P.meta)&&void 0!==t?t:{},keywords:a})},renderInput:e=>b.createElement(s.Z,{title:"Press ENTER to add"},b.createElement(p.Z,{...e,variant:"standard",label:"Meta keywords"}))})),b.createElement(m.ZP,{item:!0,xs:12},P&&b.createElement(E._i,{entityType:l.EDBEntity.Tag,entityData:P,refetchMeta:async()=>{if(!Z)return;const e=await R(parseInt(Z));return null==e?void 0:e.customMeta}})))))}}}]);