(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[451],{1374:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>c});var a=t(5155),r=t(5695),n=t(2115),i=t(1561),o=t(2801);function c(){let{slug:e}=(0,r.useParams)(),[s,t]=(0,n.useState)(null),[c,l]=(0,n.useState)(!0),[d,m]=(0,n.useState)(""),[u,h]=(0,n.useState)(!1),[p,x]=(0,n.useState)(!1),{token:f}=(0,o.A)();return((0,n.useEffect)(()=>{e&&(console.log("Fetching post with slug:",e),l(!0),m(""),fetch("".concat("https://api-arsipkl.dimasp.app","/api/posts/by-slug/").concat(e),{headers:f?{Authorization:"Bearer ".concat(f)}:{}}).then(async e=>{if(!e.ok)throw Error((await e.json()).message||"Gagal memuat postingan");return e.json()}).then(e=>{console.log("Post fetched:",e),t({...e,song_start_time:e.songStartTime,song_end_time:e.songEndTime,isLiked:!!e.isLiked}),h(!0),l(!1)}).catch(e=>{console.error("Error fetching post:",e),m(e.message),l(!1)}))},[e,f]),p)?(0,a.jsx)("div",{className:"flex justify-center items-center min-h-screen",children:(0,a.jsxs)("div",{className:"text-center p-4",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900 mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Memuat profil..."})]})}):s?d?(0,a.jsx)("div",{className:"flex justify-center items-center min-h-screen",children:(0,a.jsx)("div",{className:"text-center p-4",children:(0,a.jsx)("p",{className:"text-red-500",children:d})})}):(0,a.jsx)(a.Fragment,{children:u?(0,a.jsx)(i.A,{post:s,user:{username:s.authorUsername,profile_picture_url:s.authorAvatar,is_verified:s.authorIsVerified},onClose:()=>{h(!1),x(!0),setTimeout(()=>{window.location.href="/profil/".concat(s.authorUsername)},1e3)},onUpdatePost:e=>{if(!e||!e.id)return void console.error("Data update post tidak valid:",e);t(s=>({...s,isLiked:e.isLiked,likeCount:e.likeCount}))},onPostDelete:()=>{h(!1),t(null)}}):(0,a.jsx)("div",{className:"flex justify-center items-center min-h-screen",children:(0,a.jsxs)("div",{className:"text-center p-4",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900 mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Memuat postingan..."})]})})}):(0,a.jsx)("div",{className:"flex justify-center items-center min-h-screen",children:(0,a.jsxs)("div",{className:"text-center p-4",children:[(0,a.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-gray-900 mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Memuat postingan..."})]})})}},8468:(e,s,t)=>{Promise.resolve().then(t.bind(t,1374))}},e=>{e.O(0,[155,556,468,561,441,964,358],()=>e(e.s=8468)),_N_E=e.O()}]);