@dcrackel/hematournamentui 1.0.715 → 1.0.716

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.
@@ -1,153 +1,180 @@
1
- <template>
2
- <div
3
- v-if="person"
4
- class="flex items-center border border-dropdownSelect rounded-lg shadow-lg bg-poolBox hover:border-bright"
5
- >
6
- <div class="hidden md:block mr-4 border-r border-dropdownSelect h-20 w-10 items-center text-center pt-7">
7
- <BaseText :text="queueLabel" size="md" color="quaternary" weight="bold" />
8
- </div>
9
- <div class="block md:hidden mr-4 border-r border-dropdownSelect h-16 w-5 items-center text-center pt-5">
10
- <BaseText :text="queueLabel" size="sm" color="quaternary" weight="bold" />
11
- </div>
12
-
13
- <div class="hidden md:block mr-4">
14
- <div v-if="!portraitURL" class="w-14 h-14 rounded-xl bg-dropdownSelect flex items-center justify-center">
15
- <BaseText text="" size="sm" color="neutral" weight="bold" />
16
- </div>
17
- <img v-if="portraitURL" :src="portraitURL" alt="Portrait" class="w-14 h-14 rounded-xl" />
18
- </div>
19
-
20
- <div class="flex flex-col w-3/4 md:w-4/12 justify-start">
21
- <div class="flex items-center justify-start gap-2 min-w-0">
22
- <button class="min-w-0 text-left" type="button" @click="handleForwardToProfile">
23
- <BaseText
24
- :text="displayName"
25
- size="md"
26
- color="quaternary"
27
- weight="bold"
28
- class="text-sm md:text-xl truncate"
29
- />
30
- </button>
31
- <MissingHemaRatingsId :person="person.Person" />
32
- </div>
33
- <span class="w-full flex justify-start">
34
- <BaseText :text="clubName" size="md" color="quinary" weight="normal" class="hidden md:block" />
35
- <BaseText :text="clubShortName" size="xs" color="quinary" weight="normal" class="block md:hidden" />
36
- </span>
37
-
38
- <div class="grid md:hidden grid-cols-2 gap-x-4 mr-10">
39
- <div class="flex">
40
- <BaseText text="M2: " size="xs" color="quaternary" weight="normal" class="mr-1" />
41
- <BaseText :text="M2Rating" size="xs" color="quinary" weight="bold" class="ml-1" />
42
- </div>
43
- <div class="flex">
44
- <BaseText text="HR: " size="xs" color="quaternary" weight="normal" class="mr-1" />
45
- <BaseText :text="HEMARating" size="xs" color="quinary" weight="bold" class="ml-1" />
46
- </div>
47
- </div>
48
- </div>
49
-
50
- <div class="hidden md:grid grid-cols-1 gap-x-4 mr-4 w-36">
51
- <div class="flex">
52
- <BaseText text="M2Rating:" size="sm" color="quaternary" weight="normal" class="mr-2" />
53
- <BaseText :text="M2Rating" size="sm" color="quinary" weight="bold" class="pt-0.5" />
54
- </div>
55
- <div class="flex">
56
- <BaseText text="HemaRating:" size="sm" color="quaternary" weight="normal" class="mr-2" />
57
- <BaseText :text="HEMARating" size="sm" color="quinary" weight="bold" />
58
- </div>
59
- </div>
60
-
61
- <div class="mr-2 md:mr-4 md:ml-auto flex flex-row">
62
- <div class="flex justify-center w-20">
63
- <div class="hidden md:flex border border-dropdownSelect shadow-md rounded-lg bg-natural h-9 px-3 items-center">
64
- <BaseText text="Unpaid" size="xs" color="quinary" weight="bold" />
65
- </div>
66
- </div>
67
- <div class="w-44 flex justify-end">
68
- <BaseButton
69
- label="Move to Active"
70
- size="xs"
71
- type="primary"
72
- icon-name="fa-arrow-up-from-bracket"
73
- class="border border-dropdownSelect shadow-md rounded-l-lg bg-natural w-40 m-0! p-0! h-10"
74
- @buttonClick="handleMoveToActive"
75
- />
76
- </div>
77
- </div>
78
-
79
- <div
80
- class="block md:ml-4 border-l border-dropdownSelect h-16 w-9 md:h-20 md:w-10 items-center text-center hover:bg-eventBoxRed rounded-tr-lg rounded-br-lg pt-5 md:pt-6"
81
- >
82
- <BaseIcon
83
- icon-name="fa-circle-xmark"
84
- size=""
85
- color="quinary"
86
- hover="alarm"
87
- @click="handleRemoveFencer"
88
- class="text-md md:text-2xl"
89
- />
90
- </div>
91
- </div>
92
- </template>
93
-
94
- <script>
95
- import BaseIcon from '../../../Atoms/Icon/BaseIcon.vue';
96
- import BaseText from '../../../Atoms/Text/BaseText.vue';
97
- import BaseButton from '../../../Molecules/Buttons/BaseButton/BaseButton.vue';
98
- import MissingHemaRatingsId from '../../../Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.vue';
99
-
100
- export default {
101
- name: 'WaitlistFencerCard',
102
- components: { BaseButton, BaseIcon, BaseText, MissingHemaRatingsId },
103
- emits: ['forward:toProfile', 'move:active', 'remove:fencer'],
104
- props: {
105
- person: {
106
- type: Object,
107
- required: true
108
- },
109
- queuePosition: {
110
- type: Number,
111
- required: true
112
- }
113
- },
114
- computed: {
115
- queueLabel() {
116
- return `#${this.queuePosition}`;
117
- },
118
- displayName() {
119
- return this.person?.Person?.DisplayName || 'Unknown fencer';
120
- },
121
- clubName() {
122
- return this.person?.Person?.Club?.Name || 'No club listed';
123
- },
124
- clubShortName() {
125
- return this.person?.Person?.Club?.ShortName || this.clubName;
126
- },
127
- portraitURL() {
128
- const images = this.person?.Person?.Images || [];
129
- const portrait = images.find(image => image.Type === 'Portrait');
130
- return portrait ? portrait.URL : '';
131
- },
132
- HEMARating() {
133
- const rating = this.person?.Person?.HEMARatings?.[0]?.Rating;
134
- return rating || 0;
135
- },
136
- M2Rating() {
137
- const rating = this.person?.Person?.M2Ratings?.[0]?.Rating;
138
- return rating || 'U';
139
- }
140
- },
141
- methods: {
142
- handleMoveToActive() {
143
- this.$emit('move:active', { ...this.person });
144
- },
145
- handleRemoveFencer() {
146
- this.$emit('remove:fencer', { ...this.person });
147
- },
148
- handleForwardToProfile() {
149
- this.$emit('forward:toProfile', this.person.PersonId);
150
- }
151
- }
152
- };
153
- </script>
1
+ <template>
2
+ <div
3
+ v-if="person"
4
+ class="flex flex-wrap items-center gap-3 rounded-lg border border-dropdownSelect bg-poolBox py-3 pl-3 shadow-lg hover:border-bright md:flex-nowrap"
5
+ >
6
+ <div class="w-8 shrink-0 border-r border-dropdownSelect pr-3 text-center">
7
+ <BaseText :text="queueLabel" size="sm" color="quaternary" weight="bold" />
8
+ </div>
9
+ <div class="hidden shrink-0 lg:block">
10
+ <div v-if="!portraitURL" class="flex h-14 w-14 items-center justify-center rounded-xl bg-dropdownSelect"></div>
11
+ <img v-else :src="portraitURL" alt="Portrait" class="h-14 w-14 rounded-xl" />
12
+ </div>
13
+
14
+ <div class="min-w-0 flex-1 basis-40 text-left">
15
+ <div class="flex min-w-0 items-center gap-2">
16
+ <button class="min-w-0 text-left" type="button" @click="handleForwardToProfile">
17
+ <BaseText
18
+ :text="displayName"
19
+ size="md"
20
+ color="quaternary"
21
+ weight="bold"
22
+ class="break-words text-sm md:text-xl"
23
+ />
24
+ </button>
25
+ <MissingHemaRatingsId :person="person.Person" />
26
+ </div>
27
+ <BaseText :text="clubName" size="sm" color="quinary" class="hidden md:block" />
28
+ <BaseText :text="clubShortName" size="xs" color="quinary" class="md:hidden" />
29
+ <div class="mt-2 flex flex-wrap items-center gap-2 text-xs" aria-live="polite">
30
+ <span class="rounded px-2 py-1 font-semibold" :class="checkInClass">{{ checkInStatus }}</span>
31
+ <span
32
+ v-if="isNextCheckedIn && checkedIn"
33
+ class="rounded bg-eventBoxBlueTwo px-2 py-1 font-semibold text-primary"
34
+ >Next checked in</span
35
+ >
36
+ <span class="text-primaryHighlight">{{ waiverStatus }}</span>
37
+ </div>
38
+ </div>
39
+
40
+ <div class="hidden shrink-0 text-left xl:block">
41
+ <BaseText :text="`M2: ${M2Rating}`" size="xs" color="quinary" />
42
+ <BaseText :text="`HR: ${HEMARating}`" size="xs" color="quinary" />
43
+ </div>
44
+
45
+ <div class="flex w-full flex-wrap items-center justify-end gap-y-2 md:ml-auto md:w-auto md:shrink-0">
46
+ <div class="mr-2 flex items-center gap-2">
47
+ <span
48
+ class="hidden rounded border border-dropdownSelect px-2 py-1 text-xs font-bold text-quinary lg:inline-flex"
49
+ >Unpaid</span
50
+ >
51
+ <BaseButton
52
+ label="Move to Active"
53
+ size="xs"
54
+ type="primary"
55
+ icon-name="fa-arrow-up-from-bracket"
56
+ class="m-0! min-h-10"
57
+ @buttonClick="handleMoveToActive"
58
+ />
59
+ </div>
60
+ <div class="mr-2 flex w-44 shrink-0 justify-end md:mr-4">
61
+ <BaseButton
62
+ v-if="needsWaiver"
63
+ label="Sign Waiver"
64
+ size="xs"
65
+ type="primary"
66
+ class="m-0! h-10 w-40 p-0!"
67
+ @buttonClick="requestWeaverSign"
68
+ />
69
+ <ButtonBar
70
+ v-else
71
+ :buttons="attendanceButtons"
72
+ :selected="selectedAttendance"
73
+ class="mr-1 min-h-10"
74
+ @update:selected="handleAttendance"
75
+ />
76
+ </div>
77
+ <button
78
+ type="button"
79
+ :aria-label="`Remove ${displayName} from waitlist`"
80
+ class="flex min-h-10 w-9 shrink-0 items-center justify-center border-l border-dropdownSelect text-quinary hover:bg-eventBoxRed focus-visible:outline-2 focus-visible:outline-bright md:ml-4 md:w-10"
81
+ @click="handleRemoveFencer"
82
+ >
83
+ <BaseIcon icon-name="fa-circle-xmark" size="lg" color="quinary" hover="alarm" />
84
+ </button>
85
+ </div>
86
+ </div>
87
+ </template>
88
+
89
+ <script>
90
+ import BaseIcon from '../../../Atoms/Icon/BaseIcon.vue';
91
+ import BaseText from '../../../Atoms/Text/BaseText.vue';
92
+ import BaseButton from '../../../Molecules/Buttons/BaseButton/BaseButton.vue';
93
+ import ButtonBar from '../../../Molecules/Buttons/ButtonBar/ButtonBar.vue';
94
+ import MissingHemaRatingsId from '../../../Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.vue';
95
+ import { isWaitlistCheckedIn, needsAttendanceWaiver } from '../../../Util/waitlistAttendance.js';
96
+
97
+ export default {
98
+ name: 'WaitlistFencerCard',
99
+ components: { BaseButton, ButtonBar, BaseIcon, BaseText, MissingHemaRatingsId },
100
+ emits: ['forward:toProfile', 'move:active', 'remove:fencer', 'update:check-in', 'request:weaver-sign'],
101
+ props: {
102
+ person: { type: Object, required: true },
103
+ queuePosition: { type: Number, required: true },
104
+ isNextCheckedIn: { type: Boolean, default: false }
105
+ },
106
+ computed: {
107
+ queueLabel() {
108
+ return `#${this.queuePosition}`;
109
+ },
110
+ displayName() {
111
+ return this.person?.Person?.DisplayName || 'Unknown fencer';
112
+ },
113
+ clubName() {
114
+ return this.person?.Person?.Club?.Name || 'No club listed';
115
+ },
116
+ clubShortName() {
117
+ return this.person?.Person?.Club?.ShortName || this.clubName;
118
+ },
119
+ portraitURL() {
120
+ const images = this.person?.Person?.Images || [];
121
+ return images.find(image => image.Type === 'Portrait')?.URL || '';
122
+ },
123
+ HEMARating() {
124
+ return this.person?.Person?.HEMARatings?.[0]?.Rating || 0;
125
+ },
126
+ M2Rating() {
127
+ return this.person?.Person?.M2Ratings?.[0]?.Rating || 'U';
128
+ },
129
+ checkedIn() {
130
+ return isWaitlistCheckedIn(this.person);
131
+ },
132
+ needsWaiver() {
133
+ return needsAttendanceWaiver(this.person);
134
+ },
135
+ checkInStatus() {
136
+ return this.checkedIn ? 'Checked in' : 'Not checked in';
137
+ },
138
+ attendanceButtons() {
139
+ return [
140
+ { id: 'Absent', label: 'Absent', defaultBgColor: 'bg-natural', selectedBgColor: 'bg-eventBoxBlueTwo' },
141
+ { id: 'Present', label: 'Present', defaultBgColor: 'bg-natural', selectedBgColor: 'bg-eventBoxGreenTwo' }
142
+ ];
143
+ },
144
+ selectedAttendance() {
145
+ return this.checkedIn ? 'Present' : 'Absent';
146
+ },
147
+ checkInClass() {
148
+ return this.checkedIn ? 'bg-acceptedHighlight text-accepted' : 'bg-dropdownSelect text-primaryHighlight';
149
+ },
150
+ waiverStatus() {
151
+ if (this.needsWaiver) return 'Waiver needed';
152
+ return this.person?.Person?.Weaver?.Required ? 'Waiver signed' : 'No waiver required';
153
+ }
154
+ },
155
+ methods: {
156
+ clonePerson() {
157
+ return JSON.parse(JSON.stringify(this.person));
158
+ },
159
+ requestWeaverSign() {
160
+ this.$emit('request:weaver-sign', this.clonePerson());
161
+ },
162
+ handleAttendance(selected) {
163
+ if (selected === 'Present' && this.needsWaiver) {
164
+ this.requestWeaverSign();
165
+ return;
166
+ }
167
+ this.$emit('update:check-in', { ...this.clonePerson(), CheckedIn: selected === 'Present' });
168
+ },
169
+ handleMoveToActive() {
170
+ this.$emit('move:active', this.clonePerson());
171
+ },
172
+ handleRemoveFencer() {
173
+ this.$emit('remove:fencer', this.clonePerson());
174
+ },
175
+ handleForwardToProfile() {
176
+ this.$emit('forward:toProfile', this.person.PersonId ?? this.person.Person?.PersonId);
177
+ }
178
+ }
179
+ };
180
+ </script>
@@ -43,7 +43,7 @@ export default {
43
43
  },
