1import{r as l,j as e}from"./index-CiU28txl.js";import{u as E}from"./useImpersonation-Bci6Rvke.js";const L={de:{title:"Budget",alerts:"Budget-Benachrichtigungen",alertsDesc:"Erhalte eine Benachrichtigung, wenn dein Budget einen Schwellenwert erreicht.",emailNotify:"E-Mail",dailyLimit:"Tägliches Limit",dailyLimitDesc:"Maximaler Tagesbetrag aus deinem Wallet-Mandat.",noCents:"Kein Limit gesetzt",mandate:"Aktives Mandat",budget:"Budget",spent:"Ausgegeben",remaining:"Verbleibend",noMandate:"Kein aktives Wallet-Mandat vorhanden.",saving:"Speichern...",saved:"Gespeichert",error:"Fehler beim Speichern",loading:"Lädtâ¦"},en:{title:"Budget",alerts:"Budget Alerts",alertsDesc:"Get notified when your budget reaches a threshold.",emailNotify:"Email",dailyLimit:"Daily Limit",dailyLimitDesc:"Maximum daily spend from your wallet mandate.",noCents:"No limit set",mandate:"Active Mandate",budget:"Budget",spent:"Spent",remaining:"Remaining",noMandate:"No active wallet mandate.",saving:"Saving...",saved:"Saved",error:"Error saving",loading:"Loading..."}},k=[50,80,100];function M(){const{apiFetch:o}=E(),[f]=l.useState("de"),t=L[f],[y,x]=l.useState([]),[n,j]=l.useState(null),[v,N]=l.useState(!0),[u,d]=l.useState(null);l.useEffect(()=>{(async()=>{try{const[a,r]=await Promise.all([o("/api/account/budget-alerts"),o("/api/account/wallet-settings")]);if(a.ok){const i=await a.json();x(Array.isArray(i.alerts)?i.alerts:[])}if(r.ok){const i=await r.json();j(i.mandate)}}catch{}finally{N(!1)}})()},[o]);const g=s=>y.find(a=>a.thresholdPct===s),h=async(s,a)=>{const i=g(s)??{thresholdPct:s,enabled:!0,notifyEmail:!0},b={...i,[a]:!i[a]};d(t.saving);try{const p=await o("/api/account/budget-alerts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({thresholdPct:s,enabled:b.enabled,notifyEmail:b.notifyEmail})});if(p.ok){const w=await p.json();x(S=>[...S.filter(m=>m.thresholdPct!==s),w.alert].sort((m,C)=>m.thresholdPct-C.thresholdPct)),d(t.saved)}else d(t.error)}catch{d(t.error)}setTimeout(()=>d(null),2e3)};if(v)return e.jsx("div",{className:"text-text-muted text-sm",children:t.loading});const c=(s,a)=>`${(s/100).toFixed(2)} ${a}`;return e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-text-primary mb-6",children:t.title}),e.jsxs("div",{className:"bg-surface-overlay rounded-xl p-6 border border-border-subtle mb-6",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-primary mb-4",children:t.mandate}),n?e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.budget}),e.jsx("p",{className:"text-xl font-bold text-text-primary mt-1",children:c(n.budgetCents,n.currency)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.spent}),e.jsx("p",{className:"text-xl font-bold text-text-primary mt-1",children:c(n.spentCents,n.currency)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.remaining}),e.jsx("p",{className:"text-xl font-bold text-green-400 mt-1",children:c(n.budgetCents-n.spentCents,n.currency)})]}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx("p",{className:"text-xs text-text-muted uppercase tracking-wide",children:t.dailyLimit}),e.jsx("p",{className:"text-sm text-text-primary mt-1",children:n.dailyLimitCents?c(n.dailyLimitCents,n.currency):t.noCents})]})]}):e.jsx("p",{className:"text-text-muted text-sm",children:t.noMandate})]}),e.jsxs("div",{className:"bg-surface-overlay rounded-xl p-6 border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t.alerts}),u&&e.jsx("span",{className:"text-xs text-text-muted",children:u})]}),e.jsx("p",{className:"text-text-muted text-sm mb-4",children:t.alertsDesc}),e.jsx("div",{className:"space-y-3",children:k.map(s=>{const a=g(s),r=a?.enabled??!1,i=a?.notifyEmail??!0;return e.jsxs("div",{className:"flex items-center justify-between p-3 bg-surface-raised rounded-lg border border-border-subtle",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button",onClick:()=>{h(s,"enabled")},className:`w-10 h-6 rounded-full transition-colors relative ${r?"bg-nexbid-600":"bg-border-default"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 rounded-full bg-white transition-transform ${r?"left-5":"left-1"}`})}),e.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[s,"%"]})]}),e.jsx("button",{type:"button",onClick:()=>{h(s,"notifyEmail")},className:`text-xs px-2 py-1 rounded transition-colors ${i?"bg-blue-500/20 text-blue-400":"bg-border-default text-text-muted"}`,children:t.emailNotify})]},s)})})]})]})}const D=M;export{D as Component,M 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.