@dev-crew-berlin/enter-js-utils 0.88.1 → 0.90.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.
- package/dist/lib/tokens.d.ts +1 -0
- package/dist/lib/tokens.js +3 -2
- package/dist/models/attendee.d.ts +2 -0
- package/dist/models/attendee.js +8 -3
- package/dist/models/checkins.d.ts +1 -0
- package/dist/models/checkins.js +4 -0
- package/dist/models/rsvp.d.ts +1 -0
- package/dist/models/rsvp.js +4 -0
- package/dist/ui/companion-info.d.ts +1 -3
- package/dist/ui/companion-info.js +2 -4
- package/dist/ui/companion-info.stories.d.ts +1 -2
- package/dist/ui/companion-info.stories.js +4 -49
- package/dist/ui/guest-card.d.ts +0 -1
- package/dist/ui/guest-card.js +1 -3
- package/dist/ui/guest-card.stories.js +11 -13
- package/package.json +2 -1
package/dist/lib/tokens.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export declare function parseUnsubscribeToken(tokenString: string | undefined, o
|
|
|
33
33
|
export declare function parseEmailHtmlToken(tokenString: string | undefined, options: TokenOptions): Result<TokenValidationError, {
|
|
34
34
|
attendeeId: string;
|
|
35
35
|
emailName: string;
|
|
36
|
+
mailingId: string | null;
|
|
36
37
|
}>;
|
|
37
38
|
export declare function readRegistrationToken(getCookie: CookieGetter, options: TokenOptions & RegistrationTokenOptions): Result<TokenValidationError, RegistrationToken>;
|
|
38
39
|
export declare function storeRegistrationToken(token: string, setCookie: CookieSetter, options?: RegistrationTokenOptions): void;
|
package/dist/lib/tokens.js
CHANGED
|
@@ -58,7 +58,7 @@ export function parseEmailHtmlToken(tokenString, options) {
|
|
|
58
58
|
const tokenResult = parseJWS(tokenString, options);
|
|
59
59
|
if (!tokenResult.success) return tokenResult;
|
|
60
60
|
const payload = tokenResult.data.payload;
|
|
61
|
-
if (payload.instance_name !== options.instanceName || typeof payload.attendee_id !== 'string' || typeof payload.email_name !== 'string' || typeof payload.exp !== 'number') {
|
|
61
|
+
if (payload.instance_name !== options.instanceName || typeof payload.attendee_id !== 'string' || typeof payload.email_name !== 'string' || payload.mailing_id != undefined && typeof payload.mailing_id !== 'string' || typeof payload.exp !== 'number') {
|
|
62
62
|
return failure('token_invalid');
|
|
63
63
|
}
|
|
64
64
|
const now = new Date();
|
|
@@ -67,7 +67,8 @@ export function parseEmailHtmlToken(tokenString, options) {
|
|
|
67
67
|
if (isExpired) return failure('token_expired');
|
|
68
68
|
return success({
|
|
69
69
|
attendeeId: payload.attendee_id,
|
|
70
|
-
emailName: payload.email_name
|
|
70
|
+
emailName: payload.email_name,
|
|
71
|
+
mailingId: payload.mailing_id ?? null
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
export function readRegistrationToken(getCookie, options) {
|
|
@@ -26,6 +26,7 @@ export declare class Attendee {
|
|
|
26
26
|
} | {
|
|
27
27
|
isCompanion: true;
|
|
28
28
|
mainGuestId: string;
|
|
29
|
+
mainGuestName: string;
|
|
29
30
|
};
|
|
30
31
|
payment: Payment | null;
|
|
31
32
|
deleted: boolean;
|
|
@@ -39,6 +40,7 @@ export declare class Attendee {
|
|
|
39
40
|
*/
|
|
40
41
|
static generateID(prefix: string): string;
|
|
41
42
|
toJSON(): AttendeeJSON;
|
|
43
|
+
hash(): string;
|
|
42
44
|
getRsvpCountForBranch(branchName: string): number;
|
|
43
45
|
getRsvpCount(branchName: string, counterName: string): number;
|
|
44
46
|
getResponseForBranch(branchName: string): 'no-response' | 'negative-response' | 'positive-response';
|
package/dist/models/attendee.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import hash from 'stable-hash';
|
|
2
3
|
import { Checkins } from './checkins';
|
|
3
4
|
import { Rsvp } from './rsvp';
|
|
4
5
|
export class Attendee {
|
|
@@ -30,11 +31,12 @@ export class Attendee {
|
|
|
30
31
|
this.rsvp = new Map(Object.entries(json.rsvp ?? {}).map(([checkinTag, rsvp]) => [checkinTag, rsvp ? new Rsvp(rsvp) : null]));
|
|
31
32
|
this.checkin = new Map(Object.entries(json.checkin ?? {}).map(([checkinTag, checkin]) => [checkinTag, new Checkins(checkin)]));
|
|
32
33
|
this.companions = json.companions?.isCompanion ? {
|
|
34
|
+
...json.companions,
|
|
33
35
|
isCompanion: true,
|
|
34
|
-
|
|
36
|
+
mainGuestName: json.companions.mainGuestName ?? json.companions.mainGuestId
|
|
35
37
|
} : {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
...json.companions,
|
|
39
|
+
isCompanion: false
|
|
38
40
|
};
|
|
39
41
|
this.payment = json.payment ?? null;
|
|
40
42
|
this.deleted = json.deleted ?? false;
|
|
@@ -73,6 +75,9 @@ export class Attendee {
|
|
|
73
75
|
rsvp
|
|
74
76
|
};
|
|
75
77
|
}
|
|
78
|
+
hash() {
|
|
79
|
+
return hash([this.id, Array.from(this.userdata), Array.from(this.tags), this.language, this.time, Array.from(this.branches), Array.from(this.rsvp).map(([counterName, rsvp]) => [counterName, rsvp?.hash()]), Array.from(this.checkin).map(([counterName, checkin]) => [counterName, checkin?.hash()]), this.companions, this.payment, this.deleted]);
|
|
80
|
+
}
|
|
76
81
|
getRsvpCountForBranch(branchName) {
|
|
77
82
|
const rsvp = this.rsvp.get(branchName);
|
|
78
83
|
if (!rsvp) return 0;
|
package/dist/models/checkins.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import hash from 'stable-hash';
|
|
1
2
|
import { Checkin } from './checkin';
|
|
2
3
|
export class Checkins {
|
|
3
4
|
checkins = [];
|
|
@@ -14,6 +15,9 @@ export class Checkins {
|
|
|
14
15
|
deleted: Array.from(this.deleted)
|
|
15
16
|
};
|
|
16
17
|
}
|
|
18
|
+
hash() {
|
|
19
|
+
return hash([this.checkins.map(checkin => checkin.id), Array.from(this.deleted)]);
|
|
20
|
+
}
|
|
17
21
|
getActiveCheckins(counterName = 'main') {
|
|
18
22
|
return this.checkins.filter(checkin => checkin.counterName === counterName && !this.deleted.has(checkin.id));
|
|
19
23
|
}
|
package/dist/models/rsvp.d.ts
CHANGED
package/dist/models/rsvp.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import hash from 'stable-hash';
|
|
2
3
|
export class Rsvp {
|
|
3
4
|
constructor(args) {
|
|
4
5
|
if (typeof args == 'number') {
|
|
@@ -34,4 +35,7 @@ export class Rsvp {
|
|
|
34
35
|
checkinCounters: Array.from(this.checkinCounters)
|
|
35
36
|
};
|
|
36
37
|
}
|
|
38
|
+
hash() {
|
|
39
|
+
return hash([this.tieBreaker, this.time, this.personCount, Array.from(this.checkinCounters)]);
|
|
40
|
+
}
|
|
37
41
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
2
|
import 'styled-jsx';
|
|
3
|
-
import { Attendee } from '../models';
|
|
4
3
|
type Props = {
|
|
5
4
|
companionStatus: {
|
|
6
5
|
isCompanion: false;
|
|
7
6
|
} | {
|
|
8
7
|
isCompanion: true;
|
|
9
8
|
mainGuestId: string;
|
|
9
|
+
mainGuestName: string;
|
|
10
10
|
};
|
|
11
|
-
formatName: (attendee: Attendee) => string;
|
|
12
|
-
findMainGuest?: (attendeeId: string) => Attendee | undefined;
|
|
13
11
|
};
|
|
14
12
|
export declare const CompanionInfo: FunctionComponent<Props>;
|
|
15
13
|
export {};
|
|
@@ -4,13 +4,11 @@ import 'styled-jsx';
|
|
|
4
4
|
import { colors, fonts } from '../lib/theme';
|
|
5
5
|
export const CompanionInfo = props => {
|
|
6
6
|
if (!props.companionStatus.isCompanion) return null;
|
|
7
|
-
const mainGuest = props.findMainGuest ? props.findMainGuest(props.companionStatus.mainGuestId) : undefined;
|
|
8
|
-
const mainGuestName = mainGuest ? props.formatName(mainGuest) : undefined;
|
|
9
7
|
return /*#__PURE__*/React.createElement("p", {
|
|
10
8
|
className: _JSXStyle.dynamic([["21346984", [colors.enterMediumGrey, fonts.primary, colors.enterDarkGrey]]]) + " " + 'companion-info'
|
|
11
|
-
},
|
|
9
|
+
}, "companion of", ' ', /*#__PURE__*/React.createElement("span", {
|
|
12
10
|
className: _JSXStyle.dynamic([["21346984", [colors.enterMediumGrey, fonts.primary, colors.enterDarkGrey]]]) + " " + 'companion-name'
|
|
13
|
-
},
|
|
11
|
+
}, props.companionStatus.mainGuestName), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
14
12
|
id: "21346984",
|
|
15
13
|
dynamic: [colors.enterMediumGrey, fonts.primary, colors.enterDarkGrey]
|
|
16
14
|
}, `.companion-info.__jsx-style-dynamic-selector{margin:-0.5em 0 0.4em;color:${colors.enterMediumGrey};font-family:${fonts.primary};}.companion-name.__jsx-style-dynamic-selector{color:${colors.enterDarkGrey};}`));
|
|
@@ -3,6 +3,5 @@ import { CompanionInfo } from './companion-info';
|
|
|
3
3
|
declare const meta: Meta<typeof CompanionInfo>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof CompanionInfo>;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const WithoutMainGuest: Story;
|
|
6
|
+
export declare const WithMainGuest: Story;
|
|
8
7
|
export declare const NotACompanion: Story;
|
|
@@ -1,57 +1,15 @@
|
|
|
1
1
|
import { CompanionInfo } from './companion-info';
|
|
2
|
-
import { Attendee } from '../models';
|
|
3
2
|
const meta = {
|
|
4
3
|
title: 'Companion Info',
|
|
5
|
-
component: CompanionInfo
|
|
6
|
-
argTypes: {
|
|
7
|
-
formatName: {
|
|
8
|
-
type: 'function'
|
|
9
|
-
}
|
|
10
|
-
}
|
|
4
|
+
component: CompanionInfo
|
|
11
5
|
};
|
|
12
6
|
export default meta;
|
|
13
|
-
const
|
|
14
|
-
id: 'my-attendee',
|
|
15
|
-
language: 'de',
|
|
16
|
-
tags: ['VIP', 'Import-200-02-10'],
|
|
17
|
-
time: new Date('2022-01-01').toISOString(),
|
|
18
|
-
rsvp: {
|
|
19
|
-
default: {
|
|
20
|
-
personCount: 1,
|
|
21
|
-
time: new Date('2022-01-01').toISOString(),
|
|
22
|
-
tieBreaker: '1'
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
checkin: {},
|
|
26
|
-
companions: {
|
|
27
|
-
isCompanion: false
|
|
28
|
-
},
|
|
29
|
-
userdata: {
|
|
30
|
-
name: 'Max Mustermann'
|
|
31
|
-
},
|
|
32
|
-
deleted: false,
|
|
33
|
-
payment: null
|
|
34
|
-
});
|
|
35
|
-
export const WithMainGuestFound = {
|
|
36
|
-
args: {
|
|
37
|
-
companionStatus: {
|
|
38
|
-
isCompanion: true,
|
|
39
|
-
mainGuestId: 'my-attendee'
|
|
40
|
-
},
|
|
41
|
-
findMainGuest: () => mainGuest,
|
|
42
|
-
formatName(attendee) {
|
|
43
|
-
return attendee.getFieldValueString('name');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
export const WithoutMainGuest = {
|
|
7
|
+
export const WithMainGuest = {
|
|
48
8
|
args: {
|
|
49
9
|
companionStatus: {
|
|
50
10
|
isCompanion: true,
|
|
51
|
-
mainGuestId: 'my-attendee'
|
|
52
|
-
|
|
53
|
-
formatName(attendee) {
|
|
54
|
-
return attendee.getFieldValueString('name');
|
|
11
|
+
mainGuestId: 'my-attendee',
|
|
12
|
+
mainGuestName: 'Max Mustermann'
|
|
55
13
|
}
|
|
56
14
|
}
|
|
57
15
|
};
|
|
@@ -59,9 +17,6 @@ export const NotACompanion = {
|
|
|
59
17
|
args: {
|
|
60
18
|
companionStatus: {
|
|
61
19
|
isCompanion: false
|
|
62
|
-
},
|
|
63
|
-
formatName(attendee) {
|
|
64
|
-
return attendee.getFieldValueString('name');
|
|
65
20
|
}
|
|
66
21
|
}
|
|
67
22
|
};
|
package/dist/ui/guest-card.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ type Props = {
|
|
|
11
11
|
formatName: (attendee: Attendee) => string;
|
|
12
12
|
filterTags?: (tag: string) => boolean;
|
|
13
13
|
getTagColor?: (tag: string) => string | undefined;
|
|
14
|
-
findMainGuest?: (attendeeId: string) => Attendee | undefined;
|
|
15
14
|
onClick?: (attendeeId: string) => void;
|
|
16
15
|
};
|
|
17
16
|
export declare const GuestCard: FunctionComponent<Props>;
|
package/dist/ui/guest-card.js
CHANGED
|
@@ -37,9 +37,7 @@ export const GuestCard = props => {
|
|
|
37
37
|
}, /*#__PURE__*/React.createElement("h2", {
|
|
38
38
|
className: _JSXStyle.dynamic([["1739379681", [colors.enterGrey, colors.enterBackground, fonts.primary, props.dense ? '0.5em 0' : '1.5em 0']]]) + " " + 'name'
|
|
39
39
|
}, props.formatName(props.attendee)), /*#__PURE__*/React.createElement(CompanionInfo, {
|
|
40
|
-
companionStatus: props.attendee.companions
|
|
41
|
-
findMainGuest: props.findMainGuest,
|
|
42
|
-
formatName: props.formatName
|
|
40
|
+
companionStatus: props.attendee.companions
|
|
43
41
|
}), /*#__PURE__*/React.createElement(CheckinCountIndicator, {
|
|
44
42
|
checkins: props.attendee.getCheckinsForBranch(props.branchName).getActiveCheckins(props.counterName),
|
|
45
43
|
response: props.attendee.getResponse(props.branchName, props.counterName),
|
|
@@ -70,7 +70,8 @@ const companion = new Attendee({
|
|
|
70
70
|
checkin: {},
|
|
71
71
|
companions: {
|
|
72
72
|
isCompanion: true,
|
|
73
|
-
mainGuestId: 'my-attendee'
|
|
73
|
+
mainGuestId: 'my-attendee',
|
|
74
|
+
mainGuestName: 'Max Mustermann'
|
|
74
75
|
},
|
|
75
76
|
userdata: {
|
|
76
77
|
name: 'John Doe'
|
|
@@ -88,7 +89,7 @@ export const WithBackground = {
|
|
|
88
89
|
branchName: 'default',
|
|
89
90
|
counterName: 'main',
|
|
90
91
|
formatName(attendee) {
|
|
91
|
-
return attendee.
|
|
92
|
+
return attendee.getFieldString('name');
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
};
|
|
@@ -99,7 +100,7 @@ export const Plain = {
|
|
|
99
100
|
branchName: 'default',
|
|
100
101
|
counterName: 'main',
|
|
101
102
|
formatName(attendee) {
|
|
102
|
-
return attendee.
|
|
103
|
+
return attendee.getFieldString('name');
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
};
|
|
@@ -110,7 +111,7 @@ export const Dense = {
|
|
|
110
111
|
branchName: 'default',
|
|
111
112
|
counterName: 'main',
|
|
112
113
|
formatName(attendee) {
|
|
113
|
-
return attendee.
|
|
114
|
+
return attendee.getFieldString('name');
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
};
|
|
@@ -124,7 +125,7 @@ export const FilteredTags = {
|
|
|
124
125
|
return allowedTags.includes(tag);
|
|
125
126
|
},
|
|
126
127
|
formatName(attendee) {
|
|
127
|
-
return attendee.
|
|
128
|
+
return attendee.getFieldString('name');
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
};
|
|
@@ -134,7 +135,7 @@ export const WithColorLabel = {
|
|
|
134
135
|
branchName: 'default',
|
|
135
136
|
counterName: 'main',
|
|
136
137
|
formatName(attendee) {
|
|
137
|
-
return attendee.
|
|
138
|
+
return attendee.getFieldString('name');
|
|
138
139
|
},
|
|
139
140
|
getTagColor(tag) {
|
|
140
141
|
return tagColors[tag] ?? undefined;
|
|
@@ -147,7 +148,7 @@ export const WithMultipleColorLabels = {
|
|
|
147
148
|
branchName: 'default',
|
|
148
149
|
counterName: 'main',
|
|
149
150
|
formatName(attendee) {
|
|
150
|
-
return attendee.
|
|
151
|
+
return attendee.getFieldString('name');
|
|
151
152
|
},
|
|
152
153
|
getTagColor(tag) {
|
|
153
154
|
return tagColors[tag] ?? undefined;
|
|
@@ -161,7 +162,7 @@ export const WithInfoText = {
|
|
|
161
162
|
counterName: 'main',
|
|
162
163
|
infoText: '🥦 Vegetarian',
|
|
163
164
|
formatName(attendee) {
|
|
164
|
-
return attendee.
|
|
165
|
+
return attendee.getFieldString('name');
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
};
|
|
@@ -170,11 +171,8 @@ export const WithCompanion = {
|
|
|
170
171
|
attendee: companion,
|
|
171
172
|
branchName: 'default',
|
|
172
173
|
counterName: 'main',
|
|
173
|
-
findMainGuest: () => {
|
|
174
|
-
return attendee;
|
|
175
|
-
},
|
|
176
174
|
formatName(attendee) {
|
|
177
|
-
return attendee.
|
|
175
|
+
return attendee.getFieldString('name');
|
|
178
176
|
}
|
|
179
177
|
}
|
|
180
178
|
};
|
|
@@ -184,7 +182,7 @@ export const WithCompanionButNoMainGuestInfo = {
|
|
|
184
182
|
branchName: 'default',
|
|
185
183
|
counterName: 'main',
|
|
186
184
|
formatName(attendee) {
|
|
187
|
-
return attendee.
|
|
185
|
+
return attendee.getFieldString('name');
|
|
188
186
|
}
|
|
189
187
|
}
|
|
190
188
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dev-crew-berlin/enter-js-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.90.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",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"dependencies": {
|
|
80
80
|
"cookie": "^1.0.1",
|
|
81
81
|
"jws": "^4.0.0",
|
|
82
|
+
"stable-hash": "^0.0.5",
|
|
82
83
|
"styled-jsx": "^5.1.6",
|
|
83
84
|
"uuid": "^9.0.0"
|
|
84
85
|
}
|