PageSourceSearch

https://www.studynewzealand.nz/assets/tools-BJGyfwAO.js

js studynewzealand.nz collected 2026-10-08 22:54:06 UTC 8,010 bytes, 4 lines download raw bytes

1import{bv as I,z as W,r as y,bW as R,o as F,j as t,t as L,S as f,B as h,T as p,C as P,x as B,F as m,ac as A,w as C,bX as H}from"./index-DI8w2tsm.js";import{u as U,g as q}from"./tenant-domains-BjCruV0s.js";import{C as E}from"./ContentCopy-f9BSQGfD.js";import{T as G,a as S}from"./ToggleButtonGroup-CLrYVrVd.js";const D={fontSize:15,textColor:"#1f2937",bgColor:"#ffffff",buttonColor:"#2563eb",buttonTextColor:"#ffffff",heading:"Find a course",layout:"stacked"};function K(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function N(){return`${window.location.origin}/widgets/course-search.js`}function O(e){return`${window.location.origin}/api/t/${e}/public/widget/course-options`}function _(e,r,o,n,a){return`<script async
2${[["src",N()],["data-target",e],["data-options-url",r],["data-heading",o.heading],["data-layout",o.layout==="horizontal"?"horizontal":""],["data-font-size",String(o.fontSize)],["data-text-color",o.textColor],["data-bg-color",o.bgColor],["data-button-color",o.buttonColor],["data-button-text-color",o.buttonTextColor],["data-study-fields",encodeURIComponent(JSON.stringify(n))],["data-levels",encodeURIComponent(JSON.stringify(a))]].filter(([,l])=>l!=="").map(([l,i])=>`  ${l}="${K(i)}"`).join(`
3`)}
4><\/script>`}function b({label:e,value:r,onChange:o,testId:n}){return t.jsxs(f,{direction:"row",spacing:1.5,alignItems:"center",children:[t.jsx("input",{type:"color",value:r,onChange:a=>o(a.target.value),"aria-label":e,"data-testid":`${n}-picker`,style:{width:40,height:40,padding:0,border:"1px solid rgba(0,0,0,0.2)",borderRadius:6,background:"none",cursor:"pointer"}}),t.jsx(m,{label:e,value:r,onChange:a=>o(a.target.value),size:"small",fullWidth:!0,inputProps:{"data-testid":n}})]})}function V({style:e,studyFields:r,levels:o}){const n=e.fontSize,a={boxSizing:"border-box",width:"100%",fontSize:n,color:e.textColor,backgroundColor:"#ffffff",border:"1px solid rgba(0,0,0,0.18)",borderRadius:6,padding:`${Math.round(n*.55)}px ${Math.round(n*.7)}px`,lineHeight:1.4},x={display:"block",fontSize:Math.max(10,Math.round(n*.75)),fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",color:e.textColor,margin:"0 0 4px 0"},s=e.layout==="horizontal",l=s?{margin:0,flex:`1 1 ${Math.round(n*11)}px`,minWidth:Math.round(n*9)}:{margin:`0 0 ${Math.round(n*.8)}px 0`};return t.jsxs("div",{"data-testid":"widget-preview",style:{boxSizing:"border-box",backgroundColor:e.bgColor,color:e.textColor,fontSize:n,fontFamily:"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",lineHeight:1.4,borderRadius:10,padding:Math.round(n*1.2),maxWidth:s?"none":720,boxShadow:"0 4px 16px rgba(0,0,0,0.10)",textAlign:"left"},children:[e.heading&&t.jsx("div",{style:{fontSize:Math.round(n*1.25),fontWeight:700,margin:`0 0 ${Math.round(n*.8)}px 0`},children:e.heading}),t.jsxs("div",{style:s?{display:"flex",flexWrap:"wrap",alignItems:"flex-end",gap:Math.round(n*.6)}:void 0,children:[t.jsxs("div",{style:l,children:[t.jsx("span",{style:x,children:"I'm looking for a course in"}),t.jsxs("select",{style:a,defaultValue:"",children:[t.jsx("option",{value:"",children:"Any study field"}),r.map(i=>t.jsx("option",{value:i,children:i},i))]})]}),t.jsxs("div",{style:l,children:[t.jsx("span",{style:x,children:"I want this qualification"}),t.jsxs("select",{style:a,defaultValue:"",children:[t.jsx("option",{value:"",children:"Any level"}),o.map(i=>t.jsx("option",{value:i,children:i},i))]})]}),t.jsxs("div",{style:l,children:[t.jsx("span",{style:x,children:"I'm looking for"}),t.jsx("input",{type:"text",placeholder:"Search keywords",style:a})]}),t.jsx("button",{type:"button",style:{boxSizing:"border-box",display:"inline-block",width:s?"auto":"100%",flex:s?"0 0 auto":void 0,whiteSpace:"nowrap",fontSize:n,fontWeight:600,color:e.buttonTextColor,backgroundColor:e.buttonColor,border:"none",borderRadius:6,padding:`${Math.round(n*.65)}px ${n}px`,cursor:"pointer"},children:"Search"})]})]})}function Z(){const e=I(),{notify:r}=W(),[o,n]=y.useState(D),[a,x]=y.useState(""),{data:s,isLoading:l}=R(e||"",{query:{enabled:!!e,queryKey:H(e||"")}}),{data:i}
4=F(),z=i?.tenantMemberships?.find(d=>d.slug===e)?.role,T=i?.role==="super_admin"||z==="owner",{data:g}=U(e||"",{query:{enabled:!!e&&T,queryKey:q(e||"")}}),j=s?.studyFields??[],w=s?.qualificationLevels??[],v=y.useMemo(()=>g&&g.status==="active"?`https://${g.host}/courses`:`${window.location.origin}${"/".replace(/\/$/,"")}/d/${e}/courses`,[g,e]),c=d=>u=>n(M=>({...M,[d]:u})),k=()=>{x(_(v,e?O(e):"",o,j,w))},$=async()=>{try{await navigator.clipboard.writeText(a),r({title:"Embed code copied",severity:"success"})}catch{r({title:"Couldn't copy automatically",description:"Select the code and copy it manually.",severity:"warning"})}};return t.jsx(L,{role:"tenant_admin",children:t.jsxs(f,{spacing:3,children:[t.jsxs(h,{children:[t.jsx(p,{variant:"h5",fontWeight:700,children:"Tools"}),t.jsx(p,{variant:"body2",color:"text.secondary",children:"Utilities for promoting your directory on other websites."})]}),t.jsx(P,{children:t.jsxs(B,{children:[t.jsx(p,{variant:"h6",fontWeight:700,gutterBottom:!0,children:"Course search widget"}),t.jsx(p,{variant:"body2",color:"text.secondary",sx:{mb:3},children:"Embed a course search block on any external website. Visitors pick a study field, level and keywords, and the search opens on your directory's course search page with the filters applied."}),t.jsxs(h,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"360px 1fr"},gap:4},children:[t.jsxs(f,{spacing:2.5,children:[t.jsx(m,{label:"Heading",value:o.heading,onChange:d=>c("heading")(d.target.value),size:"small",inputProps:{"data-testid":"input-widget-heading"},helperText:"Shown above the search form. Leave blank to hide."}),t.jsxs(h,{children:[t.jsx(A,{sx:{display:"block",fontSize:13,mb:.5},children:"Layout"}),t.jsxs(G,{exclusive:!0,size:"small",value:o.layout,onChange:(d,u)=>{u&&c("layout")(u)},children:[t.jsx(S,{value:"stacked","data-testid":"button-layout-stacked",children:"Stacked"}),t.jsx(S,{value:"horizontal","data-testid":"button-layout-horizontal",children:"Single row"})]})]}),t.jsx(m,{label:"Font size (px)",type:"number",value:o.fontSize,onChange:d=>{const u=Number(d.target.value);Number.isFinite(u)&&c("fontSize")(Math.min(32,Math.max(10,Math.round(u))))},size:"small",inputProps:{min:10,max:32,"data-testid":"input-widget-font-size"}}),t.jsx(b,{label:"Text colour",value:o.textColor,onChange:c("textColor"),testId:"input-widget-text-color"}),t.jsx(b,{label:"Background colour",value:o.bgColor,onChange:c("bgColor"),testId:"input-widget-bg-color"}),t.jsx(b,{label:"Button colour",value:o.buttonColor,onChange:c("buttonColor"),testId:"input-widget-button-color"}),t.jsx(b,{label:"Button text colour",value:o.buttonTextColor,onChange:c("buttonTextColor"),testId:"input-widget-button-text-color"}),t.jsx(C,{variant:"contained",onClick:k,disabled:l,"data-testid":"button-generate-widget",children:"Generate embed code"})]}),t.jsxs(h,{children:[t.jsx(p,{variant:"caption",color:"text.secondary",sx:{textTransform:"uppercase",letterSpacing:.6,fontWeight:600},children:"Preview"}),t.jsx(h,{sx:{mt:1,p:2,bgcolor:"grey.100",borderRadius:2},children:t.jsx(V,{style:o,studyFields:j,levels:w})})]})]}),a&&t.jsxs(h,{sx:{mt:4},children:[t.jsxs(f,{direction:"row",alignItems:"center",justifyContent:"space-between",sx:{mb:1},children:[t.jsx(p,{variant:"subtitle2",fontWeight:700,children:"Embed code"}),t.jsx(C,{size:"small",startIcon:t.jsx(E,{}),onClick:$,"data-testid":"button-copy-widget-code",children:"Copy"})]}),t.jsx(m,{value:a,multiline:!0,fullWidth:!0,minRows:6,InputProps:{readOnly:!0,sx:{fontFamily:"monospace",fontSize:13}},inputProps:{"data-testid":"textarea-widget-snippet"}}),t.jsxs(p,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:1},children:["Paste this anywhere in the HTML of the external page. Search results open at ",v,". Regenerate the code after adding new study fields or levels so the dropdowns stay current."]})]})]})})]})})}export{Z 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.