"use strict";(self.webpackChunkmavunoorgbackend=self.webpackChunkmavunoorgbackend||[]).push([[1448],{11448:(S,m,s)=>{s.r(m),s.d(m,{default:()=>V});var e=s(19968),c=s(62552),g=s(20596),D=s(20436),f=s(5e3),x=s(48112),d=s(28464),p=s(42848),T=s(20464),v=s(76512),E=s(9752),l=s(63358),j=s(48744),P=s(48936),M=s(23264),L=s(81504),r=s(95840),u=s(14032),O=s(51384),A=s(71324),B=s(21424),R=s(14632),a=s(3704),_=s(96728),i=s(58476),q=s(48632);const V=()=>{(0,r.G0)();const{formatMessage:n}=(0,R.c)(),{data:o,isLoading:K,isError:N,remove:Q,regenerate:Y}=(0,i.u)(),[C,I]=(0,c.useState)(!1),[z,y]=(0,c.useState)(!1),[F,H]=(0,c.useState)(),{allowedActions:h}=(0,r.aU)(_.P),Z=4,J=(o?.docVersions?.length||0)+1,X=t=>{Y.mutate({version:t,prefix:o?.prefix})},w=()=>{I(!C)},b=async()=>{y(!0),await Q.mutateAsync({prefix:o?.prefix,version:F}),I(!C),y(!1)},k=t=>{H(t),I(!C)},$=n({id:(0,i.g)("plugin.name"),defaultMessage:"Documentation"});return N?(0,e.jsx)(g._,{children:(0,e.jsx)(D.S,{children:(0,e.jsx)(f.k,{paddingTop:8,children:(0,e.jsx)(r.wF,{})})})}):(0,e.jsxs)(g._,{children:[(0,e.jsx)(B.S,{title:$}),(0,e.jsxs)(x.G,{"aria-busy":K,children:[(0,e.jsx)(d.a,{title:$,subtitle:n({id:(0,i.g)("pages.PluginPage.header.description"),defaultMessage:"Configure the documentation plugin"}),primaryAction:(0,e.jsx)(G,{disabled:!h.canOpen||!o?.currentVersion||!o?.prefix,href:W(`${o?.prefix}/v${o?.currentVersion}`),startIcon:(0,e.jsx)(u.c,{}),children:n({id:(0,i.g)("pages.PluginPage.Button.open"),defaultMessage:"Open Documentation"})})}),(0,e.jsxs)(D.S,{children:[K&&(0,e.jsx)(r.Wm,{children:"Plugin is loading"}),o?.docVersions.length?(0,e.jsxs)(p.o,{colCount:Z,rowCount:J,children:[(0,e.jsx)(T.o,{children:(0,e.jsxs)(v.Tr,{children:[(0,e.jsx)(E.Th,{children:(0,e.jsx)(l.O,{variant:"sigma",textColor:"neutral600",children:n({id:(0,i.g)("pages.PluginPage.table.version"),defaultMessage:"Version"})})}),(0,e.jsx)(E.Th,{children:(0,e.jsx)(l.O,{variant:"sigma",textColor:"neutral600",children:n({id:(0,i.g)("pages.PluginPage.table.generated"),defaultMessage:"Last Generated"})})})]})}),(0,e.jsx)(j.K,{children:o.docVersions.sort((t,U)=>t.generatedDate<U.generatedDate?1:-1).map(t=>(0,e.jsxs)(v.Tr,{children:[(0,e.jsx)(E.Td,{width:"50%",children:(0,e.jsx)(l.O,{children:t.version})}),(0,e.jsx)(E.Td,{width:"50%",children:(0,e.jsx)(l.O,{children:t.generatedDate})}),(0,e.jsx)(E.Td,{children:(0,e.jsxs)(P.C,{justifyContent:"end",onClick:U=>U.stopPropagation(),children:[(0,e.jsx)(M.w,{forwardedAs:"a",disabled:!h.canOpen,href:W(`${o.prefix}/v${t.version}`),noBorder:!0,icon:(0,e.jsx)(u.c,{}),target:"_blank",rel:"noopener noreferrer",label:n({id:(0,i.g)("pages.PluginPage.table.icon.show"),defaultMessage:"Open {target}"},{target:`${t.version}`})}),h.canRegenerate?(0,e.jsx)(M.w,{onClick:()=>X(t.version),noBorder:!0,icon:(0,e.jsx)(O.c,{}),label:n({id:(0,i.g)("pages.PluginPage.table.icon.regenerate"),defaultMessage:"Regenerate {target}"},{target:`${t.version}`})}):null,h.canUpdate&&t.version!==o.currentVersion?(0,e.jsx)(M.w,{onClick:()=>k(t.version),noBorder:!0,icon:(0,e.jsx)(A.c,{}),label:n({id:"global.delete-target",defaultMessage:"Delete {target}"},{target:`${t.version}`})}):null]})})]},t.version))})]}):(0,e.jsx)(r.Su,{})]}),(0,e.jsx)(r.cz,{isConfirmButtonLoading:z,onConfirm:b,onToggleDialog:w,isOpen:C})]})]})},G=(0,a.cp)(L.E)`
  text-decoration: none;
`,W=n=>n.startsWith("http")?n:n.startsWith("/")?`${window.strapi.backendURL}${n}`:`${window.strapi.backendURL}/${n}`},58476:(S,m,s)=>{s.d(m,{g:()=>f,u:()=>x});var e=s(62552),c=s(95840),g=s(48632),D=s(96728);const f=d=>`${D.p}.${d}`,x=()=>{const d=(0,c.eo)(),{del:p,post:T,put:v,get:E}=(0,c.Qn)(),{formatAPIError:l}=(0,c.An)(),{isLoading:j,isError:P,data:M,refetch:L,error:r}=(0,g.useQuery)(["get-documentation",D.p],async()=>{const{data:a}=await E(`/${D.p}/getInfos`);return a});(0,e.useEffect)(()=>{P&&r&&d({type:"warning",message:r?l(r):{id:"notification.error"}})},[P,r,d,l]);const u=a=>{d({type:"warning",message:l(a)})},O=(a,_,i)=>{L(),d({type:a,message:{id:f(_),defaultMessage:i}})},A=(0,g.useMutation)(({prefix:a,version:_})=>p(`${a}/deleteDoc/${_}`),{onSuccess:()=>O("info","notification.delete.success","Successfully deleted documentation"),onError:u}),B=(0,g.useMutation)(({prefix:a,body:_})=>v(`${a}/updateSettings`,_),{onSuccess:()=>O("success","notification.update.success","Successfully updated settings"),onError:u}),R=(0,g.useMutation)(({prefix:a,version:_})=>T(`${a}/regenerateDoc`,{version:_}),{onSuccess:()=>O("info","notification.generate.success","Successfully generated documentation"),onError:u});return{data:M,isLoading:j,isError:P,remove:A,submit:B,regenerate:R}}}}]);
