PageSourceSearch

https://www.cab.org.nz/_resources/app/client/dist/assets/UserAwards-ebUXDC55.js

js cab.org.nz collected 2026-09-24 18:50:20 UTC 4,846 bytes, 11 lines download raw bytes

1import{i as l,a as t,p as d,m as o,w as u}from"./vendor-CHCIo3bd.js";import{n as w,U as c,T as v,D as h}from"./app-oVuUJ3MT.js";import"./vendor-filepond-C-Be2LEg.js";/* empty css            */t.extend(u);const _={components:{icon:l,Dropdown:h,TextField:v,UserCircle:c},data(){return{awards:[],user:null,currentRole:null,loadingAwards:!0,newAward:null,errorMessage:"",validation:{}}},computed:{...o({currentUserRole:r=>r.currentUserRole,currentUserBureaux:r=>r.currentUserBureaux})},created(){this.$store.dispatch("syncCurrentUserBureaux").then(()=>{this.fetchUser()}),this.setAwards()},methods:{fetchUser(){this.$axios.get("/api/v1/user/user",{params:{userID:this.$route.query.userId}}).then(r=>{const a=r.data.roles.find(e=>e.bureau&&this.currentUserBureaux.find(s=>s.id===e.bureau.id));this.currentRole=a,this.user=JSON.parse(JSON.stringify(r.data)),this.loadingAwards=!1})},setAwards(){this.awards=this.$cabSettings.VolunteerForm.Awards.map(r=>({value:r,text:r}))},loadAwards(){this.loadingAwards=!0,this.$axios.get(`/api/v1/user/awards/${this.$route.query.userId}`).then(r=>{this.user.awards=r.data,this.loadingAwards=!1})},onAdd(){this.newAward={awardDate:"",awardName:""}},onCancel(){this.newAward=null},onSave(){this.errorMessage=null,this.validate(),this.isFormValid()&&this.$axios.post(`/api/v1/user/awards/${this.$route.query.userId}`,this.newAward).then(r=>{this.newAward=null,this.user.awards=r.data}).catch(()=>{this.errorMessage="Failed to save award"})},onDelete(r){this.errorMessage=null,this.$axios.delete(`/api/v1/user/awards/${this.$route.query.userId}/${r.id}`).then(()=>{this.loadAwards()}).catch(()=>{this.errorMessage="Failed to remove award"})},validateName(){return this.newAward.awardName?{valid:!0}:{valid:!1,message:"Award name is required"}},validateDate(){if(!this.newAward.awardDate)return{valid:!1,message:"Award date is required"};const r=t(this.newAward.awardDate,"YYYY-MM-DD");return r.isValid()&&r.format("YYYY-MM-DD")===this.newAward.awardDate?{valid:!0}:{valid:!1,message:"Invalid date"}},validate(){d.set(this.validation,"awardName",this.validateName()),d.set(this.validation,"awardDate",this.validateDate())},isFormValid(){return!Object.entries(this.validation).find(r=>r[1].valid===!1)},formatDate(r){return t(r).format("DD/MM/YYYY")}}};var m=function(){var a=this,e=a._self._c;return e("div",{staticClass:"dashboard__awards"},[a.loadingAwards?a._e():e("div",{staticClass:"flex flex--align-center mb-4"},[e("div",{staticClass:"mr-2"},[e("user-circle",{attrs:{current:a.currentRole}})],1),a._v(" "),e("div",[a.user.name?e("h3",[a._v(a._s(a.user.name))]):a._e()])]),a._v(" "),e("div",{staticClass:"dashboard__awards-wrapper"},[e("h4",{staticClass:"mb-3"},[a._v("Awards and Certificates")]),a._v(" "),!a.loadingAwards&&a.user.awards.length?e("div",a._l(a.user.awards,function(s,i){return e("div",{key:i,staticClass:"dashboard__awards-award dashboard__awards-section"},[e("div",{staticClass:"dashboard__awards-award-details"},[e("label",[a._v(a._s(s.awardName))]),a._v(" "),e("div",[a._v("Awarded "+a._s(a.formatDate(s.awardDate)))])]),a._v(" "),e("a",{staticClass:"dashboard__awards-award-remove link-black",attrs:{href:""},on:{click:function(n){return n.preventDefault(),a.onDelete(s)}}},[e("icon",{attrs:{name:"trash-alt",scale:"0.9"}})],1)])}),0):a.newAward?a._e():e("div",{staticClass:"dashboard__awards-empty dashboard__awards-section"},[a._v(`
2      No awards or certificates to display
3    `)]),a._v(" "),a.newAward?e("div",{staticClass:"dashboard__awards-new dashboard__awards-section"},[e("div",{staticClass:"dashboard__awards-new-field"},[e("Dropdown",{attrs:{placeholder:"Choose option",label:"Award name",required:!0,flagRequired:!0,options:a.awards,validate:!1,validation:a.validation.awardName},model:{value:a.newAward.awardName,callback:function(s){a.$set(a.newAward,"awardName",s)},expression:"newAward.awardName"}})],1),a._v(" "),e("div",{staticClass:"dashboard__awards-new-field"},[e("TextField",{attrs:{placeholder:"dd/mm/yyyy",label:"Date awarded",required:!0,flagRequired:!0,type:"date",validation:a.validation.awardDate},model:{value:a.newAward.awardDate,callback:function(s){a.$set(a.newAward,"awardDate",s)},expression:"newAward.awardDate"}})],1)]):a._e(),a._v(" "),a.errorMessage?e("p",{staticClass:"error_message"},[a._v(`
4      `+a._s(a.errorMessage)+`
5    `)]):a._e(),a._v(" "),e("div",{staticClass:"dashboard__awards-actions mt-3"},[a.newAward?[e("a",{attrs:{href:"#"},on:{click:a.onCancel}},[a._v(`
6          Cancel
7        `)]),a._v(" "),e("button",{staticClass:"button button--blue",on:{click:function(s){return a.onSave()}}},[a._v(`
8          Save details
9        `)])]:e("button",{staticClass:"button button--blue",on:{click:function(s){return a.onAdd()}}},[a._v(`
10        Add award +
11      `)])],2)])])},f=[],A=w(_,m,f,!1,null,null);const C=A.exports;export{C 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.