(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[959],{1289:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>u});var l=a(5155),s=a(2115),r=a(2801),n=a(6874),i=a.n(n),c=a(5695);let o="https://api-arsipkl.dimasp.app";function u(){let{token:e}=(0,r.A)(),t=(0,c.useRouter)(),[a,n]=(0,s.useState)(""),[u,d]=(0,s.useState)([]),[m,p]=(0,s.useState)(!1);return(0,s.useEffect)(()=>{let t=setTimeout(()=>{if(""===a.trim())return void d([]);(async()=>{p(!0);try{let t={};e&&(t.Authorization="Bearer ".concat(e));let l=await fetch("".concat(o,"/api/users/search?q=").concat(a),{headers:t}),s=await l.json();l.ok&&d(s)}catch(e){console.error("Gagal melakukan pencarian:",e)}finally{p(!1)}})()},300);return()=>clearTimeout(t)},[a,e]),(0,l.jsxs)("div",{className:"container mx-auto max-w-xl py-10 px-4",children:[(0,l.jsxs)("button",{onClick:()=>t.back(),className:"mb-4 bg-transparent flex items-center gap-2 cursor-pointer",style:{border:"none"},children:[(0,l.jsx)("span",{style:{fontSize:"1.2em"},children:"←"}),(0,l.jsx)("span",{children:"Kembali"})]}),(0,l.jsx)("h1",{className:"text-3xl font-bold mb-6",children:"Cari Pengguna"}),(0,l.jsx)("div",{className:"mb-6",children:(0,l.jsx)("input",{type:"text",value:a,onChange:e=>n(e.target.value),placeholder:"Ketik nama atau username...",className:"w-full px-4 py-2 border rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500"})}),(0,l.jsxs)("div",{className:"bg-white rounded-lg shadow-md",children:[m&&(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center p-6",children:[(0,l.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mb-3"}),(0,l.jsx)("p",{className:"text-blue-600 font-semibold",children:"Memuat..."})]}),!m&&a&&0===u.length&&(0,l.jsx)("p",{className:"p-4 text-center text-gray-500",children:"Pengguna tidak ditemukan."}),(0,l.jsx)("div",{className:"divide-y",children:u.map(e=>(0,l.jsx)(i(),{href:"/profil/".concat(e.username),children:(0,l.jsxs)("div",{className:"flex items-center space-x-4 p-4 hover:bg-gray-50 transition-colors",children:[(0,l.jsx)("img",{src:e.profile_picture_url&&""!==e.profile_picture_url&&"default_profile.png"!==e.profile_picture_url?"".concat(o).concat(e.profile_picture_url):"/default_profile.png",alt:e.username,className:"w-12 h-12 rounded-full object-cover"}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"flex items-center",children:[(0,l.jsx)("p",{className:"font-bold",children:e.username}),e.is_verified&&(0,l.jsx)("img",{src:"/verified-badge.webp",alt:"Verified",className:"w-4 h-4 ml-1"})]}),(0,l.jsx)("p",{className:"text-sm text-gray-600",children:e.full_name})]})]})},e.id))})]})]})}},2801:(e,t,a)=>{"use strict";a.d(t,{A:()=>c,AuthProvider:()=>i});var l=a(5155),s=a(2115),r=a(9159);let n=(0,s.createContext)(null);function i(e){let{children:t}=e,[a,i]=(0,s.useState)(null),[c,o]=(0,s.useState)(null),[u,d]=(0,s.useState)(!0);async function m(e,t){if(e&&t)try{let a=await fetch("".concat("https://api-arsipkl.dimasp.app","/api/users/").concat(e),{headers:{Authorization:"Bearer ".concat(t)}});if(a.ok){let e=await a.json();i(t=>({...t,...e.user}))}}catch(e){}}(0,s.useEffect)(()=>{let e=localStorage.getItem("token");if(e)try{let t=(0,r.s)(e);i(t),o(e),m(t.username,e)}catch(e){localStorage.removeItem("token"),i(null),o(null)}d(!1)},[]);let p=async e=>{if(e){localStorage.setItem("token",e);try{let t=(0,r.s)(e);i(t),o(e),await m(t.username,e)}catch(e){i(null),o(null),localStorage.removeItem("token")}}};return(0,l.jsx)(n.Provider,{value:{user:a,token:c,loginUser:p,logout:()=>{localStorage.removeItem("token"),i(null),o(null)},loading:u},children:t})}let c=()=>(0,s.useContext)(n)},3075:(e,t,a)=>{Promise.resolve().then(a.bind(a,1289))}},e=>{e.O(0,[556,441,964,358],()=>e(e.s=3075)),_N_E=e.O()}]);