Browse Source

Display date for autofilled exercise data.

Lee Morgan 1 year ago
parent
commit
fb01032ff0
1 changed files with 12 additions and 2 deletions
  1. 12 2
      views/js/pages/session.js

+ 12 - 2
views/js/pages/session.js

@@ -242,8 +242,10 @@ export default {
         for(let i = 0; i < this.pastSessions.length; i++){
             for(let j = 0; j < this.pastSessions[i].exercises.length; j++){
                 if(this.pastSessions[i].exercises[j]?.exerciseId === id){
-                    note.textContent = "*Data autofilled from previous workout";
-                    return this.pastSessions[i].exercises[j].sets;
+                    const exercise = this.pastSessions[i].exercises[j];
+                    const date = new Date(this.pastSessions[i].start);
+                    note.textContent = `*Data autofilled from ${this.getDate(date)}`;
+                    return exercise.sets;
                 }
             }
         }
@@ -278,5 +280,13 @@ export default {
             .catch((err)=>{
                 notify("error", "ERROR: unable to save workout to database");
             });
+    },
+
+    getDate: function(date){
+        return date.toLocaleDateString("en-US", {
+            year: "numeric",
+            month: "long",
+            day: "numeric"
+        });
     }
 }