@dev-crew-berlin/enter-js-utils 0.20.0 → 0.21.0

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.
@@ -8,7 +8,7 @@ export declare type AttendeeJSON = {
8
8
  userdata: Record<string, FieldValue>;
9
9
  tags: string[] | null;
10
10
  language: string | null;
11
- time: Date;
11
+ time: string;
12
12
  rsvp: Record<string, number | null>;
13
13
  checkin: Record<string, CheckinsJSON>;
14
14
  companions: {
@@ -48,6 +48,7 @@ export declare class Attendee {
48
48
  } | null;
49
49
  deleted: boolean;
50
50
  constructor(rawAttendee: RawAttendee);
51
+ toJSON(): AttendeeJSON;
51
52
  getRsvpCountForTag(checkinTag: string): number;
52
53
  getResponseForTag(checkinTag: string): 'no-response' | 'negative-repsone' | 'positive-response';
53
54
  getCheckinsForTag(checkinTag: string): Checkins;
@@ -18,6 +18,21 @@ export class Attendee {
18
18
  this.deleted = rawAttendee.deleted;
19
19
  }
20
20
 
21
+ toJSON() {
22
+ // this is exactly what js also provides out of the box
23
+ // but then typescript complains that there is no toJSON function
24
+ // so we implement it here again by hand
25
+ // convert each checkin to its json representation
26
+ const checkin = Object.entries(this.checkin).reduce((obj, [tag, checkins]) => {
27
+ obj[tag] = checkins.toJSON();
28
+ return obj;
29
+ }, {});
30
+ return { ...this,
31
+ time: this.time.toISOString(),
32
+ checkin
33
+ };
34
+ }
35
+
21
36
  getRsvpCountForTag(checkinTag) {
22
37
  const rsvp = this.rsvp[checkinTag];
23
38
  if (!rsvp) return 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-crew-berlin/enter-js-utils",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "utils such as vaildation and other helpers to work with data from the enter app",
5
5
  "files": [
6
6
  "dist",