PageSourceSearch

https://plasticcleverschools.org/assets/SchoolSignUpForm-BdBl1H1r.js

js plasticcleverschools.org collected 2026-10-07 23:57:10 UTC 13,623 bytes, 1 lines download raw bytes

1import{u as X,b as J,y as Z,r as n,a as ee,d as se,j as e,B as _,X as te,P as oe,S as ae,w as E,U as re,m as ie,L as ne,e as le}from"./index-C0lDKHoD.js";import{u as ce,F as me,a as l,b as c,c as m,d,e as h,f as w}from"./form-ave1BudE.js";import{t as de}from"./zod-DVccARWr.js";import{I as N}from"./input-Be56e5MI.js";import{T as he}from"./textarea-CJ8Nbni7.js";import{S as ue,a as xe,b as pe,c as ge,d as fe}from"./select-D_ooL75G.js";import{C as _e,a as je,b as be,c as ve,d as ye,e as Ne}from"./command-BvBykc2y.js";import{C as P}from"./checkbox-Bc-CLlIv.js";import{A as Ce,b as we,a as Se}from"./alert-DlOFs73l.js";import{S as Te,b as ke}from"./schema-9wnypY-6.js";import{a as Ee}from"./useCountries-BqqFPd-B.js";import{S as F}from"./school-BV2KHIi_.js";import{C as Fe}from"./chevrons-up-down-oP2nbMyb.js";import{U as R}from"./users-CLX-qRjp.js";import{M as Le}from"./mail-DZguyh-f.js";import{C as Oe}from"./circle-alert-DwyO4fRh.js";import{o as L,b as U,s as j,n as Ie,e as qe}from"./types-iRNQIv62.js";import"./label-D7F8UYJC.js";import"./index-CGXYFoB3.js";import"./chevron-down-wSrqTeCD.js";import"./chevron-up-BPRS9dKa.js";import"./dialog-_s91QOrJ.js";import"./search-Besxymsf.js";const Ve=r=>L({school:L({name:j().min(1,r("forms:validation.required")).max(200,r("forms:validation.name_too_long",{max:200})),type:qe(ke,{required_error:r("forms:validation.invalid_selection")}),country:j().min(1,r("forms:validation.required")),address:j().optional(),studentCount:Ie().min(1,r("forms:school_registration.student_count_min")).max(1e4,r("forms:school_registration.student_count_max"))}),user:L({firstName:j().min(1,r("forms:validation.first_name_required")).max(50,r("forms:validation.name_too_long",{max:50})),lastName:j().min(1,r("forms:validation.last_name_required")).max(50,r("forms:validation.name_too_long",{max:50})),email:j().email(r("forms:validation.email_invalid"))}),acceptTerms:U().refine(p=>p===!0,{message:r("forms:school_registration.accept_terms_required")}),gdprConsent:U().refine(p=>p===!0,{message:r("forms:school_registration.gdpr_consent_required")})});function is({onClose:r,inline:p=!1,onRequestJoinInstead:O}){const{t}=X(["forms","common"]),{toast:I}=J(),{user:a}=Z(),[S,q]=n.useState(!1),[V,A]=n.useState(!1),[x,T]=n.useState(""),[b,C]=n.useState([]),[B,g]=n.useState(!1),v=n.useRef(null),{data:k=[],isLoading:Ae}=Ee(),z=Ve(t),{data:f,isLoading:D}=ee({queryKey:["/api/schools/check-domain",x],queryFn:async()=>{const s=await fetch(`/api/schools/check-domain?email=${encodeURIComponent(x)}`);if(!s.ok)throw new Error("Domain check failed");return s.json()},enabled:!!x&&x.includes("@"),retry:!1,refetchOnWindowFocus:!1,staleTime:3e4}),i=ce({resolver:de(z),defaultValues:{school:{name:"",type:void 0,country:"",address:"",studentCount:void 0},user:{firstName:(a==null?void 0:a.firstName)||"",lastName:(a==null?void 0:a.lastName)||"",email:(a==null?void 0:a.email)||""},acceptTerms:!1,gdprConsent:!1}});n.useEffect(()=>{a&&(i.setValue("user.firstName",a.firstName||""),i.setValue("user.lastName",a.lastName||""),i.setValue("user.email",a.email||""))},[a,i]),n.useEffect(()=>{f!=null&&f.matchingSchools&&f.matchingSchools.length>0?(C(f.matchingSchools),g(!0)):(C([]),g(!1))},[f]);const $=n.useCallback(s=>{var u;v.current&&clearTimeout(v.current),s&&s.includes("@")&&((u=s.split("@")[1])==null?void 0:u.includes("."))?v.current=setTimeout(()=>{T(s)},500):(T(""),C([]),g(!1))},[]),H=n.useCallback(s=>{x&&s!==x&&(T(""),C([]),g(!1))},[x]);n.useEffect(()=>()=>{v.current&&clearTimeout(v.current)},[]);const K=()=>
1{O?O():(g(!1),r())},Y=se({mutationFn:async s=>{q(!0);const{acceptTerms:o,...u}=s;return(await le("POST","/api/schools/register",u)).json()},onSuccess:s=>{I({title:t("forms:school_registration.success_title"),description:t("forms:school_registration.success_message")}),r(),setTimeout(()=>{window.location.href=s.melEligibilityId?`/mel/surveys/${s.melEligibilityId}`:"/dashboard"},2e3)},onError:s=>{var u,y;console.error("Registration error:",s);let o=t("forms:school_registration.error_message");(u=s.message)!=null&&u.includes("email")?o=t("forms:school_registration.error_email_exists"):(y=s.message)!=null&&y.includes("school")&&(o=t("forms:school_registration.error_school_exists")),I({title:t("forms:school_registration.error_title"),description:o,variant:"destructive"})},onSettled:()=>{q(!1)}}),G=s=>{Y.mutate(s)},Q=Te.map(s=>({value:s.value,label:t(s.labelKey,s.defaultLabel)})),M=e.jsxs("div",{className:p?"":"p-6",children:[!p&&e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-pcs_blue text-white p-2 rounded-lg",children:e.jsx(F,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-navy","data-testid":"text-signup-title",children:t("forms:school_registration.title")}),e.jsx("p",{className:"text-gray-600",children:t("forms:school_registration.subtitle")})]})]}),e.jsx(_,{variant:"ghost",size:"icon",onClick:r,"data-testid":"button-close-signup",children:e.jsx(te,{className:"h-5 w-5"})})]}),e.jsx(me,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(G),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-lg font-semibold text-navy",children:[e.jsx(F,{className:"h-5 w-5"}),t("forms:school_registration.school_section")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(l,{control:i.control,name:"school.name",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.school_name")}),e.jsx(d,{children:e.jsx(N,{placeholder:t("forms:school_registration.school_name_placeholder"),...s,"data-testid":"input-school-name"})}),e.jsx(h,{})]})}),e.jsx(l,{control:i.control,name:"school.type",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.school_type")}),e.jsxs(ue,{onValueChange:s.onChange,defaultValue:s.value,children:[e.jsx(d,{children:e.jsx(xe,{"data-testid":"select-school-type",children:e.jsx(pe,{placeholder:t("forms:school_registration.school_type_placeholder")})})}),e.jsx(ge,{children:Q.map(o=>e.jsx(fe,{value:o.value,children:o.label},o.value))})]}),e.jsx(h,{})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(l,{control:i.control,name:"school.country",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.country")}),e.jsxs(oe,{open:V,onOpenChange:A,children:[e.jsx(ae,{asChild:!0,children:e.jsx(d,{children:e.jsxs(_,{variant:"outline",role:"combobox","aria-expanded":V,className:E("w-full justify-between",!s.value&&"text-muted-foreground"),"data-testid":"select-country",children:[s.value?k.find(o=>o===s.value):t("forms:school_registration.country_placeholder"),e.jsx(Fe,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsx(re,{className:"w-[300px] p-0",children:e.jsxs(_e,{children:[e.jsx(je,{placeholder:t("forms:school_registration.country_search_placeholder")}),e.jsxs(be,{children:[e.jsx(ve,{children:t("forms:school_registration.country_not_found")}),e.jsx(ye,{children:k.map(o=>e.jsxs(Ne,{value:o,onSelect:u=>{const y=k.find(W=>W.toLowerCase()===u.toLowerCase());s.onChange(y===s.value?"":y),A(!1)},children:[e.jsx(ie,{className:E("mr-2 h-4 w-4",s.value===o?"opacity-100":"opacity-0")}),o]},o))})]})]})})]}),e.jsx(h,{})]})}),e.jsx(l,{control:i.control,name:"school.studentCount",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.student_count")}),e.jsx(d,{children:e.jsx(N,{type:"number",placeholder:t("forms:school_registration.student_count_placeholder"),...s,onChange:o=>s.onChange(o.target.value?parseInt(o.target.value):void 0),"data-testid":"input-student-count"})}),e.jsx(h,{})]})})]}),e.jsx(l,{control:i.control,name:"school.address",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.address")}),e.jsx(d,{children:e.jsx(he,{placeholder:t("forms:school_registration.address_placeholder"),rows:3,...s,"data-testid":"textarea-school-address"})}),e.jsx(w,{children:t("forms:school_registration.address_description")}),e.jsx(h,{})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-lg font-semibold text-navy",children:[e.jsx(R,{className:"h-5 w-5"}),t("forms:school_registration.contact_section")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(l,{control:i.control,name:"user.firstName",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.first_name")}
1),e.jsx(d,{children:e.jsx(N,{placeholder:t("forms:school_registration.first_name_placeholder"),...s,readOnly:!!a,disabled:!!a,className:a?"bg-gray-50":"","data-testid":"input-first-name"})}),e.jsx(h,{})]})}),e.jsx(l,{control:i.control,name:"user.lastName",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.last_name")}),e.jsx(d,{children:e.jsx(N,{placeholder:t("forms:school_registration.last_name_placeholder"),...s,readOnly:!!a,disabled:!!a,className:a?"bg-gray-50":"","data-testid":"input-last-name"})}),e.jsx(h,{})]})})]}),e.jsx(l,{control:i.control,name:"user.email",render:({field:s})=>e.jsxs(c,{children:[e.jsx(m,{children:t("forms:school_registration.email")}),e.jsx(d,{children:e.jsxs("div",{className:"relative",children:[e.jsx(Le,{className:"absolute left-3 top-3 h-4 w-4 text-gray-400"}),e.jsx(N,{type:"email",placeholder:t("forms:school_registration.email_placeholder"),className:E("pl-10 pr-10",a&&"bg-gray-50"),...s,onChange:o=>{s.onChange(o),H(o.target.value)},onBlur:o=>{s.onBlur(),$(o.target.value)},readOnly:!!a,disabled:!!a,"data-testid":"input-email"}),D&&!a&&e.jsx(ne,{className:"absolute right-3 top-3 h-4 w-4 text-pcs_blue animate-spin","data-testid":"spinner-domain-check"})]})}),e.jsx(w,{children:t(a?"forms:school_registration.email_description_readonly":"forms:school_registration.email_description")}),e.jsx(h,{})]})}),B&&b.length>0&&e.jsxs(Ce,{className:"border-pcs_blue bg-blue-50/50 mt-4","data-testid":"alert-matching-schools",children:[e.jsx(Oe,{className:"h-5 w-5 text-pcs_blue"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(we,{className:"text-navy font-semibold mb-2",children:t("forms:school_registration.domain_match_title")}),e.jsxs(Se,{className:"space-y-3",children:[e.jsx("p",{className:"text-gray-700",children:t("forms:school_registration.domain_match_message",{count:b.length,domain:x.split("@")[1]})}),e.jsxs("div",{className:"space-y-2",children:[b.slice(0,3).map((s,o)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm text-gray-800 bg-white/70 p-2 rounded",children:[e.jsx(F,{className:"h-4 w-4 text-pcs_blue flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:s.school.name}),e.jsxs("span",{className:"text-gray-500",children:["(",s.matchCount," ",t("forms:school_registration.domain_match_users"),")"]})]},o)),b.length>3&&e.jsx("p",{className:"text-xs text-gray-600",children:t("forms:school_registration.domain_match_more",{count:b.length-3})})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(_,{type:"button",size:"sm",onClick:K,className:"bg-pcs_blue hover:bg-pcs_blue/90 text-white","data-testid":"button-join-from-alert",children:[e.jsx(R,{className:"h-4 w-4 mr-2"}),t("forms:school_registration.domain_match_join_button")]}),e.jsx(_,{type:"button",size:"sm",variant:"outline",onClick:()=>g(!1),"data-testid":"button-dismiss-alert",children:t("forms:school_registration.domain_match_dismiss")})]})]})]})]})]}),e.jsx(l,{control:i.control,name:"acceptTerms",render:({field:s})=>e.jsxs(c,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4",children:[e.jsx(d,{children:e.jsx(P,{checked:s.value,onCheckedChange:s.onChange,"data-testid":"checkbox-accept-terms"})}),e.jsxs("div",{className:"space-y-1 leading-none",children:[e.jsx(m,{children:t("forms:school_registration.accept_terms")}),e.jsxs(w,{children:[t("forms:school_registration.accept_terms_description_start")," ",e.jsx("a",{href:"#",className:"text-pcs_blue hover:underline",children:t("forms:school_registration.terms_of_service")})," ",t("forms:school_registration.accept_terms_description_and")," ",e.jsx("a",{href:"#",className:"text-pcs_blue hover:underline",children:t("forms:school_registration.privacy_policy")})]})]}),e.jsx(h,{})]})}),e.jsx(l,{control:i.control,name:"gdprConsent",render:({field:s})=>e.jsxs(c,{className:"flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4 bg-green-50/50",children:[e.jsx(d,{children:e.jsx(P,{checked:s.value,onCheckedChange:s.onChange,"data-testid":"checkbox-gdpr-consent"})}),e.jsxs("div",{className:"space-y-1 leading-none",children:[e.jsxs(m,{children:[t("forms:school_registration.gdpr_consent")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(w,{children:t("forms:school_registration.gdpr_consent_description")})]}),e.jsx(h,{})]})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(_,{type:"button",variant:"outline",onClick:r,className:"flex-1",disabled:S,"data-testid":"button-cancel-signup",children:t("common:cancel")}),e.jsx(_,{type:"submit",disabled:S,className:"flex-1","data-testid":"button-submit-registration",children:t(S?"forms:school_registration.submitting":"forms:school_registration.submit_button")})]})]})})]});return p?M:e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsx("div",{className:"bg-white rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto",children:M})})}export{is 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.