PageSourceSearch

https://getjobs.org.uk/assets/ApiKey-BmWgOjlF.js

js getjobs.org.uk collected 2026-10-04 14:40:28 UTC 5,213 bytes, 1 lines download raw bytes

1import{a as p,j as e}from"./react-vendor-Cpqy58U4.js";import{c as R,q as T,a4 as I,a5 as C,a6 as L,a7 as S,a8 as q,L as U,a9 as k,aa as v,ab as j,ac as K,B as i,ad as a}from"./index-CxmyrlNx.js";import{E as G}from"./EmployerLayout-D5FCOiAq.js";import"./radix-nLuwKquS.js";import"./navConfig-CnaHlnNy.js";function B(){const{toast:n}=R(),d=T(),[x,m]=p.useState(null),[y,h]=p.useState(null),{data:t,isLoading:g}=I({query:{queryKey:a()}}),r=C(),o=L(),l=S(),c=q(),b=()=>{r.mutate(void 0,{onSuccess:u=>{m(u.apiKey??null),d.invalidateQueries({queryKey:a()}),n({title:"API key regenerated"})}})},N=()=>{o.mutate(void 0,{onSuccess:()=>{m(null),d.invalidateQueries({queryKey:a()}),n({title:"API key revoked"})}})},f=()=>{l.mutate(void 0,{onSuccess:u=>{h(u.apiKey??null),d.invalidateQueries({queryKey:a()}),n({title:"Test API key regenerated"})}})},A=()=>{c.mutate(void 0,{onSuccess:()=>{h(null),d.invalidateQueries({queryKey:a()}),n({title:"Test API key revoked"})}})},P=t?.lastUsedAt?new Date(t.lastUsedAt).toLocaleString():"Never used",s=t?.testKey,w=s?.lastUsedAt?new Date(s.lastUsedAt).toLocaleString():"Never used";return e.jsx(G,{children:e.jsxs("div",{className:"max-w-lg space-y-6",children:[e.jsx("h1",{className:"text-2xl font-bold",children:"API Key"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Use your API key to submit job listings programmatically via the GetJobs API. Send it as the ",e.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"X-API-Key"})," header."]}),e.jsx("p",{className:"text-sm",children:e.jsx(U,{href:"/docs",className:"text-primary underline","data-testid":"link-api-docs",children:"Read the API docs →"})}),e.jsxs(k,{children:[e.jsx(v,{children:e.jsx(j,{className:"text-base",children:"Your API Key"})}),e.jsxs(K,{className:"space-y-4",children:[g?e.jsx("div",{className:"h-8 bg-muted animate-pulse rounded"}):x?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-yellow-600 font-medium",children:"Copy this now — it won't be shown again."}),e.jsx("code",{className:"block bg-muted p-3 rounded text-sm break-all font-mono","data-testid":"text-api-key",children:x})]}):t?.hasKey?e.jsxs("div",{children:[e.jsx("code",{className:"block bg-muted p-3 rounded text-sm font-mono text-muted-foreground","data-testid":"text-api-key-prefix",children:t.prefix??"gjk_..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:t.revoked?e.jsx("span",{className:"text-destructive font-medium","data-testid":"text-api-key-revoked",children:"Revoked — generate a new key to resume API access."}):e.jsxs(e.Fragment,{children:["Key exists — prefix shown only. Last used: ",P]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No API key generated yet."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{variant:"outline",onClick:b,disabled:r.isPending,"data-testid":"button-regenerate-key",children:r.isPending?"Generating...":t?.hasKey?"Regenerate Key":"Generate Key"}),t?.hasKey&&!t.revoked&&e.jsx(i,{variant:"ghost",className:"text-destructive",onClick:N,disabled:o.isPending,"data-testid":"button-revoke-key",children:o.isPending?"Revoking...":"Revoke Key"})]})]})]}),e.jsxs(k,{children:[e.jsx(v,{children:e.jsx(j,{className:"text-base",children:"Test API Key"})}),e.jsxs(K,{className:"space-y-4",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Test keys start with ",e.jsx("code",{className:"bg-muted px-1 rounded text-xs",children:"gjt_"})," and work against the same endpoints as your live key, but every job they create is flagged as a test: it is never published, stays out of the public site, and is automatically deleted after 30 days. Use one to try out your integration safely."]}),g?e.jsx("div",{className:"h-8 bg-muted animate-pulse rounded"}):y?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-yellow-600 font-medium",children:"Copy this now — it won't be shown again."}),e.jsx("code",{className:"block bg-muted p-3 rounded text-sm break-all font-mono","data-testid":"text-test-api-key",children:y})]}):s?.hasKey?e.jsxs("div",{children:[e.jsx("code",{className:"block bg-muted p-3 rounded text-sm font-mono text-muted-foreground","data-testid":"text-test-api-key-prefix",children:s.prefix??"gjt_..."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s.revoked?e.jsx("span",{className:"text-destructive font-medium","data-testid":"text-test-api-key-revoked",children:"Revoked — generate a new test key to resume sandbox access."}):e.jsxs(e.Fragment,{children:["Key exists — prefix shown only. Last used: ",w]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No test API key generated yet."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{variant:"outline",onClick:f,disabled:l.isPending,"data-testid":"button-regenerate-test-key",children:l.isPending?"Generating...":s?.hasKey?"Regenerate Test Key":"Generate Test Key"}),s?.hasKey&&!s.revoked&&e.jsx(i,{variant:"ghost",className:"text-destructive",onClick:A,disabled:c.isPending,"data-testid":"button-revoke-test-key",children:c.isPending?"Revoking...":"Revoke Test Key"})]})]})]})]})})}export{B 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.