1import{bQ as L,r,n as k,a5 as S,j as e,l as C,B as f,R as z,aX as O,$ as P,ca as E,cb as T,cc as y,cd as N,q as B}from"./index-5a305ee0.js";import{u as W,T as F,D as A}from"./useOilWorkshop-c2167ee3.js";import{O as D,P as I,a as R,b as $}from"./OilSupplyOrdersGrid-4d7a2489.js";import{E as U}from"./eye-off-49fa1f19.js";import{E as G}from"./eye-ba8dffaf.js";import{L as H}from"./log-out-e66aa59d.js";import"./alert-dialog-b6315dbc.js";import"./plus-2e283f20.js";import"./trash-2-871b0090.js";import"./circle-alert-1d3f1533.js";const V="maronici.pl";function Z(a){const s=(a||"").trim().toLowerCase();return s?s.includes("@")?s:`${s}@${V}`:""}function q(){const[a,s]=r.useState(""),[l,h]=r.useState(""),[n,j]=r.useState(!1),[m,x]=r.useState(!1),[u,t]=r.useState(null),[b,o]=r.useState(""),d=r.useRef(null),g=async p=>{var v;p.preventDefault();const w=Z(a);if(!w||!l){t("Podaj login i hasÅo.");return}if(!b){t("Weryfikacja zabezpieczeÅ jeszcze trwa. Odczekaj chwilÄ i spróbuj ponownie.");return}x(!0),t(null);try{const{error:c}=await k.auth.signInWithPassword({email:w,password:l,options:{captchaToken:b}});if(c)throw c}catch(c){S.error("oil_panel_login_failed",c.message);const _=/captcha/i.test((c==null?void 0:c.message)||"")||(c==null?void 0:c.code)==="captcha_failed";t(_?"Weryfikacja zabezpieczeÅ nie powiodÅa siÄ. OdÅwież stronÄ i spróbuj ponownie.":"NieprawidÅowy login lub hasÅo."),(v=d.current)==null||v.reset()}finally{x(!1)}},i="w-full h-12 rounded-xl border border-slate-300 bg-white px-4 text-base text-slate-900 placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-charbel-gold focus:border-charbel-gold";return e.jsxs("div",{className:"relative flex min-h-screen items-center justify-center overflow-hidden bg-charbel-navy p-4 py-12",children:[e.jsx("div",{className:"absolute inset-0 bg-cover bg-center",style:{backgroundImage:"url(/images/hero/hero-0.jpg)"},"aria-hidden":"true"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-charbel-navy/85 via-charbel-navy/90 to-charbel-navy/95","aria-hidden":"true"}),e.jsxs("main",{className:"relative z-10 w-full max-w-sm",children:[e.jsxs("div",{className:"rounded-2xl border border-charbel-gold/15 bg-white p-7 shadow-[0_12px_48px_rgba(0,0,0,0.35)] sm:p-9",children:[e.jsxs("div",{className:"mb-7 text-center",children:[e.jsx("span",{className:"mx-auto mb-4 flex h-14 w-14 items-center justify-center rounded-full bg-charbel-gold/15",children:e.jsx(O,{className:"h-7 w-7 text-charbel-gold-dark","aria-hidden":"true"})}),e.jsx("h1",{className:"font-serif text-2xl text-charbel-navy",children:"Panel oleju"}),e.jsx("p",{className:"mt-2 text-xs uppercase tracking-[0.2em] text-charbel-navy/45",children:"Olej Åw. Szarbela"})]}),e.jsxs("form",{onSubmit:g,className:"space-y-5",noValidate:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"oilLogin",className:"block text-sm font-medium text-charbel-navy/80",children:"Login"}),e.jsx("input",{id:"oilLogin",type:"text",autoComplete:"username",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",placeholder:"siostracherubina",value:a,onChange:p=>s(p.target.value),className:i})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"oilPassword",className:"block text-sm font-medium text-charbel-navy/80",children:"HasÅo"}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:"oilPassword",type:n?"text":"password",autoComplete:"current-password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:l,onChange:p=>h(p.target.value),className:`${i} pr-12`}),e.jsx("button",{type:"button",onClick:()=>j(p=>!p),"aria-label":n?"Ukryj hasÅo":"Pokaż hasÅo",className:"absolute right-3 top-3.5 text-charbel-gold-dark/60 transition-colors hover:text-charbel-navy",children:n?e.jsx(U,{className:"h-5 w-5"}):e.jsx(G,{className:"h-5 w-5"})})]})]}),u&&e.jsx("p",{role:"alert",className:"text-sm font-medium text-red-600",children:u}),e.jsx("div",{className:"flex justify-center",children:e.jsx(P,{ref:d,onToken:o})}),e.jsx(f,{type:"submit",disabled:m,className:"h-12 w-full bg-charbel-navy text-base font-semibold text-white hover:bg-charbel-navy/90",children:m?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{className:"h-4 w-4 animate-spin"})," Logowanieâ¦"]}):"Zaloguj siÄ"})]})]}),e.jsxs("p",{className:"mt-6 text-center text-xs text-charbel-cream/70",children:["Problem z logowaniem?"," ",e.jsx("a",{href:"mailto:[email protected]",className:"text-charbel-gold hover:underline",children:"[email protected]"})]})]})]})}
1function K({onSignOut:a}){const{batches:s,orders:l,summary:h,loading:n,error:j,rowState:m,reload:x,addBatch:u,updateBatch:t,deleteBatch:b,addOrder:o,updateOrder:d,deleteOrder:g}=W(),i=A;return e.jsxs("div",{className:"min-h-screen bg-charbel-cream/40",children:[e.jsx("header",{className:"border-b border-charbel-gold/20 bg-white",children:e.jsxs("div",{className:"mx-auto max-w-7xl px-4 py-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-xl bg-charbel-gold/15",children:e.jsx(O,{className:"h-5 w-5 text-charbel-gold-dark","aria-hidden":"true"})}),e.jsx("h1",{className:"min-w-0 flex-1 font-serif text-lg leading-tight text-charbel-navy sm:text-2xl",children:"Olej Åw. Szarbela â warsztat"}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(f,{type:"button",variant:"ghost",onClick:x,className:"h-10 px-3 text-slate-500 hover:text-charbel-navy","aria-label":"OdÅwież",children:e.jsx(z,{className:`h-4 w-4 ${n?"animate-spin":""}`,"aria-hidden":"true"})}),e.jsxs(f,{type:"button",variant:"outline",onClick:a,className:"h-10 border-slate-300 px-3 text-slate-600 hover:bg-slate-100 hover:text-charbel-navy",children:[e.jsx(H,{className:"mr-1.5 h-4 w-4","aria-hidden":"true"}),"Wyloguj"]})]})]}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:i.autosaveHint})]})}),e.jsxs("main",{className:"mx-auto max-w-7xl space-y-6 px-4 py-6 sm:px-6 sm:py-8",children:[j&&e.jsxs("div",{role:"alert",className:"rounded-xl border border-red-200 bg-red-50 px-4 py-3 text-sm font-medium text-red-700",children:[i.loadError," â ",j]}),e.jsx(D,{summary:h,labels:i}),e.jsxs(E,{defaultValue:"batches",className:"space-y-5",children:[e.jsxs(T,{className:"h-auto w-full max-w-md rounded-xl bg-white p-1.5 shadow-sm",children:[e.jsxs(y,{value:"batches",className:"h-11 flex-1 rounded-lg text-base data-[state=active]:bg-charbel-navy data-[state=active]:text-white",children:[e.jsx(I,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),i.tabBatches]}),e.jsxs(y,{value:"orders",className:"h-11 flex-1 rounded-lg text-base data-[state=active]:bg-charbel-navy data-[state=active]:text-white",children:[e.jsx(F,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),i.tabOrders]})]}),e.jsx(N,{value:"batches",className:"mt-0",children:e.jsx(R,{batches:s,rowState:m,labels:i,onAdd:u,onUpdate:t,onDelete:b})}),e.jsx(N,{value:"orders",className:"mt-0",children:e.jsx($,{orders:l,rowState:m,labels:i,onAdd:o,onUpdate:d,onDelete:g})})]})]})]})}function le(){var b;const{session:a,loading:s,signOut:l}=L(),[h,n]=r.useState("checking"),[j,m]=r.useState(0),x=((b=a==null?void 0:a.user)==null?void 0:b.id)??null;r.useEffect(()=>{if(s)return;if(!x){n("denied");return}let o=!0;return n("checking"),(async()=>{try{const{data:d,error:g}=await k.rpc("post_login_role");if(g)throw g;o&&n(d==="oil_operator"||d==="admin"?"allowed":"denied")}catch(d){S.error("oil_panel_role_check_failed",d.message),o&&n("error")}})(),()=>{o=!1}},[x,s,j]);const u=r.useCallback(async()=>{await(l==null?void 0:l())},[l]),t=e.jsxs(B,{children:[e.jsx("title",{children:"Panel oleju Åw. Szarbela"}),e.jsx("meta",{name:"robots",content:"noindex, nofollow"})]});return s||a&&h==="checking"?e.jsxs(e.Fragment,{children:[t,e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-charbel-cream/40",children:e.jsx(C,{className:"h-6 w-6 animate-spin text-charbel-gold-dark","aria-label":"Wczytywanie"})})]}):a?h==="error"?e.jsxs(e.Fragment,{children:[t,e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-charbel-cream/40 px-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[e.jsx("h1",{className:"text-xl font-semibold text-charbel-navy",children:"Brak poÅÄ
czenia"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:"Nie udaÅo siÄ poÅÄ
czyÄ z serwerem. Sprawdź internet i spróbuj ponownie â Twoje uprawnienia sÄ
w porzÄ
dku."}),e.jsxs(f,{type:"button",onClick:()=>m(o=>o+1),className:"mt-6 h-11 w-full bg-charbel-navy text-white hover:bg-charbel-navy/90",children:[e.jsx(z,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Spróbuj ponownie"]})]})})]}):h!=="allowed"?e.jsxs(e.Fragment,{children:[t,e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-charbel-cream/40 px-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-slate-200 bg-white p-8 text-center shadow-sm",children:[e.jsx("h1",{className:"text-xl font-semibold text-charbel-navy",children:"Brak dostÄpu"}),e.jsx("p",{className:"mt-2 text-sm text-slate-500",children:"To konto nie ma uprawnieÅ do panelu oleju."}),e.jsx(f,{type:"button",onClick:u,className:"mt-6 h-11 w-full bg-charbel-navy text-white hover:bg-charbel-navy/90",children:"Zaloguj siÄ na inne konto"})]})})]}):e.jsxs(e.Fragment,{children:[t,e.jsx(K,{onSignOut:u})]}):e.jsxs(e.Fragment,{children:[t,e.jsx(q,{})]})}
1export{le 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.