PageSourceSearch

https://www.thestudyias.com/_next/static/chunks/5409.96b850413793b755.js

js thestudyias.com collected 2026-09-24 11:38:27 UTC 7,373 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5409],{35409:function(e,t,s){s.r(t);var a=s(57437),l=s(2265),r=s(37996),n=s(56462),o=s(55605);t.default=()=>{let[e,t]=(0,l.useState)([]),[s,i]=(0,l.useState)(!0),[c,d]=(0,l.useState)(null),[m,u]=(0,l.useState)(""),[p,h]=(0,l.useState)("");(0,l.useEffect)(()=>{g()},[]);let g=async()=>{try{i(!0);let e=[],s=0;for(;;){let t=await (0,o.De)(s,200,"creation_date","DESC",null,""),a=t?.responseObject?.recordList||t?.responseObject?.data||t?.responseObject||t?.data||t||[];if(!Array.isArray(a)||0===a.length||(e.push(...a),a.length<200))break;s+=200}let a=[];for(let t of e){let e=t?.id??t?.recordId??t?.ID;if(e||0===e)try{let t=await (0,o.TP)(e),s=t?.responseObject||t?.data||t;Array.isArray(s)&&(s.forEach(t=>{t&&(void 0===t.blog_post_id||null===t.blog_post_id)&&(t.blog_post_id=e)}),a.push(...s))}catch(e){continue}}let l=Array.from(new Map(a.map(e=>[e.id,e])).values());l.sort((e,t)=>new Date(t.creation_date).getTime()-new Date(e.creation_date).getTime()),t(l),u("")}catch(e){console.error("Error fetching comments:",e),u("Failed to fetch comments"),h("error")}finally{i(!1)}},[y,b]=(0,l.useState)({}),[x,j]=(0,l.useState)({}),[_,f]=(0,l.useState)(null),[N,v]=(0,l.useState)(null),[w,C]=(0,l.useState)(""),[S,A]=(0,l.useState)(null),[T,D]=(0,l.useState)(""),k=async()=>{if(!T){u("Please enter a blog post ID"),h("error"),setTimeout(()=>u(""),3e3);return}try{i(!0);let e=await (0,o.TP)(T),s=e?.responseObject||e?.data||e||[],a=Array.isArray(s)?s.map(e=>({...e,blog_post_id:e.blog_post_id??T})):[];t(a.sort((e,t)=>new Date(t.creation_date).getTime()-new Date(e.creation_date).getTime())),u("")}catch(e){console.error("Error loading comments for id:",e),u("Failed to load comments for that post"),h("error")}finally{i(!1)}},E=e=>{b(t=>({...t,[e]:!t[e]})),j(t=>void 0===t[e]?{...t,[e]:""}:t)},I=(e,t)=>{j(s=>({...s,[e]:t}))},P=async e=>{let s=e.id,a=e.blog_post_id??e.blogPostId??e.blogPostID??e.blogId,l=(x[s]||"").trim();if(!l){u("Reply cannot be empty"),h("error"),setTimeout(()=>u(""),3e3);return}try{f(s);let e=await (0,o.o_)(a,l,"[email protected]","Admin",null);try{let e=await (0,o.TP)(a),s=e?.responseObject||e?.data||e||[],l=Array.isArray(s)?s.map(e=>({...e,blog_post_id:e.blog_post_id??a})):[];t(e=>{let t=(e||[]).filter(e=>String(e.blog_post_id)!==String(a)),s=[...l,...t];return s.sort((e,t)=>new Date(t.creation_date).getTime()-new Date(e.creation_date).getTime()),s})}catch(l){let s=e?.responseObject||e?.data||e||{id:Date.now()};s.creation_date||(s.creation_date=new Date().toISOString()),s.name||(s.name="Admin"),s.email||(s.email="[email protected]"),(void 0===s.blog_post_id||null===s.blog_post_id)&&(s.blog_post_id=a),t(e=>[s,...e])}u("Reply posted successfully"),h("success"),b(e=>({...e,[s]:!1})),j(e=>({...e,[s]:""})),setTimeout(()=>u(""),3e3)}catch(e){console.error("Error posting reply:",e),u("Failed to post reply"),h("error")}finally{f(null)}},O=e=>{let t=e.id;N===t?(v(null),C("")):(v(t),C(e.comment||""))},R=async e=>{let s=e.id,a=(w||"").trim();if(!a){u("Updated comment cannot be empty"),h("error"),setTimeout(()=>u(""),3e3);return}try{A(s);let e=await (0,o.xu)(s,a,"Admin","","[email protected]");if(e?.errorCode===0)t(e=>e.map(e=>e.id===s?{...e,comment:a,name:"Admin",email:"[email protected]"}:e)),u("Comment updated"),h("success"),v(null),C(""),setTimeout(()=>u(""),3e3);else throw Error(e?.errorMessage||"Update failed")}catch(e){console.error("Error updating comment:",e),u("Failed to update comment"),h("error")}finally{A(null)}},F=()=>{v(null),C("")},L=e=>String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),M=e=>e?L(e).replace(/((https?:\/\/|www\.)[^\s]+)/gi,e=>{let t=e.startsWith("http")?e:"http://"+e;return`<a href="${t}" target="_blank" rel="noopener noreferrer">${e}</a>`}):"",q=async s=>{if(window.confirm("Are you sure you want to delete this comment?"))try{d(s);let a=await (0,o.ps)(s);if(0===a.errorCode){let a=e.filter(e=>e.id!==s);t(a),u("Comment deleted successfully!"),h("success"),setTimeout(()=>u(""),3e3)}else u(a.errorMessage||"Failed to delete comment"),h("error")}catch(e){console.error("Error deleting comment:",e),u("Error deleting comment. Please try again."),h("error")}finally{d(null)}};return s?(0,a.jsx)(n.Z,{title:"All Comments",children:(0,a.jsxs)("div",{className:"loading-state",children:[(0,a.jsx)(r.dAq,{className:"spinner"})," Loading comments..."]})}):(0,a.jsx)(n.Z,{title:"All Comments",children:(0,a.jsxs)("div",{className:"comments-container",children:[m&&(0,a.jsx)("div",{className:`message-alert ${p}`,children:m}),0===e.length?(0,a.jsx)("div",{className:"empty-state",children:(0,a.jsx)("p",{children:"No comments found"})}):(0,a.jsxs)("div",{className:"comments-wrapper",children:[(0,a.jsx)("div",{className:"comments-stats",children:(0,a.jsxs)("span",{children:["Total Comments: ",(0,a.jsx)("strong",{children:e.length})]})}),(0,a.jsxs)("div",{className:"comments-controls",style:{display:"flex",gap:8,alignItems:"center",marginBottom:12},children:[(0,a.jsx)("input",{placeholder:"Blog Post ID",value:T,onChange:e=>D(e.target.value),style:{padding:"6px 8px",width:160}}),(0,a.jsx)("button",{className:"btn-load",onClick:k,children:"Load"}),(0,a.jsx)("button",{className:"btn-refresh",onClick:g,children:"Refresh All"})]}),(0,a.jsx)("div",{className:"comments-list",children:e.map(e=>(0,a.jsxs)("div",{className:"comment-card",children:[(0,a.jsxs)("div",{className:"comment-header",children:[(0,a.jsxs)("div",{className:"comment-meta",children:[(0,a.jsx)("h4",{className:"comment-author",children:e.name}),(0,a.jsx)("p",{className:"comment-email",children:e.email}),(0,a.jsx)("p",{className:"comment-date",children:new Date(e.creation_date).toLocaleStr
1ing()}),(0,a.jsxs)("p",{className:"comment-blog-id",children:["Blog Post ID: ",(0,a.jsx)("strong",{children:e.blog_post_id})]})]}),(0,a.jsx)("button",{onClick:()=>q(e.id),className:"btn-delete",disabled:c===e.id,title:"Delete comment",children:c===e.id?(0,a.jsx)(r.dAq,{className:"spinner"}):(0,a.jsx)(r.Ybf,{})}),(0,a.jsx)("button",{onClick:()=>E(e.id),className:"btn-reply",title:"Reply to comment",children:"Reply"})]}),(0,a.jsx)("div",{className:"comment-body",children:N===e.id?(0,a.jsxs)("div",{className:"comment-edit-box",children:[(0,a.jsx)("textarea",{value:w,onChange:e=>C(e.target.value),rows:4}),(0,a.jsxs)("div",{className:"edit-actions",children:[(0,a.jsx)("button",{className:"btn-save-edit",onClick:()=>R(e),disabled:S===e.id,children:S===e.id?"Saving...":"Save"}),(0,a.jsx)("button",{className:"btn-cancel-edit",onClick:F,children:"Cancel"})]})]}):(0,a.jsx)("p",{dangerouslySetInnerHTML:{__html:M(e.comment||"")}})}),y[e.id]&&(0,a.jsxs)("div",{className:"comment-reply-box",children:[(0,a.jsx)("textarea",{value:x[e.id]??"",onChange:t=>I(e.id,t.target.value),placeholder:"Write your reply...",rows:3}),(0,a.jsxs)("div",{className:"reply-actions",children:[(0,a.jsx)("button",{className:"btn-send-reply",onClick:()=>P(e),disabled:_===e.id,children:_===e.id?"Sending...":"Send Reply"}),(0,a.jsx)("button",{className:"btn-cancel-reply",onClick:()=>E(e.id),children:"Cancel"})]})]}),"[email protected]"===e.email&&N!==e.id&&(0,a.jsx)("div",{style:{marginTop:8},children:(0,a.jsx)("button",{className:"btn-edit",onClick:()=>O(e),children:"Edit"})})]},e.id))})]})]})})}}}]);

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.