PageSourceSearch

https://msastroacademy.com/assets/translations-DbZv-vVG.js

js msastroacademy.com collected 2026-09-24 14:48:43 UTC 17,617 bytes, 1 lines download raw bytes

1import{r,j as e}from"./react-vendor-DDlTsOEd.js";import{A as G}from"./AdminLayout-C0t6TWD9.js";import{d as k,ai as D,B as Z,i as M,s as H,ab as B,af as J,j as U,aj as Y}from"./index-dMYrr1t8.js";import{S as L}from"./skeleton-DXQeB_cl.js";import{C as K}from"./check-DVW38x0e.js";import{R as _}from"./rotate-ccw-BS1m-NOZ.js";import"./megaphone-CG_Y22E9.js";import"./clipboard-check-H9MOfMyT.js";import"./database-BMcpOIuo.js";import"./tag-CsU2rQcC.js";import"./credit-card-CV_Lm4ZC.js";const F=25;function V({stat:s}){const g=s.total>0?Math.round(s.reviewed/s.total*100):0;return e.jsxs("div",{className:"bg-white rounded-xl p-4 shadow-sm border border-gray-100",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-900 truncate",title:s.courseTitle,children:s.courseTitle}),e.jsx("div",{className:"mt-2 h-2 rounded-full bg-gray-100 overflow-hidden",children:e.jsx("div",{className:"h-full bg-emerald-500 rounded-full transition-all",style:{width:`${g}%`}})}),e.jsxs("p",{className:"mt-2 text-xs text-gray-900",children:[e.jsx("span",{className:"font-semibold text-emerald-600",children:s.reviewed})," reviewed ·"," ",s.total-s.reviewed," pending · ",s.total," total"]})]})}function C({value:s,onChange:g,placeholder:b,rows:w=2}){return e.jsx("textarea",{value:s,onChange:i=>g(i.target.value),placeholder:b,rows:w,className:"font-telugu w-full px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-900 placeholder:text-gray-500 bg-amber-50/40 focus:outline-none focus:ring-2 focus:ring-amber-200 focus:border-amber-300 resize-y"})}function W({item:s,onSaved:g}){const[b,w]=r.useState(!1),[i,q]=r.useState(s.questionTe),[d,R]=r.useState(s.optionsTe.length===s.options.length?s.optionsTe:s.options.map(()=>"")),[c,E]=r.useState(s.explanationTe),[m,h]=r.useState(!1),[N,p]=r.useState(""),[T,S]=r.useState(0),I=i!==s.questionTe||c!==s.explanationTe||JSON.stringify(d)!==JSON.stringify(s.optionsTe.length===s.options.length?s.optionsTe:s.options.map(()=>""));async function O(){h(!0),p("");try{const n=await k.put(`/admin/translations/quizzes/${s.id}`,{questionTe:i,optionsTe:d,explanationTe:c});S(n.data?.updatedCount??1),g(s.id,{questionTe:i,optionsTe:d,explanationTe:c,reviewed:!0,reviewedAt:new Date().toISOString()}),setTimeout(()=>S(0),2600)}catch(n){p(n instanceof Error?n.message:"Could not save")}finally{h(!1)}}async function y(){h(!0),p("");try{await k.delete(`/admin/translations/quizzes/${s.id}/review`),g(s.id,{reviewed:!1,reviewedAt:null})}catch(n){p(n instanceof Error?n.message:"Could not clear review")}finally{h(!1)}}return e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden",children:[e.jsxs("button",{onClick:()=>w(n=>!n),className:"w-full text-left px-4 py-3 flex items-start gap-3 hover:bg-gray-50 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.reviewed?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-full",children:[e.jsx(B,{size:12})," Reviewed"]}):e.jsx("span",{className:"text-[11px] font-semibold text-amber-700 bg-amber-50 px-2 py-0.5 rounded-full",children:"Needs review"}),e.jsx("span",{className:"text-[11px] text-gray-900 truncate",children:s.lessonTitle}),s.copies>1&&e.jsxs("span",{className:"text-[11px] text-indigo-600 bg-indigo-50 px-2 py-0.5 rounded-full whitespace-nowrap",title:`This question appears in ${s.copies} lessons. Saving updates all of them.`,children:["in ",s.copies," lessons"]})]}),e.jsx("p",{className:"text-sm text-gray-900 mt-1 line-clamp-2",children:s.question}),e.jsx("p",{className:"font-telugu text-sm text-indigo-700 mt-1 line-clamp-2",children:s.questionTe||e.jsx("span",{className:"text-gray-900 italic font-sans",children:"Not translated"})})]}),b?e.jsx(J,{size:16,className:"text-gray-900 mt-1"}):e.jsx(U,{size:16,className:"text-gray-900 mt-1"})]}),b&&e.jsxs("div",{className:"border-t border-gray-100 p-4 space-y-4 bg-gray-50/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide mb-1",children:"Question"}),e.jsx("p",{className:"text-sm text-gray-900 mb-2",children:s.question}),e.jsx(C,{value:i,onChange:q,placeholder:"Telugu question"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide mb-1",children:"Options — Telugu is a label only; the answer recorded is always the English option. Translate all four or leave all four blank."}),e.jsx("div",{className:"space-y-2",children:s.options.map((n,v)=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 items-start",children:[e.jsxs("div",{className:`text-sm px-3 py-2 rounded-lg border ${n===s.correctAnswer?"bg-emerald-50 border-emerald-200 text-emerald-900 font-medium":"bg-white border-gray-200 text-gray-900"}`,children:[n===s.correctAnswer&&e.jsx(K,{size:13,className:"inline mr-1 text-emerald-600"}),n]}),e.jsx(C,{value:d[v]??"",onChange:$=>R(a=>a.map((x,l)=>l===v?$:x)),placeholder:`Telugu for option ${v+1}`,rows:1})]},v))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide mb-1",children:"Explanation"}),e.jsx("p",{className:"text-sm text-gray-900 mb-2",children:s.explanation}),e.jsx(C,{value:c,onChange:E,placeholder:"Telugu explanation",rows:3})]}),N&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2",children:[e.jsx(Y,{size:15,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:N})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("button",{onClick:O,disabled:m||!I,className:"bg-indigo-600 hover:bg-indigo-700 disabled:bg-gray-300 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors",children:m?"Saving…":"Save & mark reviewed"}),s.reviewed&&e.jsxs("button",{onClick:y,disabled:m,title:"Removes the reviewed mark. Your wording stays until the next content update, which then restores the original Telugu.",className:"flex items-center gap-1.5 text-sm text-gray-900 hover:text-gray-800 px-3 py-2 rounded-lg hover:bg-gray-100 transition-colors",children:[e.jsx(_,{size:14})," Unmark reviewed"]}),T>0&&e.jsx("span",{className:"text-sm text-emerald-600 font-medium",children:T>1?`Saved to all ${T} lessons`:"Saved"}),s.reviewed&&s.reviewerName&&e.jsxs("span",{className:"text-xs text-gray-900 ml-auto",children:["Last edited by ",s.reviewerName]})]})]})]})}function X({item:s,onSaved:g}){const[b,w]=r.useState(!1),[i,q]=r.useState(s.titleTe),[d,R]=r.useState(s.descriptionTe),[c,E]=r.useState(s.questions),[m,h]=r.useState(!1),[N,p]=r.useState(""),[T,S]=r.useState(!1),I=i!==s.titleTe||d!==s.descriptionTe||JSON.stringify(c)!==JSON.stringify(s.questions);function O(a,x){E(l=>l.map(u=>u.number===a?{...u,questionTe:x}:u))}function y(a,x,l){E(u=>u.map(f=>{if(f.number!==a)return f;const P=f.optionsTe.length===f.options.length?f.optionsTe:f.options.map(()=>"");return{...f,optionsTe:P.map((Q,A)=>A===x?l:Q)}}))}async function n(){h(!0),p("");try{await k.put(`/admin/translations/assignments/${s.id}`,{titleTe:i,descriptionTe:d,questions:c.map(a=>({number:a.number,questionTe:a.questionTe,optionsTe:a.optionsTe.length===a.options.length?a.optionsTe:[]}
1))}),g(s.id,{titleTe:i,descriptionTe:d,questions:c,reviewed:!0,reviewedAt:new Date().toISOString()}),S(!0),setTimeout(()=>S(!1),1800)}catch(a){p(a instanceof Error?a.message:"Could not save")}finally{h(!1)}}async function v(){h(!0),p("");try{await k.delete(`/admin/translations/assignments/${s.id}/review`),g(s.id,{reviewed:!1,reviewedAt:null})}catch(a){p(a instanceof Error?a.message:"Could not clear review")}finally{h(!1)}}const $=c.filter(a=>a.questionTe.trim()!=="").length;return e.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden",children:[e.jsxs("button",{onClick:()=>w(a=>!a),className:"w-full text-left px-4 py-3 flex items-start gap-3 hover:bg-gray-50 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.reviewed?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded-full",children:[e.jsx(B,{size:12})," Reviewed"]}):e.jsx("span",{className:"text-[11px] font-semibold text-amber-700 bg-amber-50 px-2 py-0.5 rounded-full",children:"Needs review"}),e.jsx("span",{className:"text-[11px] text-gray-900",children:s.courseTitle}),e.jsxs("span",{className:"text-[11px] text-gray-900",children:["· ",$,"/",c.length," questions translated"]})]}),e.jsx("p",{className:"text-sm font-medium text-gray-900 mt-1",children:s.title}),e.jsx("p",{className:"font-telugu text-sm text-indigo-700 mt-0.5",children:s.titleTe||e.jsx("span",{className:"text-gray-900 italic font-sans",children:"Not translated"})})]}),b?e.jsx(J,{size:16,className:"text-gray-900 mt-1"}):e.jsx(U,{size:16,className:"text-gray-900 mt-1"})]}),b&&e.jsxs("div",{className:"border-t border-gray-100 p-4 space-y-5 bg-gray-50/50",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide mb-1",children:"Paper title"}),e.jsx("p",{className:"text-sm text-gray-900 mb-2",children:s.title}),e.jsx(C,{value:i,onChange:q,placeholder:"Telugu title",rows:1})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide mb-1",children:"Instructions"}),e.jsx("p",{className:"text-sm text-gray-900 mb-2",children:s.description}),e.jsx(C,{value:d,onChange:R,placeholder:"Telugu instructions",rows:3})]}),c.map(a=>e.jsxs("div",{className:"border-t border-gray-200 pt-4",children:[e.jsxs("p",{className:"text-xs font-semibold text-gray-900 uppercase tracking-wide mb-1",children:["Q",a.number," · ",a.type," · ",a.marks," marks"]}),e.jsx("p",{className:"text-sm text-gray-900 mb-2",children:a.question}),e.jsx(C,{value:a.questionTe,onChange:x=>O(a.number,x),placeholder:"Telugu question",rows:3}),a.options.length>0&&e.jsx("div",{className:"mt-3 space-y-2",children:a.options.map((x,l)=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 items-start",children:[e.jsx("div",{className:"text-sm px-3 py-2 rounded-lg border bg-white border-gray-200 text-gray-900",children:x}),e.jsx(C,{value:(a.optionsTe.length===a.options.length?a.optionsTe[l]:"")??"",onChange:u=>y(a.number,l,u),placeholder:`Telugu for option ${l+1}`,rows:1})]},l))})]},a.number)),N&&e.jsxs("div",{className:"flex items-start gap-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2",children:[e.jsx(Y,{size:15,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:N})]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap sticky bottom-0 bg-gray-50/95 py-2",children:[e.jsx("button",{onClick:n,disabled:m||!I,className:"bg-indigo-600 hover:bg-indigo-700 disabled:bg-gray-300 text-white text-sm font-medium px-4 py-2 rounded-lg transition-colors",children:m?"Saving…":"Save & mark reviewed"}),s.reviewed&&e.jsxs("button",{onClick:v,disabled:m,title:"Removes the reviewed mark. Your wording stays until the next content update, which then restores the original Telugu.",className:"flex items-center gap-1.5 text-sm text-gray-900 hover:text-gray-800 px-3 py-2 rounded-lg hover:bg-gray-100 transition-colors",children:[e.jsx(_,{size:14})," Unmark reviewed"]}),T&&e.jsx("span",{className:"text-sm text-emerald-600 font-medium",children:"Saved"}),s.reviewed&&s.reviewerName&&e.jsxs("span",{className:"text-xs text-gray-900 ml-auto",children:["Last edited by ",s.reviewerName]})]})]})]})}function xe(){const[s,g]=r.useState("quizzes"),[b,w]=r.useState(null),[i,q]=r.useState("all"),[d,R]=r.useState("all"),[c,E]=r.useState(""),[m,h]=r.useState(""),[N,p]=r.useState([]),[T,S]=r.useState(0),[I,O]=r.useState(0),[y,n]=r.useState(0),[v,$]=r.useState([]),[a,x]=r.useState(!0);r.useEffect(()=>{const t=setTimeout(()=>h(c),300);return()=>clearTimeout(t)},[c]),r.useEffect(()=>{n(0)},[s,i,d,m]);const l=r.useCallback(()=>{k.get("/admin/translations/summary").then(t=>w(t.data)).catch(()=>w(null))},[]);r.useEffect(l,[l]),r.useEffect(()=>{let t=!1;x(!0);const o=new URLSearchParams;return i!=="all"&&o.set("courseId",String(i)),d!=="all"&&o.set("status",d),s==="quizzes"?(m&&o.set("search",m),o.set("limit",String(F)),o.set("offset",String(y*F)),k.get(`/admin/translations/quizzes?${o}`).then(j=>{t||(p(j.data.items),S(j.data.total),O(j.data.reviewedTotal??0))}).finally(()=>!t&&x(!1))):k.get(`/admin/translations/assignments?${o}`).then(j=>{t||$(j.data.items)}).finally(()=>!t&&x(!1)),()=>{t=!0}},[s,i,d,m,y]);const u=s==="quizzes"?b?.quizzes??[]:b?.assignments??[],f=r.useMemo(()=>u.reduce((t,o)=>({total:t.total+o.total,reviewed:t.reviewed+o.reviewed}),{total:0,reviewed:0}),[u]),P=r.useCallback((t,o)=>{p(j=>j.map(z=>z.id===t?{...z,...o}:z)),l()},[l]),Q=r.useCallback((t,o)=>{$(j=>j.map(z=>z.id===t?{...z,...o}:z)),l()},[l]),A=Math.ceil(T/F);return e.jsx(G,{children:e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 flex items-center gap-2",children:[e.jsx(D,{size:22,className:"text-indigo-600"})," Telugu review"]}),e.jsx("p",{className:"text-sm text-gray-900 mt-0.5",children:"Correct the Telugu wording students see. English text and correct answers are fixed here — marking is unaffected, and reviewed items keep your wording through future updates."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>g("quizzes"),className:`flex items-center gap-2 text-sm font-medium px-4 py-2 rounded-lg transition-colors ${s==="quizzes"?"bg-indigo-600 text-white":"bg-white text-gray-900 border border-gray-200 hover:bg-gray-50"}`,children:[e.jsx(Z,{size:15})," Quiz questions"]}),e.jsxs("button",{onClick:()=>g("assignments"),className:`flex items-center gap-2 text-sm font-medium px-4 py-2 rounded-lg transition-colors ${s==="assignments"?"bg-indigo-600 text-white":"bg-white text-gray-900 border border-gray-200 hover:bg-gray-50"}`,children:[e.jsx(M,{size:15})," Assignment papers"]})]}),u.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 ga
1p-3",children:u.map(t=>e.jsx(V,{stat:t},t.courseId))}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-md",children:[e.jsx(H,{size:15,className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-900"}),e.jsx("input",{value:c,onChange:t=>E(t.target.value),placeholder:s==="quizzes"?"Search English or Telugu…":"Search is available on quiz questions",disabled:s==="assignments",className:"w-full pl-9 pr-4 py-2 border border-gray-200 rounded-lg text-sm text-gray-900 placeholder:text-gray-500 focus:outline-none focus:ring-2 focus:ring-indigo-200 disabled:bg-gray-50 disabled:text-gray-600"})]}),e.jsxs("select",{value:i,onChange:t=>q(t.target.value==="all"?"all":Number(t.target.value)),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-900 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-200",children:[e.jsx("option",{value:"all",children:"All courses"}),u.map(t=>e.jsx("option",{value:t.courseId,children:t.courseTitle},t.courseId))]}),e.jsxs("select",{value:d,onChange:t=>R(t.target.value),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm text-gray-900 bg-white focus:outline-none focus:ring-2 focus:ring-indigo-200",children:[e.jsx("option",{value:"all",children:"All items"}),e.jsx("option",{value:"pending",children:"Needs review"}),e.jsx("option",{value:"reviewed",children:"Reviewed"})]}),e.jsx("span",{className:"text-sm text-gray-900 ml-auto",children:s==="quizzes"?`${I} of ${T} reviewed`:`${f.reviewed} of ${f.total} reviewed`})]}),a?e.jsx("div",{className:"space-y-3",children:Array.from({length:6}).map((t,o)=>e.jsxs("div",{className:"bg-white rounded-xl p-4 shadow-sm border border-gray-100",children:[e.jsx(L,{className:"h-3 w-24 bg-gray-100 mb-2"}),e.jsx(L,{className:"h-4 w-3/4 bg-gray-100 mb-1.5"}),e.jsx(L,{className:"h-4 w-2/3 bg-gray-100"})]},o))}):s==="quizzes"?N.length===0?e.jsxs("div",{className:"bg-white rounded-xl p-12 text-center shadow-sm border border-gray-100",children:[e.jsx(D,{size:36,className:"text-gray-900 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-900 text-sm",children:"No quiz questions match these filters"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-3",children:N.map(t=>e.jsx(W,{item:t,onSaved:P},t.id))}),A>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3 pt-2",children:[e.jsx("button",{onClick:()=>n(t=>Math.max(t-1,0)),disabled:y===0,className:"px-3 py-1.5 text-sm border border-gray-200 rounded-lg bg-white disabled:text-gray-600 hover:bg-gray-50",children:"Previous"}),e.jsxs("span",{className:"text-sm text-gray-900",children:["Page ",y+1," of ",A]}),e.jsx("button",{onClick:()=>n(t=>Math.min(t+1,A-1)),disabled:y>=A-1,className:"px-3 py-1.5 text-sm border border-gray-200 rounded-lg bg-white disabled:text-gray-600 hover:bg-gray-50",children:"Next"})]})]}):v.length===0?e.jsxs("div",{className:"bg-white rounded-xl p-12 text-center shadow-sm border border-gray-100",children:[e.jsx(M,{size:36,className:"text-gray-900 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-900 text-sm",children:"No assignment papers match these filters"})]}):e.jsx("div",{className:"space-y-3",children:v.map(t=>e.jsx(X,{item:t,onSaved:Q},t.id))})]})})}export{xe as default};

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.