PageSourceSearch

https://riederalm.lovable.app/assets/ReceptionMPDashboard-DfjLL2LC.js

js riederalm.lovable.app collected 2026-10-03 03:44:59 UTC 8,262 bytes, 1 lines download raw bytes

1import{j as e,r as g,u as q}from"./react-vendor-CShGlGts.js";import{a7 as E,a9 as z,s as m,aY as F,ak as k,t as x,al as M,B as w,aa as W,C as p,ae as b,af as y,a as C,aH as K,w as P,es as B,aU as V,aV as H}from"./index-BYC0bmF9.js";import{C as L}from"./calendar-ChaNdtnx.js";import{D as R}from"./DualStatusDots-CqngL06E.js";import{u as U}from"./useMenuApprovalStatus-BQUIx04E.js";import{M as Y}from"./MorgenpostChangesPanel-4chZqq2t.js";import{P as G}from"./play-C5QreMYP.js";import{S as D}from"./square-pen-C1ki5aDA.js";import"./query-BUBuIGkW.js";import"./shared-utils--gW9Kwo0.js";import"./supabase-C0joAID3.js";import"./index.esm-DLTvrltQ.js";import"./subDays-DZPLfhSR.js";import"./startOfMonth-B-rb6ulI.js";import"./addMonths-CxZqvFR-.js";import"./isSameMonth-CQvZjdv-.js";import"./setMonth-QYDt0UIt.js";import"./getDaysInMonth-DIbTKDm9.js";import"./isSameDay-C8GttKCU.js";const J=({status:s})=>{const a={draft:{variant:"outline",text:"Entwurf",color:"text-muted-foreground"},in_progress:{variant:"secondary",text:"In Bearbeitung",color:"text-yellow-600"},completed:{variant:"default",text:"Fertig",color:"text-green-600"},published:{variant:"default",text:"Veröffentlicht",color:"text-blue-600"},ready_for_print:{variant:"default",text:"Druckbereit",color:"text-purple-600"}},n=a[s]||a.draft;return e.jsx(E,{variant:n.variant,className:n.color,children:n.text})},Q=({changeCount:s,className:a})=>s===0?null:e.jsxs(E,{variant:"destructive",className:a,children:[e.jsx(z,{className:"h-3 w-3 mr-1"}),s," Änderung",s!==1?"en":""," seit Freigabe"]}),X=s=>{const[a,n]=g.useState({changes:[],modifiedAfterApproval:!1,receptionNotified:!1,loading:!0});return g.useEffect(()=>{const f=async()=>{try{const{data:i,error:j}=await m.from("morgenpost_entries").select("changes_after_approval, modified_after_mp_approval, last_change_at, reception_notified").eq("datum",s).maybeSingle();if(j)throw j;if(i){const o=Array.isArray(i.changes_after_approval)?i.changes_after_approval:[];n({changes:o,modifiedAfterApproval:i.modified_after_mp_approval||!1,lastChangeAt:i.last_change_at||void 0,receptionNotified:i.reception_notified||!1,loading:!1})}else n({changes:[],modifiedAfterApproval:!1,receptionNotified:!1,loading:!1})}catch(i){console.error("Error loading change tracking data:",i),n({changes:[],modifiedAfterApproval:!1,receptionNotified:!1,loading:!1})}};f();const h=m.channel(`morgenpost_changes_${s}`).on("postgres_changes",{event:"*",schema:"public",table:"morgenpost_entries",filter:`datum=eq.${s}`},()=>f()).subscribe();return()=>{m.removeChannel(h)}},[s]),a};function ve(){const s=q(),{toast:a}=F(),[n,f]=g.useState(new Date),[h,i]=g.useState([]),[j,o]=g.useState(!1);g.useEffect(()=>{v()},[n]);const v=async()=>{o(!0);try{const t=k(n,{weekStartsOn:1}),r=Array.from({length:7},(d,$)=>x(M(t,$),"yyyy-MM-dd")),{data:c,error:u}=await m.from("morgenpost_entries").select("id, datum, status, erstellt_am, erstellt_von, begruessung_de, begruessung_en").in("datum",r);if(u)throw u;const l=new Map(c?.map(d=>[d.datum,d])||[]),T=r.map(d=>({date:d,status:l.get(d)?.status||"entwurf",id:l.get(d)?.id,title_de:l.get(d)?.begruessung_de,title_en:l.get(d)?.begruessung_en,started_at:l.get(d)?.erstellt_am,completed_at:void 0}));i(T)}catch(t){console.error("Error loading week posts:",t),a({title:"Fehler",description:"Konnte MPs nicht laden",variant:"destructive"})}finally{o(!1)}},S=async t=>{try{const{data:r}=await m.auth.getSession(),c=r?.session?.user?.id,{data:u}=await m.from("morgenpost_entries").select("*").eq("datum",t).maybeSingle();if(u){const{error:l}=await m.from("morgenpost_entries").update({status:"entwurf",erstellt_am:new Date().toISOString(),erstellt_von:c}).eq("id",u.id);if(l)throw l}else{const{error:l}=await m.from("morgenpost_entries").insert({datum:t,status:"entwurf",erstellt_am:new Date().toISOString(),erstellt_von:c});if(l)throw l}a({title:"Erfolg",description:"MP wurde gestartet"}),s(`/morgenpost?date=${t}`)}catch(r){console.error("Error starting MP:",r),a({title:"Fehler",description:"Konnte MP nicht starten",variant:"destructive"})}},A=t=>{s(`/morgenpost?date=${t}`)},I=t=>{s(`/morgenpost?date=${t}`)},N=k(n,{weekStartsOn:1}
1),O=Array.from({length:7},(t,r)=>M(N,r)),_=h.reduce((t,r)=>(t[r.status]=(t[r.status]||0)+1,t),{});return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(w,{variant:"ghost",size:"icon",onClick:()=>s("/reception"),children:e.jsx(W,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Morgenpost Dashboard"}),e.jsx("p",{className:"text-muted-foreground",children:"Verwalte deine Morgenposts"})]})]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(p,{children:[e.jsx(b,{className:"pb-2",children:e.jsx(y,{className:"text-sm font-medium text-muted-foreground",children:"Entwürfe"})}),e.jsx(C,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.entwurf||0})})]}),e.jsxs(p,{children:[e.jsx(b,{className:"pb-2",children:e.jsx(y,{className:"text-sm font-medium text-muted-foreground",children:"In Bearbeitung"})}),e.jsx(C,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.in_bearbeitung||0})})]}),e.jsxs(p,{children:[e.jsx(b,{className:"pb-2",children:e.jsx(y,{className:"text-sm font-medium text-muted-foreground",children:"Fertig"})}),e.jsx(C,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.fertig||0})})]}),e.jsxs(p,{children:[e.jsx(b,{className:"pb-2",children:e.jsx(y,{className:"text-sm font-medium text-muted-foreground",children:"Veröffentlicht"})}),e.jsx(C,{children:e.jsx("div",{className:"text-2xl font-bold",children:_.veroeffentlicht||0})})]})]}),e.jsxs("div",{className:"grid gap-6 lg:grid-cols-[300px_1fr]",children:[e.jsxs(p,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(K,{className:"h-5 w-5"}),e.jsx("h2",{className:"font-semibold",children:"Kalender"})]}),e.jsx(L,{mode:"single",selected:n,onSelect:t=>t&&f(t),locale:P,className:"rounded-md"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-xl font-semibold",children:["KW ",x(N,"ww, yyyy")]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[x(N,"dd.MM.")," - ",x(M(N,6),"dd.MM.yyyy")]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:O.map(t=>{const r=B(t),c=h.find(u=>u.date===r);return e.jsx(Z,{day:t,dayPost:c,onAction:()=>{c?.status==="fertig"||c?.status==="veroeffentlicht"?I(r):c?.status==="entwurf"||c?.status==="in_bearbeitung"?A(r):S(r)}},r)})})]})]})]})}const Z=({day:s,dayPost:a,onAction:n})=>{const f=B(s),{mpApproved:h,amApproved:i,loading:j}=U(f),o=X(f),[v,S]=g.useState(!1),A=()=>!a||a.status==="entwurf"?e.jsxs(w,{onClick:n,className:"w-full",variant:"default",size:"sm",children:[e.jsx(G,{className:"h-4 w-4 mr-2"}),"MP starten"]}):a.status==="fertig"||a.status==="veroeffentlicht"?e.jsxs(w,{onClick:n,variant:"secondary",className:"w-full",size:"sm",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Bearbeiten"]}):e.jsxs(w,{onClick:n,variant:"outline",className:"w-full",size:"sm",children:[e.jsx(D,{className:"h-4 w-4 mr-2"}),"Weiter bearbeiten"]});return e.jsx(p,{className:"p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:x(s,"EEEE",{locale:P})}),e.jsx("div",{className:"text-lg font-semibold",children:x(s,"dd.MM.yyyy")})]}),!j&&e.jsx(R,{mpApproved:h,amApproved:i})]}),a&&a.status!=="entwurf"&&e.jsx(J,{status:a.status}),!o.loading&&o.modifiedAfterApproval&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(w,{variant:"ghost",size:"sm",className:"w-full justify-between",onClick:()=>S(!v),children:[e.jsx(Q,{changeCount:o.changes.length}),v?e.jsx(V,{className:"h-4 w-4"}):e.jsx(H,{className:"h-4 w-4"})]}),v&&e.jsx("div",{className:"pt-2",children:e.jsx(Y,{changes:o.changes,lastChangeAt:o.lastChangeAt,receptionNotified:o.receptionNotified})})]}),A()]})})};export{ve 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.