text: (window.webpackJsonp=window.webpackJsonp||[]).push([[36],{124:function(e,t,r){"use strict";r.r(t);var n=r(0),o=r.n(n),a=r(11),s=r.n(a);r(16);function c(e,t,r,n,o,a,s){try{var c=e[a](s),i=c.value}catch(e){return void r(e)}c.done?t(i):Promise.resolve(i).then(n,o)}function i(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function s(e){c(a,n,o,s,i,"next",e)}function i(e){c(a,n,o,s,i,"throw",e)}s(void 0)})}}var l={components:{VueCtkDateTimePicker:s.a},created:function(){var e=i(o.a.mark(function e(){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(!(Object.entries(this.$store.getters["performances/performances"]).length<=1)){e.next=3;break}return e.next=3,this.$store.dispatch("performances/fetchPerformances");case 3:if(!(this.$store.getters["shows/shows"].length<1)){e.next=6;break}return e.next=6,this.$store.dispatch("shows/fetchShows");case 6:case"end":return e.stop()}},e,this)}));return function(){return e.apply(this,arguments)}}(),data:function(){return{newPerformance:{show_id:"",name:"ABC",date:"2020-02-25",location:"Beausobre, Morges",is_sold_out:!1}}},computed:{loading:function(){return this.$store.getters["loading/loading"]},shows:function(){return this.$store.getters["shows/shows"]},performances:function(){return this.$store.getters["performances/performances"]}},methods:{addNewPerformance:function(){var e=i(o.a.mark(function e(){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,console.log("addNewPerformance: ",this.newPerformance),this.$store.commit("loading/SET_LOADING",!0),e.next=5,this.$store.dispatch("performances/createPerformance",{newPerformance:this.newPerformance});case 5:this.$store.commit("loading/SET_LOADING",!1),this.$noty.success("Nouveau spectacle créé avec succès."),this.$router.push("/admin/performances"),e.next=14;break;case 10:e.prev=10,e.t0=e.catch(0),this.$store.commit("loading/SET_LOADING",!1),this.$noty.error("Une erreur est survenue et le nouveau spectacle n'a pas pu être crée.");case 14:case"end":return e.stop()}},e,this,[[0,10]])}));return function(){return e.apply(this,arguments)}}()}},u=r(2),m=Object(u.a)(l,function(){var e=this,t=e.$createElement,r=e._self._c||t;return r("b-container",[r("b-breadcrumb",[r("b-breadcrumb-item",{staticClass:"navigation",attrs:{to:"/admin/performances"}},[r("font-awesome-icon",{attrs:{icon:"calendar-day"}}),e._v(" "),r("span",[e._v("Représentations")])],1),e._v(" "),r("b-breadcrumb-item",{attrs:{active:""}},[e._v("Créer")])],1),e._v(" "),r("h2",{staticClass:"text-center"},[e._v("Ajouter nouvelle représentation")]),e._v(" "),r("b-form",{on:{submit:function(t){return t.preventDefault(),e.addNewPerformance(t)}}},[r("b-row",{staticClass:"justify-content-start my-3 px-3",attrs:{"align-v":"center"}},[r("b-col",{attrs:{cols:"12",md:"6"}},[r("b-form-group",{attrs:{label:"Entrer un nom pour ce spectacle:","label-for":"newPerformanceName"}},[r("b-form-input",{attrs:{id:"newPerformanceName",placeholder:"Nom de la représentation"},model:{value:e.newPerformance.name,callback:function(t){e.$set(e.newPerformance,"name",t)},expression:"newPerformance.name"}})],1)],1),e._v(" "),r("b-col",{attrs:{cols:"12",md:"6"}},[r("b-form-group",{attrs:{label:"Entrer un lieu pour ce spectacle:","label-for":"newPerformanceLocation"}},[r("b-form-input",{attrs:{id:"newPerformanceLocation",placeholder:"Lieu de la représentation"},model:{value:e.newPerformance.location,callback:function(t){e.$set(e.newPerformance,"location",t)},expression:"newPerformance.location"}})],1)],1),e._v(" "),r("b-col",{attrs:{cols:"12",md:"6"}},[r("b-form-group",{attrs:{label:"Entrer une date:","label-for":"newPerformanceDate"}},[r("VueCtkDateTimePicker",{attrs:{label:"Cliquer pour choisir une date",format:"YYYY-MM-DD",formatted:"YYYY-MM-DD",color:"#9ACD32","button-color":"#9ACD32","button-now-translation":"Aujourd'hui","only-date":"",id:"newPerformanceDate"},model:{value:e.newPerformance.date,callback:function(t){e.$set(e.newPerformance,"date",t)},expression:"newPerformance.date"}})],1)],1),e._v(" "),r("b-col",{attrs:{cols:"12",md:"6"}},[r("b-form-group",{attrs:{label:"Sélectionner le spectacle:","label-for":"newPerformanceShow"}})],1),e._v(" "),r("b-col",{attrs:{cols:"12",md:"6"}},[r("b-form-checkbox",{attrs:{id:"newPerformanceIsSoldOut"},model:{value:e.newPerformance.is_sold_out,callback:function(t){e.$set(e.newPerformance,"is_sold_out",t)},expression:"newPerformance.is_sold_out"}},[e._v("\n\t\t\t\t\t\tLa représentation est "+e._s(e.newPerformance.is_sold_out?"complète":"libre")+"\n\t\t\t\t\t")])],1)],1),e._v(" "),r("b-row",{staticClass:"justify-content-center my-2"},[r("b-button",{attrs:{variant:"primary",type:"submit",disabled:e.loading||!e.newPerformance.show_id}},[e.loading?r("b-spinner",{attrs:{small:"",type:"grow"}}):e._e(),e._v("\n                \tCréer la représentation\n                ")],1),r("br")],1)],1)],1)},[],!1,null,"1b5527f7",null);t.default=m.exports}}]);