1import{F as _}from"./FormFieldFeedback-B1ACm6Z5.js";import{_ as b,Q as g,P as m,S as n,aw as k,T as w,d as I,U as C,o as a,v as D,c as l,i as t,a1 as A,k as v,O as h,E as p,h as f,t as d,l as c,x as y}from"./index-dTZKzxlM.js";import{L as E}from"./LoadingIndicator-BD4Jf9DD.js";import{D as V}from"./DataElement-CgISZgdg.js";const F={name:"AccessCodeForm",emits:["cancel","saved"],components:{DataElement:V,LoadingIndicator:E,FormFieldFeedback:_},mixins:[g],setup(){const{user:e}=I();return{v$:C(),user:e}},props:{profile:{type:Object,required:!0}},mounted(){},computed:{codes(){return this.profile.codes.map(e=>parseInt(e.invitationcode))}},validations(){return{code:{required:n.withMessage("Access Code is required",w),isValid:n.withMessage(({$response:e})=>e?e?.data?.message:"Invalid Data",n.withAsync(this.validate)),$autoDirty:!0},externalId:{required:n.withMessage("External ID is required",k(()=>this.invitation!=null&&this.invitation.promptExternalID)),$autoDirty:!0}}},data(){return{invitation:null,code:"",externalId:""}},methods:{validate(e){return this.code<999||this.code>9999?{$valid:!1,data:{message:"This code is invalid",extraParams:{}}}:this.codes.indexOf(this.code)>-1?{$valid:!1,data:{message:"This code is already registered",extraParams:{}}}:m.builder().onelook().get(`/api/whichway/invitation?key=${this.code}`).exe().then(s=>s!=null&&s.active?(this.invitation=s,!0):{$valid:!1,data:{message:"This code is not available",extraParams:{}}}).catch(s=>(console.error(s.response.data.error),{$valid:!1,data:{message:s.response.data.error,extraParams:{}}}))},whenValid(){return this.working=!0,m.builder().onelook().post("/api/whichway/user/codes").payload({code:this.code,externalid:this.externalId}).exe().then(()=>(this.$toast.add({severity:"success",summary:"Add Access Code",detail:"Access code has been added",life:5e3}),this.$emit("saved"),Promise.resolve())).catch(e=>{console.error(e),this.$toast.add({severity:"error",summary:"Add Access Code",detail:"Sorry, we could not add this access code",life:15e3})}).finally(()=>this.working=!1)}}},T={key:1,class:"row"},q={class:"col-12"},P={class:"row"},S={class:"col-12 form-group"},M={key:0,class:"col-12 my-4"},$={key:1,class:"col-12 form-group"},B={for:"externalid"},N=["placeholder"],O={key:0},U={class:"row"},L={class:"col-6"},j={class:"col-6"},z=["disabled"];function Q(e,s,Y,r,i,G){const x=y("loading-indicator"),u=y("form-field-feedback");return e.working?(a(),D(x,{key:0})):(a(),l("div",T,[t("div",q,[t("form",{onSubmit:s[3]||(s[3]=A((...o)=>e.submit&&e.submit(...o),["prevent"]))},[t("div",null,[t("div",null,[t("div",P,[t("div",S,[s[4]||(s[4]=t("label",{for:"code"},[t("h5",null,"Enter Your Access Code:")],-1)),v(t("input",{type:"number",class:p(["form-control",e.getFieldClass(r.v$.code)]),id:"code","data-testid":"access-code-field",placeholder:"Enter your access code","onUpdate:modelValue":s[0]||(s[0]=o=>i.code=o)},null,2),[[h,i.code]]),f(u,{field:r.v$.code},null,8,["field"])]),i.invitation!=null?(a(),l("div",M," This access code was provided by "+d(i.invitation.clientName)+". ",1)):c("",!0),i.invitation?.promptExternalID?(a(),l("div",$,[t("label",B,d(i.invitation.externalIDTitle),1),v(t("input",{type:"text",class:p(["form-control",e.getFieldClass(r.v$.externalId)]),id:"externalid",placeholder:`Enter your ${i.invitation.externalIDTitle}`,"onUpdate:modelValue":s[1]||(s[1]=o=>i.externalId=o)},null,10,N),[[h,i.externalId]]),f(u,{field:r.v$.externalId},null,8,["field"]),i.invitation?.externalIDInstructions!=""?(a(),l("small",O,d(i.invitation.externalIDInstructions),1)):c("",!0)])):c("",!0)])]),t("div",null,[t("div",U,[t("div",L,[t("button",{onClick:s[2]||(s[2]=o=>e.$emit("cancel")),"aria-label":"Cancel",class:"btn-primary-dark"}," Cancel ")]),t("div",j,[t("button",{type:"submit",disabled:e.working,"aria-label":"Save",class:"btn-primary-dark"},"Save",8,z)])])])])],32)])]))}const W=b(F,[["render",Q]]);export{W 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.