2022-11-01 16:17:52 +01:00
|
|
|
"use strict";(self["webpackChunkfittrackee_client"]=self["webpackChunkfittrackee_client"]||[]).push([[401],{2528:function(t,e,o){o.d(e,{Z:function(){return Q}});o(7658);var a=o(6252),n=o(3577),l=o(2262),r=o(9963),s=o(9150),i=o(2201),u=o(5801),d=o(9917),c=o(6558),p=o(8966),m=o(631),w=o(3649);const k={id:"workout-form"},f=["onSubmit"],_={class:"form-items"},v={key:0,class:"form-item-radio"},g=["checked","disabled"],y={for:"withGpx"},S=["checked","disabled"],U={for:"withoutGpx"},h={class:"form-item"},b=["disabled"],T=["value"],E={key:1,class:"form-item"},D={for:"gpxFile"},O=["disabled"],I={class:"files-help info-box"},A={key:2,class:"form-item"},C={for:"title"},R=["required","disabled"],$={key:3},N={class:"workout-date-duration"},x={class:"form-item"},z={class:"workout-date-time"},L=["disabled"],j=["disabled"],W={class:"form-item"},P=["disabled"],B=["disabled"],F=["disabled"],H={class:"form-item"},M=["disabled"],Z={class:"form-item"},q={key:1},G={key:2,class:"form-buttons"},K=["disabled"],Y=["onClick"];var V=(0,a.aZ)({__name:"WorkoutEdition",props:{authUser:null,sports:null,isCreation:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},workout:{default:()=>({})}},setup(t){const e=t,{t:o}=(0,s.QT)(),V=(0,d.o)(),J=(0,i.tv)(),{authUser:X,workout:Q,isCreation:tt,loading:et}=(0,l.BK)(e),ot=(0,a.Fl)((()=>(0,m.xH)(e.sports,o,"is_active_for_user",Q.value.id?[Q.value.sport_id]:[]))),at=(0,a.Fl)((()=>V.getters[u.SY.GETTERS.APP_CONFIG])),nt=at.value.max_single_file_size?(0,p.Z)(at.value.max_single_file_size):"",lt=at.value.gpx_limit_import,rt=at.value.max_zip_file_size?(0,p.Z)(at.value.max_zip_file_size):"",st=(0,a.Fl)((()=>V.getters[u.SY.GETTERS.ERROR_MESSAGES])),it=(0,l.qj)({sport_id:"",title:"",notes:"",workoutDate:"",workoutTime:"",workoutDurationHour:"",workoutDurationMinutes:"",workoutDurationSeconds:"",workoutDistance:""}),ut=(0,l.iH)(e.workout.id?e.workout.with_gpx:e.isCreation);let dt=null;const ct=(0,l.iH)(!1);function pt(t){it.notes=t}function mt(){ut.value=!ut.value,ct.value=!1}function wt(t){t.target.files&&(dt=t.target.files[0])}function kt(t){if(it.sport_id=`${t.sport_id}`,it.title=t.title,it.notes=t.notes,!t.with_gpx){const o=(0,c.Jo)((0,c.eB)(t.workout_date,e.authUser.timezone),"yyyy-MM-dd"),a=t.duration.split(":");it.workoutDistance=`${X.value.imperial_units?(0,w.sC)(t.distance,"km","mi",2):parseFloat(t.distance.toFixed(2))}`,it.workoutDate=o.workout_date,it.workoutTime=o.workout_time,it.workoutDurationHour=a[0],it.workoutDurationMinutes=a[1],it.workoutDurationSeconds=a[2]}}function ft(t){t.title=it.title,t.distance=X.value.imperial_units?(0,w.sC)(+it.workoutDistance,"mi","km",3):+it.workoutDistance,t.duration=3600*+it.workoutDurationHour+60*+it.workoutDurationMinutes+ +it.workoutDurationSeconds,t.workout_date=`${it.workoutDate} ${it.workoutTime}`}function _t(){const t={sport_id:+it.sport_id,notes:it.notes};if(e.workout.id)e.workout.with_gpx?t.title=it.title:ft(t),V.dispatch(u.aX.ACTIONS.EDIT_WORKOUT,{workoutId:e.workout.id,data:t});else if(ut.value){if(!dt){const t="workouts.NO_FILE_PROVIDED";return void V.commit(u.SY.MUTATIONS.SET_ERROR_MESSAGES,t)}t.file=dt,V.dispatch(u.aX.ACTIONS.ADD_WORKOUT,t)}else ft(t),V.dispatch(u.aX.ACTIONS.ADD_WORKOUT_WITHOUT_GPX,t)}function vt(){e.workout.id?J.push({name:"Workout",params:{workoutId:e.workout.id}}):J.go(-1)}function gt(){ct.value=!0}return(0,a.bv)((()=>{e.workout.id&&kt(e.workout)})),(0,a.Ah)((()=>V.commit(u.SY.MUTATIONS.EMPTY_ERROR_MESSAGES))),(0,a.YP)((()=>e.workout),(async(t,e)=>{t!==e&&t&&t.id&&kt(t)})),(t,e)=>{const o=(0,a.up)("CustomTextArea"),s=(0,a.up)("ErrorMessage"),i=(0,a.up)("Loader"),u=(0,a.up)("Card");return(0,a.wg)(),(0,a.iD)("div",{id:"workout-edition",class:(0,n.C_)(["center-card with-margin",{"center-form":(0,l.SU)(Q)&&(0,l.SU)(Q).with_gpx}])},[(0,a.Wm)(u,null,{title:(0,a.w5)((()=>[(0,a.Uk)((0,n.zw)(t.$t(`workouts.${(0,l.SU)(tt)?"ADD":"EDIT"}_WORKOUT`)),1)])),content:(0,a.w5)((()=>[(0,a._)("div",k,[(0,a._)("form",{class:(0,n.C_)({errors:ct.value}),onSubmit:(0,r.iM)(_t,["prevent"])},[(0,a._)("div",_,[(0,l.SU)(tt)?((0,a.wg)(),(0,a.iD)("div",v,[(0,a.
|