PageSourceSearch

https://limpopomirror.co.za/assets/ProgressReport-DUbGyFYo.js

js limpopomirror.co.za collected 2026-09-24 23:45:30 UTC 13,087 bytes, 6 lines download raw bytes

1import{Y as se,j as e,l as ae,n as te,r as l,o as Y,s as w,af as F,cz as p,am as re,B as d,aL as q,aM as L,bs as ne,J as x,ad as ie,ah as G,dm as O,X as le,an as oe,ao as ce,ap as I,aq as S,ar as de,as as v,dt as me,aj as he,a_ as ge,a$ as pe,bE as ue,b0 as xe,bF as je,aS as J,aT as fe,bK as be,bu as Ne,du as ve}from"./admin-gOTFpfvz.js";const we=()=>{const{user:m,session:h}=ae(),j=te();l.useEffect(()=>{document.title="Progress Report - Limpopo Mirror"},[]);const[i,k]=l.useState(""),[g,D]=l.useState(""),[n,r]=l.useState(!1),[o,b]=l.useState(null),[u,f]=l.useState({title:"",description:"",period_label:"",change_date:""}),[Z,E]=l.useState(!1),[N,_]=l.useState([]),[P,$]=l.useState(null),[R,A]=l.useState(!1),{data:M=[],isLoading:K}=Y({queryKey:["changelog-entries",i,g],queryFn:async()=>{let s=w.from("changelog_entries").select("*").order("change_date",{ascending:!1});i&&(s=s.gte("change_date",i)),g&&(s=s.lte("change_date",g));const{data:a,error:t}=await s;if(t)throw t;return a}}),B=F({mutationFn:async s=>{if(s.id){const{error:a}=await w.from("changelog_entries").update({title:s.title,description:s.description,period_label:s.period_label,change_date:s.change_date}).eq("id",s.id);if(a)throw a}else{const{error:a}=await w.from("changelog_entries").insert({title:s.title,description:s.description,period_label:s.period_label,change_date:s.change_date,created_by:m==null?void 0:m.id});if(a)throw a}},onSuccess:()=>{j.invalidateQueries({queryKey:["changelog-entries"]}),r(!1),b(null),f({title:"",description:"",period_label:"",change_date:""}),p.success("Entry saved")},onError:s=>p.error(s.message)}),Q=F({mutationFn:async s=>{const{error:a}=await w.from("changelog_entries").delete().eq("id",s);if(a)throw a},onSuccess:()=>{j.invalidateQueries({queryKey:["changelog-entries"]}),p.success("Entry deleted")}}),U=s=>{b(s.id),f({title:s.title,description:s.description,period_label:s.period_label,change_date:s.change_date}),r(!0)},X=()=>{const s=new URLSearchParams;i&&s.set("from",i),g&&s.set("to",g);const a=s.toString();window.open(`/progress-report${a?`?${a}`:""}`,"_blank")},H=async()=>{if(!(h!=null&&h.access_token)){p.error("You must be logged in");return}A(!0);try{const s=await fetch("https://pcadhrcghlhjosreajvb.supabase.co/functions/v1/generate-changelog-entries",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${h.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InBjYWRocmNnaGxoam9zcmVhanZiIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjYwMDM2ODksImV4cCI6MjA4MTU3OTY4OX0.xWq8-pRccua9Ml0u7YC_zKzZUPHbmXikdnYFAKhGtF0"},body:JSON.stringify({})}),a=await s.json();if(!s.ok){p.error(a.error||"Failed to generate entries");return}if(!a.entries||a.entries.length===0){p.info(a.message||"No new changes found to document.");return}_(a.entries.map(t=>({...t,selected:!0}))),$({since_date:a.since_date,migrations_analyzed:a.migrations_analyzed}),E(!0)}catch(s){console.error("Generation error:",s),p.error("Failed to connect to AI service")}finally{A(!1)}},V=s=>{_(a=>a.map(t=>({...t,selected:s})))},W=s=>{_(a=>a.map((t,c)=>c===s?{...t,selected:!t.selected}:t))},y=(s,a,t)=>{_(c=>c.map((z,ee)=>ee===s?{...z,[a]:t}:z))},T=F({mutationFn:async()=>{const s=N.filter(c=>c.selected);if(s.length===0)throw new Error("No entries selected");const a=s.map(c=>({title:c.title,description:c.description,change_date:c.change_date,period_label:c.period_label,is_major:c.is_major,created_by:m==null?void 0:m.id})),{error:t}=await w.from("changelog_entries").insert(a);if(t)throw t;return s.length},onSuccess:s=>{j.invalidateQueries({queryKey:["changelog-entries"]}),E(!1),_([]),p.success(`${s} changelog entries saved`)},onError:s=>p.error(s.message)}),C=N.filter(s=>s.selected).length;return e.jsxs(re,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Changelog Entries"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage development milestones and generate printable reports."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(d,{variant:"outline",onClick:H,disabled:R,className:"gap-2",children:[R?e.jsx(q,{className:"h-4 w-4 animate-spin"}):e.jsx(L,{className:"h-4 w-4"}),"Generate To Date"]}),e.jsxs(d,{onClick:X,className:"gap-2",children:[e.jsx(ne,{className:"h-4 w-4"}),"Generate Report"]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap p-4 border border-border rounded-lg bg-card",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"From:"}),e.jsx(x,{type:"date",value:i,onChange:s=>k(s.target.value),className:"w-44"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"To:"}),e.jsx(x,{type:"date",value:g,onChange:s=>D(s.target.value),className:"w-44"})]}),e.jsx(d,{variant:"outline",size:"sm",onClick:()=>{k(""),D("")},children:"Clear"}),e.jsx("div",{className:"ml-auto",children:e.jsxs(d,{size:"sm",onClick:()=>{r(!0),b(null),f({title:"",description:"",period_label:"",change_date:new Date().toISOString().split("T")[0]})},children:[e.jsx(ie,{className:"h-4 w-4 mr-1"})," Add Entry"]})})]}),n&&e.jsxs("div",{className:"border border-border rounded-lg p-4 space-y-3 bg-card",children:[e.jsx("h3",{className:"font-medium text-sm",children:o?"Edit Entry":"New Entry"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(x,{placeholder:"Title",value:u.title,onChange:s=>
1f(a=>({...a,title:s.target.value}))}),e.jsx(x,{placeholder:"Period label (e.g. Early March 2026)",value:u.period_label,onChange:s=>f(a=>({...a,period_label:s.target.value}))})]}),e.jsx(G,{placeholder:"Description",value:u.description,onChange:s=>f(a=>({...a,description:s.target.value}))}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(x,{type:"date",value:u.change_date,onChange:s=>f(a=>({...a,change_date:s.target.value})),className:"w-44"}),e.jsxs(d,{size:"sm",onClick:()=>B.mutate({...u,id:o||void 0}),disabled:!u.title||!u.description||!u.period_label,children:[e.jsx(O,{className:"h-4 w-4 mr-1"})," ",o?"Update":"Save"]}),e.jsxs(d,{variant:"ghost",size:"sm",onClick:()=>{r(!1),b(null)},children:[e.jsx(le,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]}),K?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs(oe,{children:[e.jsx(ce,{children:e.jsxs(I,{children:[e.jsx(S,{children:"Date"}),e.jsx(S,{children:"Period"}),e.jsx(S,{children:"Title"}),e.jsx(S,{className:"hidden md:table-cell",children:"Description"}),e.jsx(S,{className:"w-20",children:"Actions"})]})}),e.jsxs(de,{children:[M.map(s=>e.jsxs(I,{children:[e.jsx(v,{className:"whitespace-nowrap text-sm",children:s.change_date}),e.jsx(v,{className:"text-sm",children:s.period_label}),e.jsxs(v,{className:"font-medium text-sm",children:[s.is_major&&e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-primary mr-2"}),s.title]}),e.jsx(v,{className:"hidden md:table-cell text-sm text-muted-foreground max-w-xs truncate",children:s.description}),e.jsx(v,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(d,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>U(s),children:e.jsx(me,{className:"h-3 w-3"})}),e.jsx(d,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>Q.mutate(s.id),children:e.jsx(he,{className:"h-3 w-3"})})]})})]},s.id)),!M.length&&e.jsx(I,{children:e.jsx(v,{colSpan:5,className:"text-center text-muted-foreground py-8",children:"No entries found. Add your first changelog entry above."})})]})]})]}),e.jsx(ge,{open:Z,onOpenChange:E,children:e.jsxs(pe,{className:"max-w-4xl max-h-[85vh] overflow-y-auto",children:[e.jsxs(ue,{children:[e.jsxs(xe,{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-5 w-5 text-primary"}),"Review AI-Generated Entries"]}),e.jsx(je,{children:P&&e.jsxs(e.Fragment,{children:["Analyzed ",P.migrations_analyzed," migrations since"," ",new Date(P.since_date).toLocaleDateString("en-ZA",{day:"numeric",month:"long",year:"numeric"}),". Review, edit, and select entries to save."]})})]}),e.jsx("div",{className:"space-y-1 mb-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium cursor-pointer",children:[e.jsx(J,{checked:C===N.length&&N.length>0,onCheckedChange:s=>V(!!s)}),"Select All (",C,"/",N.length,")"]})})}),e.jsx("div",{className:"space-y-4",children:N.map((s,a)=>e.jsx("div",{className:`border rounded-lg p-4 space-y-3 transition-opacity ${s.selected?"border-border bg-card":"border-border/50 bg-muted/30 opacity-60"}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(J,{checked:s.selected,onCheckedChange:()=>W(a),className:"mt-1"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:[e.jsx(x,{value:s.title,onChange:t=>y(a,"title",t.target.value),placeholder:"Title",className:"font-medium"}),e.jsx(x,{value:s.period_label,onChange:t=>y(a,"period_label",t.target.value),placeholder:"Period label"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{type:"date",value:s.change_date,onChange:t=>y(a,"change_date",t.target.value)}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(fe,{checked:s.is_major,onCheckedChange:t=>y(a,"is_major",t)}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:"Major"})]})]})]}),e.jsx(G,{value:s.description,onChange:t=>y(a,"description",t.target.value),rows:2,className:"text-sm"})]})]})},a))}),e.jsxs(be,{className:"mt-4",children:[e.jsx(d,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),e.jsxs(d,{onClick:()=>T.mutate(),disabled:C===0||T.isPending,children:[T.isPending?e.jsx(q,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(O,{className:"h-4 w-4 mr-2"}),"Save ",C," ",C===1?"Entry":"Entries"]})]})]})})]})},_e=()=>{const[m]=Ne(),h=m.get("from")||"",j=m.get("to")||"",{data:i=[],isLoading:k}=Y({queryKey:["changelog-report",h,j],queryFn:async()=>{let n=w.from("changelog_entries").select("*").order("change_date",{ascending:!0});h&&(n=n.gte("change_date",h)),j&&(n=n.lte("change_date",j));const{data:r,error:o}=await n;if(o)throw o;return r}}),g=l.useMemo(()=>{const n={};
1return i.forEach(r=>{n[r.period_label]||(n[r.period_label]=[]),n[r.period_label].push(r)}),Object.entries(n).map(([r,o])=>({period:r,items:o}))},[i]),D=l.useMemo(()=>{if(!i.length)return"";const n=new Date(i[0].change_date),r=new Date(i[i.length-1].change_date),o=b=>b.toLocaleDateString("en-ZA",{day:"numeric",month:"long",year:"numeric"});return`${o(n)} – ${o(r)}`},[i]);return e.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[e.jsxs("div",{className:"max-w-3xl mx-auto px-8 py-12 print:px-0 print:py-0",children:[e.jsx("div",{className:"print:hidden mb-8 flex justify-end",children:e.jsxs(d,{onClick:()=>window.print(),className:"gap-2",children:[e.jsx(ve,{className:"h-4 w-4"}),"Print / Save as PDF"]})}),e.jsxs("header",{className:"mb-10 border-b border-border pb-8",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight mb-2",children:"Zoutnet Development Progress Report"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:D||"All entries"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Major functional changes, new features, and critical bug fixes."})]}),k?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"})}):e.jsxs("div",{className:"space-y-10",children:[g.map(n=>e.jsxs("section",{children:[e.jsx("h2",{className:"text-xl font-bold mb-4 text-primary",children:n.period}),e.jsx("div",{className:"space-y-4",children:n.items.map(r=>e.jsxs("div",{className:"border-l-2 border-accent pl-4",children:[e.jsx("h3",{className:"font-semibold text-base",children:r.title}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed mt-1",children:r.description})]},r.id))})]},n.period)),!g.length&&e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No changelog entries found for the selected period."})]}),e.jsx("footer",{className:"mt-12 pt-6 border-t border-border text-sm text-muted-foreground",children:e.jsxs("p",{children:["Report generated on ",new Date().toLocaleDateString("en-ZA",{day:"numeric",month:"long",year:"numeric"}),". This document covers significant platform changes only; minor UI adjustments and routine maintenance are excluded."]})})]}),e.jsx("style",{children:`
2        @media print {
3          body { background: white !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
4          @page { margin: 2cm; size: A4; }
5        }
6      `})]})},Ce=()=>se().pathname.startsWith("/admin")?e.jsx(we,{}):e.jsx(_e,{});export{Ce 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.