1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6903],{30401:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>m});var r=a(37876),i=a(14232),n=a(89099),s=a(62422),l=a(62406),o=a(94430);let d=[["en","English"],["hi","Hindi"],["gu","Gujarati"],["pa","Punjabi"],["ta","Tamil"],["te","Telugu"],["bn","Bengali"],["mr","Marathi"],["ur","Urdu"],["es","Spanish"]],c=e=>{let t=(e||"").replace(/\D/g,"").slice(-10);return 10===t.length?`(${t.slice(0,3)}) ${t.slice(3,6)}-${t.slice(6)}`:e||""};function m(){let e=(0,n.useRouter)(),{member:t,loading:a}=(0,l.IG)(),{toast:m}=(0,o.j)(),[x,h]=(0,i.useState)([]),[u,p]=(0,i.useState)(!1),[b,g]=(0,i.useState)(!1),[f,y]=(0,i.useState)(null),[w,j]=(0,i.useState)(!0),[v,N]=(0,i.useState)("");function _(){j(!0),Promise.all([fetch(`/api/member/mod/voicemails${b?"?all=1":""}`).then(e=>e.json()),fetch("/api/member/mod/voicemails?settings=1").then(e=>e.json())]).then(([e,t])=>{e.error||(h(e.voicemails||[]),p(!!e.isAdmin)),t.error||y(t.settings||{})}).finally(()=>j(!1))}async function k(e){y(t=>({...t,voicemail_lang:e}));try{let t=await fetch("/api/member/mod/voicemails",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"settings",voicemailLang:e})}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"Save failed")}catch(e){m(e.message,"error")}}(0,i.useEffect)(()=>{if(!a){if(t&&!t.is_staff)return void e.replace("/app");t&&_()}},[a,t,b]);let[S,C]=(0,i.useState)(null);async function $(e){C(e);try{let t=await fetch("/api/member/mod/voicemails",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"retry-audio",id:e})}),a=await t.json();if(!t.ok||a.error)throw Error(a.error||"Could not fetch it");m("Got it â the recording is here.","success"),_()}catch(e){m(e.message,"error")}finally{C(null)}}async function T(e){h(t=>t.map(t=>t.id===e?{...t,is_read:!0}:t)),fetch("/api/member/mod/voicemails",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"read",id:e})}).catch(()=>{})}return(0,r.jsxs)(s.Ay,{title:"Voicemail",active:"/app/admin",children:[(0,r.jsx)("h1",{className:"app-fade-up text-xl font-extrabold text-brand-navy dark:text-white mb-1",children:"Voicemail"}),(0,r.jsx)("p",{className:"app-fade-up text-gray-500 dark:text-white/55 text-sm mb-4",children:"Missed calls to your extension, transcribed and translated."}),(0,r.jsxs)("div",{className:"app-fade-up bg-white border border-orange-100 rounded-2xl p-4 shadow-xs mb-5",children:[(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsx)("p",{className:"font-bold text-brand-navy dark:text-white text-sm",children:"My extension"}),(0,r.jsx)("p",{className:"text-gray-500 dark:text-white/55 text-xs mt-0.5",children:"Callers dial the main number and enter your extension to leave you a voicemail here. Your extension is assigned for you."})]}),(0,r.jsxs)("div",{className:"text-right shrink-0",children:[(0,r.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-wide text-gray-400 dark:text-white/45",children:"Extension"}),(0,r.jsx)("p",{className:"text-2xl font-extrabold text-brand-navy dark:text-white tabular-nums leading-tight",children:f?.extension||"â"})]})]}),(0,r.jsxs)("label",{className:"text-xs font-semibold text-gray-600 dark:text-white/70 block mt-3",children:["Translate voicemails to",(0,r.jsx)("select",{value:f?.voicemail_lang||"en",onChange:e=>k(e.target.value),className:"mt-1 w-full border border-gray-200 rounded-xl px-3 py-2.5 text-sm bg-white",children:d.map(([e,t])=>(0,r.jsx)("option",{value:e,children:t},e))})]})]}),u&&(0,r.jsxs)("div",{className:"flex gap-2 mb-3",children:[(0,r.jsx)("button",{onClick:()=>g(!1),className:`text-xs font-bold px-3 py-1.5 rounded-full ${!b?"bg-brand-navy text-white":"bg-gray-100 text-gray-600 dark:text-white/70"}`,children:"Mine"}),(0,r.jsx)("button",{onClick:()=>g(!0),className:`text-xs font-bold px-3 py-1.5 rounded-full ${b?"bg-brand-navy text-white":"bg-gray-100 text-gray-600 dark:text-white/70"}`,children:"Everyone"})]}),!w&&x.length>
10&&(0,r.jsx)("input",{value:v,onChange:e=>N(e.target.value),placeholder:"Searchâ¦",className:"w-full border border-orange-100 rounded-xl px-4 py-2.5 text-sm mb-3"}),w?(0,r.jsx)("div",{className:"space-y-2",children:[0,1,2].map(e=>(0,r.jsx)("div",{className:"h-24 rounded-2xl bg-white border border-orange-100 app-shine"},e))}):0===x.length?(0,r.jsx)("p",{className:"text-gray-400 dark:text-white/45 text-sm text-center py-10",children:"No voicemails yet."}):(0,r.jsx)("div",{className:"space-y-3 app-stagger",children:x.filter(e=>{let t=v.trim().toLowerCase();return!t||[e.caller_name,e.from_number,e.transcript,e.translation].some(e=>String(e||"").toLowerCase().includes(t))}).map(t=>{let a;return(0,r.jsxs)("div",{className:`bg-white border rounded-2xl p-4 shadow-xs ${t.is_read?"border-gray-100":"border-brand-orange/40"}`,onClick:()=>!t.is_read&&T(t.id),children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("div",{className:"min-w-0",children:[(0,r.jsxs)("p",{className:"font-bold text-brand-navy dark:text-white text-sm truncate",children:[!t.is_read&&(0,r.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-brand-orange mr-1.5 align-middle"}),t.caller_name||c(t.from_number)||"Unknown caller"]}),(0,r.jsxs)("p",{className:"text-gray-400 dark:text-white/45 text-[11px]",children:[t.caller_name&&t.from_number?`${c(t.from_number)} \xb7 `:"",new Date(t.created_at).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),t.duration?` \xb7 ${(a=t.duration)?`${Math.floor(a/60)}:${String(a%60).padStart(2,"0")}`:""}`:"",b&&t.owner_name?` \xb7 ext ${t.extension} (${t.owner_name})`:""]})]}),t.from_number&&(0,r.jsx)("button",{onClick:a=>{var r;a.stopPropagation(),(r=t.from_number)&&e.push(`/app/admin/communications?call=${encodeURIComponent(r)}`)},"aria-label":`Call ${t.caller_name||c(t.from_number)} back`,className:"shrink-0 w-9 h-9 rounded-full bg-green-500 text-white flex items-center justify-center active:scale-95 transition-transform",children:(0,r.jsx)("svg",{width:"15",height:"15",fill:"currentColor",viewBox:"0 0 24 24",children:(0,r.jsx)("path",{d:"M6.6 10.8c1.4 2.8 3.8 5.1 6.6 6.6l2.2-2.2c.3-.3.7-.4 1-.2 1.1.4 2.3.6 3.6.6.6 0 1 .4 1 1V20c0 .6-.4 1-1 1-9.4 0-17-7.6-17-17 0-.6.4-1 1-1h3.5c.6 0 1 .4 1 1 0 1.3.2 2.5.6 3.6.1.3 0 .7-.2 1L6.6 10.8z"})})})]}),t.audio_path&&(0,r.jsx)("audio",{controls:!0,preload:"metadata",src:`/api/member/mod/voicemail-audio?id=${t.id}`,className:"w-full mt-2.5 h-9"}),t.translation&&(0,r.jsx)("p",{className:"text-brand-navy dark:text-white text-sm mt-2.5 whitespace-pre-wrap",children:t.translation}),t.transcript&&(0,r.jsxs)("details",{className:"mt-1.5",children:[(0,r.jsxs)("summary",{className:"text-[11px] font-semibold text-gray-400 dark:text-white/45 cursor-pointer",children:[t.translation?"Original transcript":"Transcript",t.transcript_lang?` \xb7 ${t.transcript_lang}`:""]}),(0,r.jsx)("p",{className:"text-gray-600 dark:text-white/70 text-sm mt-1 whitespace-pre-wrap",children:t.transcript})]}),!t.audio_path&&(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsxs)("p",{className:"text-amber-700 dark:text-amber-300 text-xs",children:["Recording unavailable",t.audio_error?` â ${t.audio_error}`:"",". Call them back on the number above."]}),t.recording_sid&&(0,r.jsx)("button",{onClick:()=>$(t.id),disabled:S===t.id,className:"mt-1.5 text-xs font-bold rounded-xl px-3 py-1.5 border border-orange-100 text-brand-navy dark:text-white disabled:opacity-50",children:S===t.id?"Fetchingâ¦":"Try fetching it again"})]})]},t.id)})})]})}},82714:(e,t,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/app/admin/voicemail",function(){return a(30401)}])}},e=>{e.O(0,[8230,900,8766,2422,636,6593,8792],()=>e(e.s=82714)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.