(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[568],{7263:(e,t,a)=>{"use strict";a.d(t,{NotesPage:()=>i});var l=a(8111),s=a(5271),d=a(8719);function r(e){return e?new Date(e).toLocaleString("de-DE",{day:"2-digit",month:"2-digit",year:"2-digit",hour:"2-digit",minute:"2-digit"}):"—"}function i(){let{client:e}=(0,d.U)(),[t,a]=(0,s.useState)([]),[i,n]=(0,s.useState)(!0),[o,c]=(0,s.useState)(""),[x,u]=(0,s.useState)(null),[b,m]=(0,s.useState)(!1),[h,f]=(0,s.useState)(""),[p,g]=(0,s.useState)(""),N=(0,s.useCallback)(async()=>{if(e){n(!0);try{let t=await e.fetchNotes({query:o||void 0,limit:200});a(t)}finally{n(!1)}}},[e,o]);async function y(){if(e&&h.trim()&&p.trim()){if(x){let t=await e.updateNote(x.id,{title:h.trim(),content:p});t&&(a(e=>e.map(e=>e.id===x.id?t:e)),u(t))}else{let t=await e.addNote({title:h.trim(),content:p});t&&(a(e=>[t,...e]),u(t))}m(!1)}}async function v(t){e&&confirm('Notiz "'.concat(t.title,'" wirklich l\xf6schen?'))&&await e.deleteNote(t.id)&&(a(e=>e.filter(e=>e.id!==t.id)),(null==x?void 0:x.id)===t.id&&(u(null),m(!1)))}return(0,s.useEffect)(()=>{N()},[N]),(0,l.jsxs)("div",{className:"flex h-full",children:[(0,l.jsxs)("div",{className:"w-72 border-r border-[#1f1f1f] flex flex-col",children:[(0,l.jsxs)("div",{className:"p-3 border-b border-[#1f1f1f]",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,l.jsx)("h1",{className:"text-base font-semibold text-gray-100",children:"Notes"}),(0,l.jsx)("button",{onClick:function(){u(null),f(""),g(""),m(!0)},className:"text-xs px-2 py-0.5 bg-blue-600 hover:bg-blue-500 text-white rounded",children:"+ Neu"})]}),(0,l.jsx)("input",{value:o,onChange:e=>c(e.target.value),placeholder:"Suchen …",className:"w-full bg-[#0d0d0d] border border-[#2a2a2a] rounded px-2 py-1 text-xs text-gray-200 focus:outline-none focus:border-blue-500"})]}),(0,l.jsxs)("div",{className:"flex-1 overflow-y-auto p-1.5",children:[i&&(0,l.jsx)("div",{className:"text-gray-500 text-xs italic p-2",children:"Lade…"}),!i&&0===t.length&&(0,l.jsx)("div",{className:"text-gray-500 text-xs italic p-2",children:"Keine Notizen."}),t.map(e=>(0,l.jsxs)("button",{onClick:()=>{u(e),m(!1)},className:"w-full text-left p-2 rounded mb-1 border ".concat((null==x?void 0:x.id)===e.id?"bg-blue-500/10 border-blue-500/40":"border-transparent hover:bg-[#141414]"),children:[(0,l.jsx)("div",{className:"text-sm text-gray-200 font-medium truncate",children:e.title}),(0,l.jsx)("div",{className:"text-[10px] text-gray-500 mt-0.5",children:r(e.updatedAt)}),(0,l.jsx)("div",{className:"text-[11px] text-gray-400 mt-0.5 line-clamp-2",children:e.content.slice(0,100)})]},e.id))]})]}),(0,l.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[!x&&!b&&(0,l.jsx)("div",{className:"text-gray-500 text-sm text-center mt-12",children:"W\xe4hle eine Notiz aus der Liste links oder erstelle eine neue."}),b&&(0,l.jsxs)("div",{className:"max-w-3xl space-y-3",children:[(0,l.jsx)("input",{value:h,onChange:e=>f(e.target.value),placeholder:"Titel",className:"w-full bg-[#0d0d0d] border border-[#2a2a2a] rounded px-3 py-2 text-lg text-gray-100 font-medium focus:outline-none focus:border-blue-500"}),(0,l.jsx)("textarea",{value:p,onChange:e=>g(e.target.value),placeholder:"Inhalt …",rows:20,className:"w-full bg-[#0d0d0d] border border-[#2a2a2a] rounded px-3 py-2 text-sm text-gray-200 font-mono focus:outline-none focus:border-blue-500 resize-y"}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)("button",{onClick:y,disabled:!h.trim()||!p.trim(),className:"px-4 py-1.5 bg-blue-600 hover:bg-blue-500 disabled:opacity-40 text-white rounded text-sm font-semibold",children:"Speichern"}),(0,l.jsx)("button",{onClick:()=>{m(!1),x||(f(""),g(""))},className:"px-3 py-1.5 bg-[#1a1a1a] text-gray-400 rounded border border-[#2a2a2a] text-sm",children:"Abbrechen"})]})]}),x&&!b&&(0,l.jsxs)("div",{className:"max-w-3xl",children:[(0,l.jsxs)("div",{className:"flex items-start justify-between gap-3 mb-2",children:[(0,l.jsx)("h2",{className:"text-2xl font-bold text-gray-100",children:x.title}),(0,l.jsxs)("div",{className:"flex gap-1.5",children:[(0,l.jsx)("button",{onClick:()=>{u(x),f(x.title),g(x.content),m(!0)},className:"px-2 py-1 bg-blue-500/10 text-blue-400 border border-blue-500/40 rounded text-xs",children:"✎ Edit"}),(0,l.jsx)("button",{onClick:()=>v(x),className:"px-2 py-1 bg-red-500/10 text-red-400 border border-red-500/40 rounded text-xs",children:"\uD83D\uDDD1 L\xf6schen"})]})]}),(0,l.jsxs)("div",{className:"text-[11px] text-gray-500 mb-3",children:["Erstellt: ",r(x.createdAt),x.updatedAt!==x.createdAt&&" \xb7 Aktualisiert: ".concat(r(x.updatedAt))]}),(0,l.jsx)("div",{className:"text-sm text-gray-300 whitespace-pre-wrap font-mono bg-[#0d0d0d] border border-[#1f1f1f] rounded p-3",children:x.content})]})]})]})}},7875:(e,t,a)=>{Promise.resolve().then(a.bind(a,7263))}},e=>{e.O(0,[719,814,743,358],()=>e(e.s=7875)),_N_E=e.O()}]);