mirror of
https://github.com/sstent/aicyclingcoach-go.git
synced 2026-02-21 06:36:05 +00:00
1 line
9.9 KiB
JavaScript
1 line
9.9 KiB
JavaScript
"use strict";exports.id=928,exports.ids=[928],exports.modules={6745:(e,t,r)=>{function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"default",{enumerable:!0,get:function(){return c}});let i=r(167),o=r(997),s=i._(r(6689)),a=r(9642);async function l(e){let{Component:t,ctx:r}=e;return{pageProps:await (0,a.loadGetInitialProps)(t,r)}}class c extends s.default.Component{render(){let{Component:e,pageProps:t}=this.props;return(0,o.jsx)(e,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach(function(t){var n,i;n=t,i=r[t],(n=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},t))}}c.origGetInitialProps=l,c.getInitialProps=l,("function"==typeof t.default||"object"==typeof t.default&&null!==t.default)&&void 0===t.default.__esModule&&(Object.defineProperty(t.default,"__esModule",{value:!0}),Object.assign(t.default,t),e.exports=t.default)},2935:(e,t,r)=>{r.a(e,async(e,n)=>{try{r.d(t,{Z:()=>u});var i=r(6689),o=r(7101),s=e([o]);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function l(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach(function(t){var n,i;n=t,i=r[t],(n=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}o=(s.then?(await s)():s)[0];let c=({workout:e,onClose:t,onSave:r})=>{let{0:n,1:s}=(0,i.useState)({type:"",duration_minutes:0,intensity:"",description:""});(0,i.useEffect)(()=>{e&&s({type:e.type||"",duration_minutes:e.duration_minutes||0,intensity:e.intensity||"",description:e.description||""})},[e]);let a=e=>{let{name:t,value:r}=e.target;s(e=>l(l({},e),{},{[t]:r}))};return e?o.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",children:(0,o.jsxs)("div",{className:"bg-white rounded-lg p-6 w-full max-w-md",children:[o.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Edit Workout"}),(0,o.jsxs)("form",{onSubmit:e=>{e.preventDefault(),r(n)},children:[(0,o.jsxs)("div",{className:"space-y-4",children:[(0,o.jsxs)("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Workout Type"}),o.jsx("input",{type:"text",name:"type",value:n.type,onChange:a,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,o.jsxs)("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Duration (minutes)"}),o.jsx("input",{type:"number",name:"duration_minutes",value:n.duration_minutes,onChange:a,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]}),(0,o.jsxs)("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Intensity"}),(0,o.jsxs)("select",{name:"intensity",value:n.intensity,onChange:a,className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500",children:[o.jsx("option",{value:"",children:"Select intensity"}),o.jsx("option",{value:"zone_1",children:"Zone 1 (Easy)"}),o.jsx("option",{value:"zone_2",children:"Zone 2 (Moderate)"}),o.jsx("option",{value:"zone_3",children:"Zone 3 (Tempo)"}),o.jsx("option",{value:"zone_4",children:"Zone 4 (Threshold)"}),o.jsx("option",{value:"zone_5",children:"Zone 5 (VO2 Max)"})]})]}),(0,o.jsxs)("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Description"}),o.jsx("textarea",{name:"description",value:n.description,onChange:a,rows:"3",className:"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"})]})]}),(0,o.jsxs)("div",{className:"flex justify-end space-x-3 mt-6",children:[o.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-gray-700 bg-gray-200 rounded-md hover:bg-gray-300",children:"Cancel"}),o.jsx("button",{type:"submit",className:"px-4 py-2 text-white bg-blue-600 rounded-md hover:bg-blue-700",children:"Save"})]})]})]})}):null};c.defaultProps={workout:null};let u=c;n()}catch(e){n(e)}})},9729:(e,t,r)=>{r.a(e,async(e,n)=>{try{r.d(t,{Z:()=>p});var i=r(6689),o=r(263),s=r(9648),a=r(8041),l=r(2935),c=r(7101),u=e([o,s,a,l,c]);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}[o,s,a,l,c]=u.then?(await u)():u;let p=({plan:e,mode:t="view"})=>{let{apiKey:r}=(0,o.a)(),{0:n,1:u}=(0,i.useState)(e?.jsonb_plan),{0:p,1:f}=(0,i.useState)(!1),{0:b,1:m}=(0,i.useState)(null),{0:y,1:j}=(0,i.useState)(0),v=async i=>{try{let o=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach(function(t){var n,i;n=t,i=r[t],(n=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}({},n);o.weeks[y].workouts=o.weeks[y].workouts.map(e=>e.day===i.day?i:e),"edit"===t&&await s.default.put(`/api/plans/${e.id}`,o,{headers:{"X-API-Key":r}}),u(o),f(!1)}catch(e){console.error("Error updating workout:",e)}};return(0,c.jsxs)("div",{className:"bg-white p-6 rounded-lg shadow-md",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,c.jsxs)("h3",{className:"text-xl font-semibold",children:[n?.plan_overview?.focus," Training Plan"]}),(0,c.jsxs)("div",{className:"text-gray-600",children:[n?.plan_overview?.duration_weeks," weeks •",n?.plan_overview?.weekly_hours," hrs/week"]})]}),c.jsx("div",{className:"space-y-8",children:n?.weeks?.map((e,r)=>c.jsxs("div",{className:"border-l-2 border-blue-100 pl-4",children:[c.jsxs("div",{className:"flex items-center justify-between mb-4",children:[c.jsxs("h4",{className:"font-medium",children:["Week ",r+1,": ",e.focus]}),c.jsxs("div",{className:"flex items-center space-x-2",children:[c.jsx("div",{className:"h-2 w-24 bg-gray-200 rounded-full",children:c.jsx("div",{className:"h-full bg-blue-600 rounded-full",style:{width:`${(r+1)/n.plan_overview.duration_weeks*100}%`}})}),c.jsxs("span",{className:"text-sm text-gray-600",children:[e.workouts.length," workouts"]})]})]}),c.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:e.workouts.map((e,n)=>c.jsx(a.Z,{workout:e,onEdit:()=>{j(r),m(e),f(!0)},editable:"edit"===t},`${r}-${n}`))})]},r))}),p&&c.jsx(l.Z,{workout:b,onClose:()=>f(!1),onSave:v})]})};n()}catch(e){n(e)}})},8041:(e,t,r)=>{r.a(e,async(e,n)=>{try{r.d(t,{Z:()=>a});var i=r(7101),o=e([i]);i=(o.then?(await o)():o)[0];let s=({workout:e,onEdit:t,editable:r})=>(0,i.jsxs)("div",{className:"border rounded-lg p-4 bg-white shadow-sm",children:[(0,i.jsxs)("div",{className:"flex justify-between items-start mb-2",children:[i.jsx("h5",{className:"font-medium capitalize",children:e?.type?.replace("_"," ")||"Workout"}),r&&i.jsx("button",{onClick:t,className:"text-blue-600 hover:text-blue-800 text-sm",children:"Edit"})]}),(0,i.jsxs)("div",{className:"text-sm text-gray-600 space-y-1",children:[(0,i.jsxs)("div",{children:["Duration: ",e?.duration_minutes||0," minutes"]}),(0,i.jsxs)("div",{children:["Intensity: ",e?.intensity||"N/A"]}),e?.description&&i.jsx("div",{className:"mt-2 text-gray-700",children:e.description})]})]});s.defaultProps={workout:{},onEdit:()=>{},editable:!1};let a=s;n()}catch(e){n(e)}})},263:(e,t,r)=>{r.a(e,async(e,n)=>{try{r.d(t,{a:()=>c});var i=r(6689),o=r(3590),s=r(7101),a=e([o,s]);[o,s]=a.then?(await a)():a;let l=(0,i.createContext)(),c=()=>((0,i.useContext)(l),{apiKey:null,authFetch:()=>{},loading:!1});n()}catch(e){n(e)}})},1323:(e,t)=>{Object.defineProperty(t,"l",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},5244:(e,t)=>{var r;Object.defineProperty(t,"x",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE"}(r||(r={}))}}; |