Class { #name : 'MFTHomePage', #superclass : 'MFTPage', #category : 'MyFitnessTracker-Web-Components', #package : 'MyFitnessTracker-Web', #tag : 'Components' } { #category : 'rendering' } MFTHomePage >> renderContentOn: html [ html heading level: 1; with: self session user trainee currentRoutine canonicalName capitalized. self renderStatusOn: html; renderNextWorkoutPrescriptionOn: html; renderMainActionsOn: html. self session user trainee logBook workoutLogs ifNotEmpty: [ self renderWorkoutLogBookOn: html ] ] { #category : 'rendering' } MFTHomePage >> renderMainActionsOn: html [ | trainee | trainee := self session user trainee. html div: [ html anchor callback: [ | workoutLog | workoutLog := self call: (MFTWorkoutLogEditorPage forWorkoutPrescription: trainee nextWorkoutPrescription). workoutLog ifNotNil: [ trainee logWorkout: workoutLog ] ]; with: 'Log workout' ] ] { #category : 'rendering' } MFTHomePage >> renderNextWorkoutPrescriptionOn: html [ | workoutPrescription | workoutPrescription := self session user trainee nextWorkoutPrescription. html heading level: 2; with: 'Next workout'. html heading level: 3; with: workoutPrescription canonicalName. html render: (MFTWorkoutPrescriptionTable forPrescription: workoutPrescription) ] { #category : 'rendering' } MFTHomePage >> renderStatusOn: html [ | trainee | trainee := self session user trainee. html definitionList: [ trainee logBook durationSinceLastWorkout ifNotNil: [ html definitionTerm: 'Hours since last workout'; definitionData: trainee logBook durationSinceLastWorkout asHours rounded asString ]. html definitionTerm: 'Recovery status'; definitionData: (trainee isRecovered ifTrue: [ 'Fully recovered' ] ifFalse: [ 'Not recovered yet' ]) ] ] { #category : 'rendering' } MFTHomePage >> renderWorkoutLogBookOn: html [ html heading level: 2; with: 'Previous workouts'. html table style: 'max-width: 30rem'; with: [ html tableHead: [ html tableRow: [ html tableData: 'Date'; tableData: 'Name'; tableData: 'Volume'; tableData: 'Intensity' ] ]; tableBody: [ self session user trainee logBook workoutLogs reverseDo: [ :workoutLog | html tableRow: [ html tableData: workoutLog start asDate yyyymmdd; tableData: workoutLog canonicalName; tableData: workoutLog volume; tableData: workoutLog intensityFactor asString , '%' ] ] ] ] ] { #category : 'accessing' } MFTHomePage >> title [ ^ 'Home' ]