PageSourceSearch

https://examinaite.ie/assets/BookLanding-DbezdCgL.js

js examinaite.ie collected 2026-10-08 21:11:54 UTC 3,711 bytes, 1 lines download raw bytes

1import{r as c,j as e}from"./motion-BjqkKhQ9.js";import{db as I,fe as w,hg as S,h9 as A,hd as E,hc as R,d6 as $,W as U,cP as l,e as x,bb as T}from"./index-BE3n-wU4.js";import{a as L}from"./appCheck-mt58sOLB.js";import{I as O}from"./Input-DpOgmkai.js";import{ah as q}from"./firebase-LzfcTgM7.js";import{o as z,c as B}from"./navigationOrigin-8fZak3Tt.js";import{K as D}from"./key-round-BFFARVb9.js";async function P(d){if(d)return d;try{return(await q(I)).user}catch(n){const s=n.code;return s==="auth/operation-not-allowed"?w.warn("Anonymous sign-in is not enabled for this Firebase project",new Error(String(s))):w.warn("Anonymous sign-in failed",n instanceof Error?n:new Error(String(n))),null}}const F=16;function J(){const{code:d}=S(),{currentUser:n}=A(),s=E(),f=R(),[a,k]=c.useState(d??""),[u,o]=c.useState(!1),[g,r]=c.useState(null),[v,b]=c.useState(!1),N=c.useCallback(async i=>{const h=i.trim();if(!h||u)return;o(!0),r(null),b(!1);const y=await P(n);if(!y){b(!0),o(!1);return}try{const C=await y.getIdToken(),p=await $(`/book-code/${encodeURIComponent(h)}`,{headers:{Authorization:`Bearer ${C}`,...await L()}});if(!p.ok){let j="That code doesn’t match anything.";try{const m=await p.json();typeof(m==null?void 0:m.error)=="string"&&(j=m.error)}catch{}r(j),o(!1);return}const t=await p.json();if(!(t!=null&&t.paperId)||!(t!=null&&t.nodeId)){r("That code doesn’t match anything."),o(!1);return}s(`/practice/exams/${encodeURIComponent(t.paperId)}/q/${encodeURIComponent(t.nodeId)}`,{state:{publisher:t.publisher,title:t.title,code:h,...z(B(f,"your book code"))}})}catch{r("We couldn’t open that code. Please try again."),o(!1)}},[n,f,s,u]);return e.jsx("div",{className:"min-h-screen bg-canvas px-4 py-12",children:e.jsx("div",{className:"mx-auto max-w-lg",children:e.jsxs(U,{className:"p-6 sm:p-8",children:[e.jsx("span",{"aria-hidden":"true",className:"mb-4 inline-flex h-12 w-12 items-center justify-center rounded-2xl bg-clr-indigo-100 text-clr-indigo-700",children:e.jsx(D,{className:"h-6 w-6"})}),e.jsx(l,{as:"h1",variant:"title",className:"text-content",children:"Open your book's question"}),e.jsx(l,{variant:"muted",className:"mt-2 text-sm",children:"Type the code printed beside a question in your revision book. No account needed — you'll get the full question with every part, its figures and an answer box."}),e.jsxs("form",{className:"mt-6 flex items-start gap-2",onSubmit:i=>{i.preventDefault(),N(a)},children:[e.jsxs("label",{htmlFor:"book-landing-code",className:"min-w-0 flex-1",children:[e.jsx("span",{className:"sr-only",children:"Book code"}),e.jsx(O,{id:"book-landing-code",value:a,onChange:i=>{k(i.target.value),r(null)},maxLength:F,autoComplete:"off",autoCapitalize:"characters",spellCheck:!1,placeholder:"e.g. RKYDDJ"})]}),e.jsx(x,{type:"submit",disabled:u||!a.trim(),children:u?"Opening…":"Open"})]}),g&&e.jsx(l,{role:"alert",variant:"muted",className:"mt-3 text-sm text-clr-red-600",children:g}),v&&e.jsxs("div",{className:"mt-4 rounded-xl bg-surface-muted p-4",children:[e.jsx(l,{className:"text-sm text-content",children:"You'll need an account to open this one."}),e.jsxs("div",{className:"mt-3 flex gap-3",children:[e.jsx(x,{to:`/signup?redirect=${encodeURIComponent(`/book/${a.trim()}`)}`,size:"sm",children:"Create a free account"}),e.jsx(x,{to:`/login?redirect=${encodeURIComponent(`/book/${a.trim()}`)}`,size:"sm",variant:"secondary",children:"Sign in"})]})]}),e.jsxs(l,{variant:"muted",className:"mt-6 text-xs",children:["Marking your answer and showing a worked model answer need a free account."," ",e.jsx(T,{to:"/signup",className:"text-brand underline",children:"Create one"})," whenever you like — your work carries over."]})]})})})}export{J 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.