"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["components/pages/IpAddressDomainsPage"],{909:(e,t,s)=>{s.r(t),s.d(t,{default:()=>c});var a=s(241),n=s(719),d=s(242),i=s(910),o=s(90),r=s(447),u=s(748);const l=r.gql`
    mutation UpdateIpAddressDefaultDomain($input: UpdateIpAddressDefaultDomainInput!) {
        updateIpAddressDefaultDomain(input: $input) {
            ipAddress {
                id
                defaultDomain {
                    id
                }
            }
        }
    }
`,p=o.Locale.getTranslate("components.pages.ip-address-domains"),c=()=>{const e=(0,n.useNavigate)(),[t,s]=(0,a.useState)(),{ipAddress:o,viewer:r}=(0,n.useLoaderData)(),{ipAddressId:c}=(0,n.useParams)(),[m,{loading:f}]=(0,u.useMutation)(l,{onCompleted:()=>e(-1)}),D=t||o.defaultDomain?.id,A=t&&t!==o.defaultDomain?.id,y="ADMIN"===r.type||"EXCLUSIVE"===o.type,C=e=>()=>s(e),j=(0,a.useMemo)((()=>[{key:"name",title:(0,a.jsx)(p,{content:"site"}),type:"title",render:({id:e,name:t})=>y?(0,a.jsx)(d.Radio,{onChange:C(e),checked:D===e,children:t}):t}]),[D,y]);return(0,a.jsx)(i.default,{"data-type":"ip-address-domains-drawer",title:(0,a.jsx)(p,{content:"title",params:{type:(0,a.jsx)(p,{content:`type-${o.type}`}),ipAddress:o.ipAddress}}),onClose:()=>e(-1),children:(0,a.jsx)(d.List,{id:"ip-address-domains-list",rowKey:"id",data:o.domains,columns:j,toolbar:y?(0,a.jsx)(d.Toolbar,{children:(0,a.jsx)(d.Button,{"data-testid":"updateDomainButton",onClick:async()=>{await m({variables:{input:{ipAddressId:c,domainId:t}}})},disabled:!A,state:f?"loading":void 0,children:(0,a.jsx)(p,{content:"setAsDefault"})})}):null})})}},910:(e,t,s)=>{s.r(t),s.d(t,{default:()=>r});var a=s(241),n=s(243),d=s.n(n),i=s(242);const o=({onClose:e,isOpen:t,...s})=>{const[n,d]=(0,a.useState)(t),o=(0,a.useRef)(null),r=(0,a.useMemo)((()=>e?(...t)=>{d(!1),o.current=setTimeout((()=>{e(...t),o.current=null}),300)}:e),[e]);return(0,a.useEffect)((()=>()=>clearTimeout(o.current)),[]),(0,a.useEffect)((()=>{o.current&&clearTimeout(o.current)}),[t]),(0,a.jsx)(i.Drawer,{...s,onClose:r,isOpen:n})};o.propTypes={onClose:d().func,isOpen:d().bool},o.defaultProps={onClose:null,isOpen:!0};const r=o}}]);
//# sourceMappingURL=IpAddressDomainsPage.js.map?f72a8118f87924862ef4