44
44
  argTypes: {
45
45
  personsInTournament: {
46
- control: { type: 'array' },
46
+ control: { type: 'object' },
47
47
  description: 'List of persons in the tournament',
48
48
  table: {
49
49
  type: { summary: 'Array' },
@@ -51,7 +51,7 @@ export default {
51
51
  }
52
52
  },
53
53
  personsAll: {
54
- control: { type: 'array' },
54
+ control: { type: 'object' },
55
55
  description: 'List of all persons',
56
56
  table: {
57
57
  type: { summary: 'Array' },
@@ -59,7 +59,7 @@ export default {
59
59
  }
60
60
  },
61
61
  fencingClubs: {
62
- control: { type: 'array' },
62
+ control: { type: 'object' },
63
63
  description: 'List of clubs',
64
64
  table: {
65
65
  type: { summary: 'Array' },
@@ -117,6 +117,38 @@ export const WithWaitlist = {
117
117
  }
118
118
  };
119
119
 
120
+ export const WaitlistCheckIn = {
121
+ parameters: {
122
+ docs: {
123
+ description: {
124
+ story:
125
+ 'Waitlisted fencers sign the waiver, then use Absent/Present to check in without joining the active roster. Move to Active remains available to fill a no-show spot. The parent handles update:waitlist-check-in ({ ...person, CheckedIn }), weaver:sign, and move:waitlist-to-active, then supplies updated personsInTournament. Status stays Waitlist until the parent promotes the fencer.'
126
+ }
127
+ }
128
+ },
129
+ args: {
130
+ ...WithWaitlist.args,
131
+ personsInTournament: [
132
+ {
133
+ ...activeRoster[0],
134
+ Status: 'Absent',
135
+ Person: {
136
+ ...activeRoster[0].Person,
137
+ Weaver: { Required: true, Scope: 'Tournament', Signed: true }
138
+ }
139
+ },
140
+ ...waitlistedPersons.map((person, index) => ({
141
+ ...person,
142
+ CheckedIn: index === 2,
143
+ Person: {
144
+ ...person.Person,
145
+ Weaver: { Required: true, Scope: 'Tournament', Signed: index !== 0 }
146
+ }
147
+ }))
148
+ ]
149
+ }
150
+ };
151
+
120
152
  export const RegistrationOpen = {
121
153
  args: {
122
154
  personsInTournament: eventPersonGetEventById.persons,
@@ -0,0 +1,73 @@
1
+ import { mount } from '@vue/test-utils';
2
+ import { describe, expect, it } from 'vitest';
3
+ import EventAttendance from './EventAttendance.vue';
4
+ import WaitlistFencerCard from '../../../Organisms/Cards/WaitlistFencerCard/WaitlistFencerCard.vue';
5
+ import ButtonBar from '../../../Molecules/Buttons/ButtonBar/ButtonBar.vue';
6
+
7
+ const createPerson = (id, status) => ({
8
+ PersonId: id,
9
+ Status: status,
10
+ CheckedIn: false,
11
+ WaitlistPosition: id,
12
+ Person: {
13
+ DisplayName: `Fencer ${id}`,
14
+ Weaver: { Required: true, Scope: 'Tournament', Signed: true }
15
+ }
16
+ });
17
+
18
+ const mountAttendance = personsInTournament =>
19
+ mount(EventAttendance, {
20
+ props: { event: { Status: 'preparation' }, personsInTournament },
21
+ shallow: true,
22
+ global: { stubs: { WaitlistFencerCard: false, ButtonBar: false, BaseButton: false, BaseText: false } }
23
+ });
24
+
25
+ describe('Waitlist attendance intent', () => {
26
+ it('keeps check-in separate from promotion into a no-show spot', async () => {
27
+ const absent = createPerson(1, 'Absent');
28
+ const waiting = createPerson(2, 'Waitlist');
29
+ const wrapper = mountAttendance([absent, waiting]);
30
+ const card = wrapper.getComponent(WaitlistFencerCard);
31
+
32
+ await card.getComponent(ButtonBar).findAll('section')[1].trigger('click');
33
+ const checkedIn = wrapper.emitted('update:waitlist-check-in')[0][0];
34
+ expect(checkedIn).toEqual({ ...waiting, CheckedIn: true });
35
+ expect(wrapper.emitted('update:person')).toBeUndefined();
36
+ expect(wrapper.emitted('move:waitlist-to-active')).toBeUndefined();
37
+
38
+ await wrapper.setProps({ personsInTournament: [absent, checkedIn] });
39
+ expect(wrapper.text()).toContain('1 waiting · 1 checked in');
40
+ expect(wrapper.getComponent(WaitlistFencerCard).text()).toContain('Next checked in');
41
+ const promote = card.findAll('button').find(button => button.text() === 'Move to Active');
42
+ await promote.trigger('click');
43
+ expect(wrapper.emitted('move:waitlist-to-active')[0][0]).toEqual(checkedIn);
44
+ expect(waiting.Status).toBe('Waitlist');
45
+
46
+ await wrapper.setProps({ personsInTournament: [absent, { ...checkedIn, Status: 'Present' }] });
47
+ expect(wrapper.findComponent(WaitlistFencerCard).exists()).toBe(false);
48
+ expect(wrapper.findAllComponents({ name: 'FencerCard' })).toHaveLength(2);
49
+ wrapper.unmount();
50
+ });
51
+
52
+ it('confirms a waitlisted waiver through the existing modal without changing roster status', async () => {
53
+ const waiting = createPerson(2, 'Waitlist');
54
+ waiting.Person.Weaver.Signed = false;
55
+ const wrapper = mountAttendance([waiting]);
56
+ const sign = wrapper
57
+ .getComponent(WaitlistFencerCard)
58
+ .findAll('button')
59
+ .find(button => button.text() === 'Sign Waiver');
60
+
61
+ await sign.trigger('click');
62
+ const modal = wrapper.getComponent({ name: 'BaseModal' });
63
+ expect(modal.props('show')).toBe(true);
64
+ modal.vm.$emit('submitModal');
65
+ await wrapper.vm.$nextTick();
66
+ expect(wrapper.emitted('weaver:sign')[0][0]).toEqual(waiting);
67
+ expect(wrapper.emitted('weaver:sign')[0][0].Person).not.toBe(waiting.Person);
68
+ expect(waiting.Person.Weaver.Signed).toBe(false);
69
+ expect(wrapper.emitted('update:waitlist-check-in')).toBeUndefined();
70
+ expect(modal.props('show')).toBe(false);
71
+ wrapper.unmount();
72
+ });
73
+ });