@plus45/types 1.1.38 → 1.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  CompletedExercise,
18
18
  WorkoutExecution
19
19
  } from "./types/workout/workout_execution";
20
+ import { WeekLayout } from "./types/generics/week_layout";
20
21
 
21
22
  export {
22
23
  // User Type Structures
@@ -36,6 +37,9 @@ export {
36
37
  type Schedule,
37
38
  type AssignedSchedule,
38
39
 
40
+ // Generics
41
+ type WeekLayout,
42
+
39
43
  // Enums
40
44
  ExerciseType,
41
45
  ExerciseUnit,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plus45/types",
3
- "version": "1.1.38",
3
+ "version": "1.1.39",
4
4
  "main": "index.ts",
5
5
  "types": "index.ts"
6
6
  }
@@ -0,0 +1,53 @@
1
+ export class WeekLayout<T> {
2
+ Sunday: Array<T>;
3
+ Monday: Array<T>;
4
+ Tuesday: Array<T>;
5
+ Wednesday: Array<T>;
6
+ Thursday: Array<T>;
7
+ Friday: Array<T>;
8
+ Saturday: Array<T>;
9
+
10
+ constructor(
11
+ Sunday?: Array<T>,
12
+ Monday?: Array<T>,
13
+ Tuesday?: Array<T>,
14
+ Wednesday?: Array<T>,
15
+ Thursday?: Array<T>,
16
+ Friday?: Array<T>,
17
+ Saturday?: Array<T>
18
+ ) {
19
+ this.Sunday = Sunday ?? [];
20
+ this.Monday = Monday ?? [];
21
+ this.Tuesday = Tuesday ?? [];
22
+ this.Wednesday = Wednesday ?? [];
23
+ this.Thursday = Thursday ?? [];
24
+ this.Friday = Friday ?? [];
25
+ this.Saturday = Saturday ?? [];
26
+ }
27
+
28
+ private getDayFromIndex = [
29
+ "Sunday",
30
+ "Monday",
31
+ "Tuesday",
32
+ "Wednesday",
33
+ "Thursday",
34
+ "Friday",
35
+ "Saturday"
36
+ ];
37
+
38
+ /**
39
+ * 0 = Sunday, 6 = Saturday
40
+ */
41
+ public setDay(index: number, value: T[]) {
42
+ const day = this.getDayFromIndex[index] as keyof WeekLayout<T>;
43
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
+ (this as any)[day] = value;
45
+ }
46
+
47
+ public addToDay(index: number, value: T) {
48
+ const day = this.getDayFromIndex[index] as keyof WeekLayout<T>;
49
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
+ const toAddTo = (this as any)[day] as T[];
51
+ toAddTo.push(value);
52
+ }
53
+ }
@@ -1,7 +1,9 @@
1
+ import { Workout } from "../workout/workout";
2
+
1
3
  export type Schedule = {
2
4
  id: string;
3
5
  user_id: string;
4
- workout_id: string;
6
+ workout: Workout;
5
7
  days_of_week: number[];
6
8
  created_at: string;
7
9
  start_time: string;