ocearo-ui
Version:
Ocean Robot UI: Sailing made smarter
1 lines • 1.06 kB
JavaScript
;(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[79],{68079:function(e,t,l){l.r(t);var r=l(57437),s=l(2265);t.default=e=>{let{path:t}=e,[l,c]=(0,s.useState)([]),[n,o]=(0,s.useState)(null),a=(0,s.useRef)(null);return(0,s.useEffect)(()=>{(async()=>{try{let e=await fetch("".concat(t,"/index.json"));if(!e.ok)throw Error("Network response was not ok");let l=await e.json();c(l),l.length>0&&o(l[0])}catch(e){console.error("Error fetching PDF files:",e)}})()},[t]),(0,r.jsxs)("div",{className:"flex flex-col h-full",ref:a,children:[(0,r.jsx)("div",{className:"bg-oGray2 text-white p-4 flex space-x-4",children:l.map((e,t)=>(0,r.jsx)("button",{className:"px-4 py-2 rounded-t ".concat((null==n?void 0:n.file)===e.file?"bg-oGray font-bold":"hover:bg-oGray"),onClick:()=>o(e),children:e.title},t))}),(0,r.jsx)("div",{className:"flex-grow bg-oGray2 text-white p-4 flex items-center justify-center",children:n&&(0,r.jsx)("iframe",{src:"".concat(t,"/").concat(n.file),title:"PDF Viewer",width:"100%",height:"100%",style:{border:"none"}})})]})}}}]);