1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6082],{41507:function(e,l,i){i.d(l,{w:function(){return EditMantelpieceForm}});var n=i(85893),a=i(35152),o=i(4423),t=i(26784),r=i(32208),d=i(71987),s=i(90473),c=i(92879),u=i(93717),m=i(66529),p=i(18020),x=i(71293),v=i(93108),h=i(73935),j=i(87536),g=i(17527),b=i(52646),f=i(17393),Q=i(46162),k=i(57129),C=i(62874),I=i(31915),y=i(94720),R=i(56312),U=i(68929),M=i.n(U),D=i(67294);let useEditMantelpiece=e=>{let{mantelpiece:l,onAfterSubmit:i}=e,{t:n}=(0,g.$G)(),{handleMutationError:a}=(0,b._)(),o=(0,k.U)(),t=(0,f.Ay)(),r=(0,y.p)(),{mutate:d}=(0,f.EH)(),s=(0,I.E)(n),c=(0,D.useMemo)(()=>(null==l?void 0:l.cardId)!=null,[null==l?void 0:l.cardId]),u=(0,D.useMemo)(()=>c?Q.eC:Q.UP,[c]),m=(0,D.useMemo)(()=>({descriptionJson:null==l?void 0:l.descriptionJson,media:l.imageUrl?{mediaUrl:l.imageUrl,uploadId:l.mantelpieceImageId}:null,mantelpieceRelation:l.mantelpieceRelation}),[l]),p=(0,D.useMemo)(()=>Object.keys(C.C).map(e=>({value:C.C[e],label:n("mantelpiece.".concat(M()(null==e?void 0:e.toLocaleLowerCase()),"OptionLabel"))})),[n]),{formState:{isSubmitting:x,isValid:v,isDirty:h},handleSubmit:U,setValue:E,control:L,watch:w,reset:O}=(0,j.cI)({mode:"all",resolver:(0,R.F)(u),defaultValues:m});(0,D.useEffect)(()=>{O(m)},[m,O]);let J=w("media"),N=(0,D.useCallback)(async e=>{if(!e)return;let l={mediaUrl:URL.createObjectURL(e),loading:!0};E("media",l,{shouldValidate:!0,shouldDirty:!0}),d({file:e},{onSuccess:e=>{E("media",e,{shouldValidate:!0,shouldDirty:!0})},onError:e=>{a(e),E("media",null,{shouldValidate:!0,shouldDirty:!0})},onSettled:()=>{URL.revokeObjectURL(l.mediaUrl)}})},[d,a,E]),Z=(0,D.useCallback)(()=>{E("media",null,{shouldValidate:!0,shouldDirty:!0})},[E]),_=(0,D.useMemo)(()=>x||t.isLoading,[x,t.isLoading]),F=(0,D.useMemo)(()=>_||(null==J?void 0:J.loading)||!v||!h,[_,null==J?void 0:J.loading,v,h]),H=(0,D.useCallback)(e=>{t.mutate({mantelpieceId:l.id,dto:e},{onSuccess:()=>{r({description:n("publishedChanges"),variant:"success",position:"top-right"}),o({...l,...e}),i()}})},[r,t,i,n,o,l]),P=(0,D.useCallback)(async e=>{var l;H({mantelpieceRelation:null==e?void 0:e.mantelpieceRelation,mantelpieceImageId:null==e?void 0:null===(l=e.media)||void 0===l?void 0:l.uploadId,...(null==e?void 0:e.descriptionJson)!=null&&{descriptionJson:e.descriptionJson},...(null==e?void 0:e.descriptionHtml)!=null&&{descriptionHtml:e.descriptionHtml}})},[H]);return{handleSubmit:U,control:L,onAddMedia:N,onRemoveMedia:Z,isLoading:_,isDisabled:F,setValue:E,isCardFromCardDatabase:c,onSubmit:P,ownCardOptions:s,relationOptions:p}},EditMantelpieceForm=e=>{let{mantelpiece:l,submitPortalRef:i,onAfterSubmit:b}=e,{t:f}=(0,g.$G)(),{control:Q,handleSubmit:k,isLoading:C,isCardFromCardDatabase:I,onAddMedia:y,onRemoveMedia:R,onSubmit:U,isDisabled:M,relationOptions:D,setValue:E}=useEditMantelpiece({mantelpiece:l,onAfterSubmit:b});return(0,n.jsxs)(u.k,{flexDir:"column",bg:"neutral.50",gap:(0,c.Q)(2),children:[(0,n.jsx)(s.x,{isCardFromCardDatabase:I,imageUrl:(null==l?void 0:l.externalImageUrl)||(null==l?void 0:l.imageUrl),number:null==l?void 0:l.number,name:null==l?void 0:l.name,variant:null==l?void 0:l.variant,set:null==l?void 0:l.set,mantelpieceRelation:null==l?void 0:l.mantelpieceRelation,grade:null==l?void 0:l.grade}),(0,n.jsx)("form",{children:(0,n.jsxs)(u.k,{flexDir:"column",gap:(0,c.Q)(2),children:[(0,n.jsx)(t.Z,{px:{base:(0,c.Q)(24),lg:(0,c.Q)(32)},py:(0,c.Q)(32),children:(0,n.jsxs)(u.k,{flexDir:"column",gap:(0,c.Q)(16),flex:1,pb:{base:(0,c.Q)(8),lg:(0,c.Q)(24)},children:[(0,n.jsx)(m.l,{variant:"accent",children:f("mantelpiece.relationQuestion")}),(0,n.jsxs)(p.NI,{children:[(0,n.jsx)(m.l,{children:f("mantelpiece.relation")}),(0,n.jsx)(j.Qr,{control:Q,name:"mantelpieceRelation",render:e=>{let{field:{onChange:l,onBlur:i,value:a}}=e;return(0,n.jsx)(r.Ph,{id:"mantelpieceRelation",onChange:e=>{l(null==e?void 0:e.value)},onBlur:i,value:null==D?void 0:D.find(e=>(null==e?void 0:e.value)===a),options:D,placeholder:f("mantelpiece.selectRelation"),dropdownIndicator:!0,menuPortalTarget:document.body})}})]})]})}),(0,n.jsx)(t.Z,{flexDir:"column",px:{base:(0,c.Q)(24),lg:(0,c.Q)(32)},py:(0,c.Q)(32),children:(0,n.jsxs)(p.NI,{children:[(0,n.jsx)(m.l,{variant:"accent",mb:(0,c.Q)(16),color:"black.500",children:f("description.title")}),(null==l?void 0:l.description)&&!(null==l?void 0:l.descriptionJson)?(0,n.jsx)(o.Z,{markdownText:null==l?void 0:l.description}):(0,n.jsx)(j.Qr,{control:Q,name:"descriptionJson",render:e=>
1{let{field:{onChange:i,value:o}}=e;return(0,n.jsx)(a.Z,{onChange:(e,l)=>{i(e),E("descriptionHtml",l)},content:o,placeholder:f("description.placeholder")},l?l.id:void 0)}})]})}),(0,n.jsxs)(t.Z,{flexDir:"column",px:{base:(0,c.Q)(24),lg:(0,c.Q)(32)},py:(0,c.Q)(32),gap:(0,c.Q)(16),children:[(0,n.jsxs)(u.k,{flexDir:"column",gap:{base:(0,c.Q)(8),lg:(0,c.Q)(16)},children:[(0,n.jsx)(m.l,{variant:"accent",children:f("imageForYourMantelpiece")}),I&&(0,n.jsx)(x.x,{variant:"p1",color:"black.500",children:f("optionalUploadOfImageMantelpiece")})]}),(0,n.jsx)(p.NI,{children:(0,n.jsx)(j.Qr,{control:Q,name:"media",render:e=>{let{field:{value:l}}=e;return(0,n.jsx)(d.f,{id:"mantelpiece-edit-media",onAddMedia:y,value:l,onRemoveMedia:R})}})})]}),i.current&&(0,h.createPortal)((0,n.jsx)(v.z,{type:"button",isLoading:C,isDisabled:M,onClick:k(U),flex:{base:1,lg:"unset"},variant:"primary",minW:(0,c.Q)(112),className:"edit-mantelpiece-form-submit-action",children:f("publishChanges")}),i.current)]})})]})}},96082:function(e,l,i){i.r(l);var n=i(85893),a=i(92879),o=i(16576),t=i(7636),r=i(35391),d=i(46685),s=i(89693),c=i(89423),u=i(97878),m=i(93717),p=i(93108),x=i(67294),v=i(17527),h=i(41507);l.default=e=>{let{mantelpiece:l,isOpen:i,onClose:j}=e,{t:g}=(0,v.$G)(),b=(0,x.useRef)(null);return(0,n.jsxs)(o.u_,{isOpen:i,onClose:j,size:"2xl",scrollBehavior:"inside",closeOnOverlayClick:!1,children:[(0,n.jsx)(t.Z,{}),(0,n.jsxs)(r.h,{children:[(0,n.jsx)(d.x,{children:g("editItem")}),(0,n.jsx)(s.o,{color:"neutral.700",top:(0,a.Q)(27)}),(0,n.jsx)(c.f,{p:0,children:(0,n.jsx)(h.w,{mantelpiece:l,submitPortalRef:b,onAfterSubmit:j})}),(0,n.jsx)(u.m,{children:(0,n.jsxs)(m.k,{w:"full",gap:(0,a.Q)(16),justifyContent:"space-between",children:[(0,n.jsx)(p.z,{variant:"outline",onClick:j,minW:(0,a.Q)(112),className:"edit-mantelpiece-modal-close-action",children:g("cancel")}),(0,n.jsx)(m.k,{ref:b})]})})]})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.