UNPKG

@getontime/cli

Version:
3 lines (2 loc) 1.39 kB
import{h as l,j as t,A as f}from"./vendor-q6fv0YT2.js";import{e as h,ah as p,ak as b,bR as g,U as x}from"./index-B81u4hxi.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="e2b27f50-5d33-4a5f-805e-dc15ca8efc3a",e._sentryDebugIdIdentifier="sentry-dbid-e2b27f50-5d33-4a5f-805e-dc15ca8efc3a")}catch{}})();const y="_container_o8th0_17",_="_pin_o8th0_27",m="_pinFailed_o8th0_51",c={container:y,pin:_,pinFailed:m};function v({permission:e,handleValidation:a}){const[s,o]=l.useState(""),[i,r]=l.useState(!1),u=()=>{a(s)||(r(!0),o(""))},d=n=>{o(n),i&&r(!1)};return t.jsxs("div",{className:c.container,children:[`Ontime ${e}`,t.jsxs("form",{onSubmit:n=>{n.preventDefault(),u()},className:h([c.pin,i&&c.pinFailed]),children:[t.jsx(p,{type:"password",maxLength:4,height:"large",value:s,onChange:n=>d(n.target.value)}),t.jsx(b,{type:"submit",variant:"primary","aria-label":"Enter",children:t.jsx(f,{})})]})]})}function w({permission:e,children:a}){const{editorAuth:s,operatorAuth:o,validate:i}=l.useContext(g),r=l.useCallback(d=>i(d,e),[e,i]);return x||(e==="editor"?s:e==="operator"?o:!1)?t.jsx(t.Fragment,{children:a}):t.jsx(v,{permission:e,handleValidation:r})}export{w as P}; //# sourceMappingURL=ProtectRoute-BH-QvsU0.js.map