@dcrackel/hematournamentui 1.0.711 → 1.0.713

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.
Files changed (109) hide show
  1. package/.prettierignore +7 -7
  2. package/.storybook/main.js +3 -1
  3. package/README.md +182 -148
  4. package/dist/HemaTournamentUI-lib.es.js +4150 -4039
  5. package/dist/HemaTournamentUI-lib.umd.js +27 -27
  6. package/dist/hematournamentui-tailwind.css +11 -0
  7. package/package.json +96 -96
  8. package/prettier.config.js +16 -16
  9. package/src/main.js +1 -1
  10. package/src/mocks/getDEBouts-TableOf128.js +37 -37
  11. package/src/mocks/getDEBouts-TableOf64.js +35 -35
  12. package/src/stories/Atoms/Input/BaseInput.test.js +97 -97
  13. package/src/stories/Atoms/Input/BaseInput.vue +149 -149
  14. package/src/stories/Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.stories.js +23 -23
  15. package/src/stories/Molecules/Indicators/MissingHemaRatingsId/MissingHemaRatingsId.vue +35 -35
  16. package/src/stories/Molecules/Indicators/RegistrationStatus/RegistrationStatus.vue +30 -0
  17. package/src/stories/Molecules/Menus/HoverActions/HoverActions.test.js +138 -0
  18. package/src/stories/Molecules/Menus/HoverActions/HoverActions.vue +212 -0
  19. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.stories.js +6 -0
  20. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.test.js +18 -18
  21. package/src/stories/Molecules/Modals/DirectorModal/DirectorModal.vue +1 -1
  22. package/src/stories/Organisms/Cards/BoutCard/BoutCard.vue +5 -1
  23. package/src/stories/Organisms/Cards/BoutCard/Variants/BoutCardActive/BoutCardActive.vue +19 -10
  24. package/src/stories/Organisms/Cards/BoutCard/Variants/BoutCardInactive/BoutCardInactive.vue +11 -7
  25. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.stories.js +33 -33
  26. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.test.js +45 -45
  27. package/src/stories/Organisms/Cards/BracketDirectorAssignmentCard/BracketDirectorAssignmentCard.vue +103 -103
  28. package/src/stories/Organisms/Cards/Director/DirectorCard.test.js +82 -0
  29. package/src/stories/Organisms/Cards/Director/DirectorCard.vue +32 -51
  30. package/src/stories/Organisms/Cards/EditBout/EditBout.test.js +51 -51
  31. package/src/stories/Organisms/Cards/EventCard/EventCard.stories.js +41 -1
  32. package/src/stories/Organisms/Cards/EventCard/EventCard.test.js +106 -0
  33. package/src/stories/Organisms/Cards/EventCard/EventCard.vue +62 -30
  34. package/src/stories/Organisms/Cards/FencerCard/FencerCard.vue +298 -298
  35. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.stories.js +77 -60
  36. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.test.js +144 -143
  37. package/src/stories/Organisms/Cards/TableauBoutCard/TableauBoutCard.vue +289 -256
  38. package/src/stories/Organisms/Cards/TableauFencerCard/TableauFencerCard.stories.js +69 -69
  39. package/src/stories/Organisms/Cards/TableauFencerCard/TableauFencerCard.vue +80 -80
  40. package/src/stories/Organisms/Cards/WaitlistFencerCard/WaitlistFencerCard.vue +153 -153
  41. package/src/stories/Organisms/ComplexInputs/DropDown/DropDownMenu.vue +4 -0
  42. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.stories.js +31 -31
  43. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.test.js +109 -109
  44. package/src/stories/Organisms/ComplexInputs/ImageCropper/ImageCropper.vue +192 -192
  45. package/src/stories/Organisms/Containers/Tableau/Tableau.stories.js +1 -0
  46. package/src/stories/Organisms/Containers/Tableau/Tableau.test.js +247 -204
  47. package/src/stories/Organisms/Containers/Tableau/Tableau.vue +89 -15
  48. package/src/stories/Organisms/Containers/Tableau/components/BracketDirectorAssignmentPanel.test.js +29 -29
  49. package/src/stories/Organisms/Containers/Tableau/components/BracketDirectorAssignmentPanel.vue +46 -46
  50. package/src/stories/Organisms/Containers/Tableau/components/TableauSvgOverlay.test.js +21 -21
  51. package/src/stories/Organisms/Containers/Tableau/components/TableauSvgOverlay.vue +39 -39
  52. package/src/stories/Organisms/Containers/Tableau/layout/TableauLayoutEngine.js +145 -145
  53. package/src/stories/Organisms/Containers/Tableau/layout/TableauLayoutEngine.test.js +64 -64
  54. package/src/stories/Organisms/Containers/Tableau/plannedAssignments.js +36 -57
  55. package/src/stories/Organisms/Containers/Tableau/plannedAssignments.test.js +101 -65
  56. package/src/stories/Organisms/Containers/TableauColumn/TableauColumn.vue +14 -1
  57. package/src/stories/Organisms/Headers/AttendanceSummary/AttendanceSummary.vue +12 -5
  58. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.stories.js +52 -48
  59. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.vue +256 -227
  60. package/src/stories/Organisms/Wizards/EditEventWizard/DirectElimination/DirectElimination.vue +226 -226
  61. package/src/stories/Organisms/Wizards/EditEventWizard/DirectEliminationPromotion/DirectEliminationPromotion.vue +204 -204
  62. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.stories.js +137 -133
  63. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.test.js +221 -191
  64. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.vue +372 -366
  65. package/src/stories/Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue +172 -172
  66. package/src/stories/Organisms/Wizards/EditEventWizard/PoolConfiguration/PoolConfiguration.vue +216 -216
  67. package/src/stories/Organisms/Wizards/EditEventWizard/PriceFields.test.js +79 -79
  68. package/src/stories/Organisms/Wizards/EditEventWizard/RuleSerialization.test.js +29 -0
  69. package/src/stories/Organisms/Wizards/EditEventWizard/WeaponSelection.test.js +138 -0
  70. package/src/stories/Templates/EventManagement/Bracket/Bracket.stories.js +123 -12
  71. package/src/stories/Templates/EventManagement/Bracket/Bracket.test.js +178 -166
  72. package/src/stories/Templates/EventManagement/Bracket/Bracket.vue +35 -7
  73. package/src/stories/Templates/EventManagement/Bracket/BracketDirectorAssignment.test.js +242 -0
  74. package/src/stories/Templates/EventManagement/Bracket/BracketMobile.test.js +131 -0
  75. package/src/stories/Templates/EventManagement/Bracket/BracketPlannedSuggestions.js +42 -39
  76. package/src/stories/Templates/EventManagement/Bracket/BracketStories.test.js +80 -0
  77. package/src/stories/Templates/EventManagement/Bracket/BracketStoryAssignments.js +93 -0
  78. package/src/stories/Templates/EventManagement/Bracket/BracketStoryAssignments.test.js +152 -0
  79. package/src/stories/Templates/EventManagement/Bracket/BracketStoryHarness.js +39 -39
  80. package/src/stories/Templates/EventManagement/Bracket/BracketStoryHarness.test.js +79 -79
  81. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.stories.js +93 -93
  82. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.vue +91 -91
  83. package/src/stories/Templates/EventManagement/EventAttendance/EventAttendance.stories.js +31 -1
  84. package/src/stories/Templates/EventManagement/PoolLive/PoolLive.test.js +121 -121
  85. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.stories.js +9 -2
  86. package/src/stories/Templates/Menus/EditEventsTopMenu/EditEventsTopMenu.vue +5 -4
  87. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.stories.js +81 -81
  88. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.test.js +39 -39
  89. package/src/stories/Templates/PersonManagement/Admin/Administration/Administration.vue +101 -101
  90. package/src/stories/Templates/PersonManagement/Admin/FencerAdmin/FencerAdmin.stories.js +71 -71
  91. package/src/stories/Templates/PersonManagement/Admin/FencerAdmin/FencerAdmin.vue +86 -86
  92. package/src/stories/Templates/PersonManagement/Admin/MergeAccounts/MergeAccounts.stories.js +86 -86
  93. package/src/stories/Templates/PersonManagement/Admin/MergeAccounts/MergeAccounts.vue +247 -247
  94. package/src/stories/Templates/PersonManagement/Basic/BasicEdit.vue +170 -170
  95. package/src/stories/Templates/PersonManagement/PersonManagement.stories.js +156 -156
  96. package/src/stories/Templates/PersonManagement/PersonManagement.test.js +329 -329
  97. package/src/stories/Templates/PersonManagement/PersonManagement.vue +329 -329
  98. package/src/stories/Templates/PersonManagement/PersonManagementDraft.js +42 -42
  99. package/src/stories/Templates/TournamentManagement/ListEvents/ListEvents.stories.js +58 -45
  100. package/src/stories/Templates/TournamentManagement/TournamentManagement.stories.js +84 -84
  101. package/src/stories/Templates/TournamentManagement/TournamentManagement.test.js +114 -114
  102. package/src/stories/Templates/TournamentManagement/TournamentManagement.vue +363 -363
  103. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.stories.js +116 -116
  104. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.vue +307 -307
  105. package/src/stories/Util/Validations/PersonManagementValidations.js +45 -45
  106. package/src/stories/Util/Validations/PriceValidation.js +6 -6
  107. package/src/stories/Util/boutDirectorAssignment.js +46 -0
  108. package/src/stories/Util/registrationStatus.js +11 -0
  109. package/src/stories/Util/tabs.js +19 -47
@@ -1,247 +1,247 @@
1
- <template>
2
- <section class="w-full">
3
- <div class="flex w-full flex-col gap-6 md:flex-row">
4
- <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
5
- <BaseText
6
- :text="`Merge into this account: ${person?.DisplayName || 'Root Account'}`"
7
- size="md"
8
- color="primary"
9
- />
10
-
11
- <div class="mt-3 space-y-2">
12
- <div class="text-sm text-quaternary">
13
- <span class="font-semibold text-primary">PersonId:</span> {{ rootPersonId }}
14
- </div>
15
- <div class="text-sm text-quaternary">
16
- <span class="font-semibold text-primary">Legal Name:</span> {{ legalName }}
17
- </div>
18
- <div class="text-sm text-quaternary">
19
- <span class="font-semibold text-primary">Club:</span> {{ clubName }}
20
- </div>
21
- <div class="text-sm text-quaternary">
22
- <span class="font-semibold text-primary">Email:</span> {{ primaryEmail }}
23
- </div>
24
- </div>
25
-
26
- <div class="mt-4 flex h-64 flex-col justify-between">
27
- <div class="min-h-0">
28
- <BaseText text="Accounts to merge in" size="sm" color="quaternary" weight="bold" />
29
- <div class="border-b border-dropdownSelect h-2"></div>
30
- <div v-if="selected.length === 0" class="mt-2 text-sm text-quaternary">None selected yet.</div>
31
- <div v-else class="mt-2 max-h-44 overflow-y-auto border border-dropdownSelect rounded-lg">
32
- <div
33
- v-for="p in selected"
34
- :key="p.PersonId"
35
- class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
36
- >
37
- <div class="min-w-0">
38
- <div class="text-sm text-primary font-semibold truncate">
39
- {{ p.DisplayName }}
40
- <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
41
- </div>
42
- <div class="text-xs text-quaternary truncate">
43
- {{ p.FirstName }} {{ p.LastName }}
44
- <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
45
- </div>
46
- </div>
47
-
48
- <BaseButton
49
- color="warn"
50
- label="Remove"
51
- size="xs"
52
- type="primary"
53
- @buttonClick="removeSelected(p.PersonId)"
54
- />
55
- </div>
56
- </div>
57
- </div>
58
-
59
- <div class="flex justify-end">
60
- <BaseButton
61
- color="warn"
62
- label="Merge Accounts Together"
63
- size="sm"
64
- type="primary"
65
- :disabled="!canMerge"
66
- @buttonClick="emitMergeAccounts"
67
- />
68
- </div>
69
- </div>
70
- </section>
71
-
72
- <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
73
- <BaseText text="Results" size="md" color="primary" />
74
-
75
- <div class="mt-4">
76
- <TitledInput
77
- title="Filter people"
78
- placeholder="Type name or club..."
79
- :inputValue="filterText"
80
- @update:value="filterText = $event"
81
- />
82
- <div class="text-xs text-quaternary mt-1">Filters Display Name, First/Last Name, or Club Name.</div>
83
- </div>
84
-
85
- <div class="mt-4 flex items-center justify-between text-xs text-quaternary">
86
- <span> Showing {{ filteredPeople.length }}{{ totalMatches > resultLimit ? '+' : '' }} results </span>
87
- <span v-if="totalMatches > resultLimit"> (limited to first {{ resultLimit }}) </span>
88
- </div>
89
-
90
- <div class="mt-2 border border-dropdownSelect rounded-lg h-64 overflow-y-auto">
91
- <div
92
- v-for="p in filteredPeople"
93
- :key="p.PersonId"
94
- class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
95
- >
96
- <div class="min-w-0">
97
- <div class="text-sm text-primary font-semibold truncate">
98
- <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
99
- {{ resultTitle(p) }}
100
- </div>
101
- <div class="text-xs text-quaternary truncate">
102
- {{ p.FirstName }} {{ p.LastName }}
103
- <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
104
- </div>
105
- </div>
106
-
107
- <BaseButton color="neutral" label="Add" size="xs" type="primary" @buttonClick="addSelected(p)" />
108
- </div>
109
-
110
- <div v-if="filteredPeople.length === 0" class="px-3 py-3 text-sm text-quaternary">No matches.</div>
111
- </div>
112
- </section>
113
- </div>
114
- </section>
115
- </template>
116
-
117
- <script>
118
- import BaseText from '../../../../Atoms/Text/BaseText.vue';
119
- import TitledInput from '../../../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
120
- import BaseButton from '../../../../Molecules/Buttons/BaseButton/BaseButton.vue';
121
-
122
- const getPersonSearchValues = person => {
123
- const searchablePerson = person || {};
124
- const club = searchablePerson.Club || {};
125
- return [
126
- searchablePerson.DisplayName,
127
- searchablePerson.FirstName,
128
- searchablePerson.LastName,
129
- club.Name,
130
- club.ShortName
131
- ];
132
- };
133
-
134
- const normalizeSearchValue = value => String(value || '').toLowerCase();
135
-
136
- const personMatchesQuery = (person, query) =>
137
- getPersonSearchValues(person).some(value => normalizeSearchValue(value).includes(query));
138
-
139
- export default {
140
- name: 'MergeAccounts',
141
- components: { BaseText, TitledInput, BaseButton },
142
- emits: ['merge:merge'],
143
- props: {
144
- person: { type: Object, required: true },
145
- people: { type: Array, required: true }
146
- },
147
- data() {
148
- return {
149
- filterText: '',
150
- selected: [],
151
- resultLimit: 200
152
- };
153
- },
154
- computed: {
155
- rootPersonId() {
156
- return this.person?.PersonId ?? '';
157
- },
158
- legalName() {
159
- const first = this.person?.FirstName || '';
160
- const last = this.person?.LastName || '';
161
- return `${first} ${last}`.trim() || '-';
162
- },
163
- clubName() {
164
- return this.person?.Club?.Name || '-';
165
- },
166
- primaryEmail() {
167
- const emails = this.person?.PersonEmails || [];
168
- const primary = emails.find(email => email.IsPrimary);
169
- return primary?.EmailAddress || '-';
170
- },
171
- selectedIds() {
172
- return new Set(this.selected.map(p => p.PersonId));
173
- },
174
- canMerge() {
175
- return this.selected.length > 0;
176
- },
177
- normalizedFilterText() {
178
- return (this.filterText || '').trim().toLowerCase();
179
- },
180
- candidatePeople() {
181
- return (this.people || []).filter(
182
- p => p && p.PersonId !== this.rootPersonId && !this.selectedIds.has(p.PersonId)
183
- );
184
- },
185
- matchingPeople() {
186
- const q = this.normalizedFilterText;
187
-
188
- if (!q) return this.candidatePeople;
189
-
190
- return this.candidatePeople.filter(p => this.matchesQuery(p, q));
191
- },
192
- totalMatches() {
193
- return this.matchingPeople.length;
194
- },
195
- filteredPeople() {
196
- return this.matchingPeople.slice(0, this.resultLimit);
197
- }
198
- },
199
- watch: {
200
- rootPersonId() {
201
- this.selected = [];
202
- },
203
- people() {
204
- this.removeUnavailableSelectedPeople();
205
- }
206
- },
207
- methods: {
208
- personClubSuffix(p) {
209
- return ` - ${p.Club.Name}`;
210
- },
211
- resultTitle(p) {
212
- const email = this.getPrimaryEmail(p);
213
-
214
- if (!email) return p.DisplayName || '';
215
-
216
- return `${p.DisplayName} - ${email}`;
217
- },
218
- getPrimaryEmail(p) {
219
- const emails = p?.PersonEmails || [];
220
- return emails.find(email => email.IsPrimary)?.EmailAddress || '';
221
- },
222
- matchesQuery(p, q) {
223
- return personMatchesQuery(p, q);
224
- },
225
- removeUnavailableSelectedPeople() {
226
- const availableIds = new Set((this.people || []).map(p => p?.PersonId));
227
- this.selected = this.selected.filter(p => availableIds.has(p.PersonId));
228
- },
229
- addSelected(p) {
230
- if (!p || p.PersonId === this.rootPersonId) return;
231
- if (this.selectedIds.has(p.PersonId)) return;
232
- this.selected = [...this.selected, p];
233
- },
234
- removeSelected(personId) {
235
- this.selected = this.selected.filter(p => p.PersonId !== personId);
236
- },
237
- emitMergeAccounts() {
238
- if (!this.canMerge) return;
239
-
240
- this.$emit('merge:merge', {
241
- rootPersonId: this.rootPersonId,
242
- mergePersonIds: this.selected.map(p => p.PersonId)
243
- });
244
- }
245
- }
246
- };
247
- </script>
1
+ <template>
2
+ <section class="w-full">
3
+ <div class="flex w-full flex-col gap-6 md:flex-row">
4
+ <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
5
+ <BaseText
6
+ :text="`Merge into this account: ${person?.DisplayName || 'Root Account'}`"
7
+ size="md"
8
+ color="primary"
9
+ />
10
+
11
+ <div class="mt-3 space-y-2">
12
+ <div class="text-sm text-quaternary">
13
+ <span class="font-semibold text-primary">PersonId:</span> {{ rootPersonId }}
14
+ </div>
15
+ <div class="text-sm text-quaternary">
16
+ <span class="font-semibold text-primary">Legal Name:</span> {{ legalName }}
17
+ </div>
18
+ <div class="text-sm text-quaternary">
19
+ <span class="font-semibold text-primary">Club:</span> {{ clubName }}
20
+ </div>
21
+ <div class="text-sm text-quaternary">
22
+ <span class="font-semibold text-primary">Email:</span> {{ primaryEmail }}
23
+ </div>
24
+ </div>
25
+
26
+ <div class="mt-4 flex h-64 flex-col justify-between">
27
+ <div class="min-h-0">
28
+ <BaseText text="Accounts to merge in" size="sm" color="quaternary" weight="bold" />
29
+ <div class="border-b border-dropdownSelect h-2"></div>
30
+ <div v-if="selected.length === 0" class="mt-2 text-sm text-quaternary">None selected yet.</div>
31
+ <div v-else class="mt-2 max-h-44 overflow-y-auto border border-dropdownSelect rounded-lg">
32
+ <div
33
+ v-for="p in selected"
34
+ :key="p.PersonId"
35
+ class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
36
+ >
37
+ <div class="min-w-0">
38
+ <div class="text-sm text-primary font-semibold truncate">
39
+ {{ p.DisplayName }}
40
+ <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
41
+ </div>
42
+ <div class="text-xs text-quaternary truncate">
43
+ {{ p.FirstName }} {{ p.LastName }}
44
+ <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
45
+ </div>
46
+ </div>
47
+
48
+ <BaseButton
49
+ color="warn"
50
+ label="Remove"
51
+ size="xs"
52
+ type="primary"
53
+ @buttonClick="removeSelected(p.PersonId)"
54
+ />
55
+ </div>
56
+ </div>
57
+ </div>
58
+
59
+ <div class="flex justify-end">
60
+ <BaseButton
61
+ color="warn"
62
+ label="Merge Accounts Together"
63
+ size="sm"
64
+ type="primary"
65
+ :disabled="!canMerge"
66
+ @buttonClick="emitMergeAccounts"
67
+ />
68
+ </div>
69
+ </div>
70
+ </section>
71
+
72
+ <section class="border border-dropdownSelect rounded-lg p-4 bg-white md:w-1/2">
73
+ <BaseText text="Results" size="md" color="primary" />
74
+
75
+ <div class="mt-4">
76
+ <TitledInput
77
+ title="Filter people"
78
+ placeholder="Type name or club..."
79
+ :inputValue="filterText"
80
+ @update:value="filterText = $event"
81
+ />
82
+ <div class="text-xs text-quaternary mt-1">Filters Display Name, First/Last Name, or Club Name.</div>
83
+ </div>
84
+
85
+ <div class="mt-4 flex items-center justify-between text-xs text-quaternary">
86
+ <span> Showing {{ filteredPeople.length }}{{ totalMatches > resultLimit ? '+' : '' }} results </span>
87
+ <span v-if="totalMatches > resultLimit"> (limited to first {{ resultLimit }}) </span>
88
+ </div>
89
+
90
+ <div class="mt-2 border border-dropdownSelect rounded-lg h-64 overflow-y-auto">
91
+ <div
92
+ v-for="p in filteredPeople"
93
+ :key="p.PersonId"
94
+ class="flex items-center justify-between px-3 py-2 border-b border-dropdownSelect last:border-b-0"
95
+ >
96
+ <div class="min-w-0">
97
+ <div class="text-sm text-primary font-semibold truncate">
98
+ <span class="text-xs text-quaternary font-normal">(#{{ p.PersonId }})</span>
99
+ {{ resultTitle(p) }}
100
+ </div>
101
+ <div class="text-xs text-quaternary truncate">
102
+ {{ p.FirstName }} {{ p.LastName }}
103
+ <span v-if="p?.Club?.Name">{{ personClubSuffix(p) }}</span>
104
+ </div>
105
+ </div>
106
+
107
+ <BaseButton color="neutral" label="Add" size="xs" type="primary" @buttonClick="addSelected(p)" />
108
+ </div>
109
+
110
+ <div v-if="filteredPeople.length === 0" class="px-3 py-3 text-sm text-quaternary">No matches.</div>
111
+ </div>
112
+ </section>
113
+ </div>
114
+ </section>
115
+ </template>
116
+
117
+ <script>
118
+ import BaseText from '../../../../Atoms/Text/BaseText.vue';
119
+ import TitledInput from '../../../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
120
+ import BaseButton from '../../../../Molecules/Buttons/BaseButton/BaseButton.vue';
121
+
122
+ const getPersonSearchValues = person => {
123
+ const searchablePerson = person || {};
124
+ const club = searchablePerson.Club || {};
125
+ return [
126
+ searchablePerson.DisplayName,
127
+ searchablePerson.FirstName,
128
+ searchablePerson.LastName,
129
+ club.Name,
130
+ club.ShortName
131
+ ];
132
+ };
133
+
134
+ const normalizeSearchValue = value => String(value || '').toLowerCase();
135
+
136
+ const personMatchesQuery = (person, query) =>
137
+ getPersonSearchValues(person).some(value => normalizeSearchValue(value).includes(query));
138
+
139
+ export default {
140
+ name: 'MergeAccounts',
141
+ components: { BaseText, TitledInput, BaseButton },
142
+ emits: ['merge:merge'],
143
+ props: {
144
+ person: { type: Object, required: true },
145
+ people: { type: Array, required: true }
146
+ },
147
+ data() {
148
+ return {
149
+ filterText: '',
150
+ selected: [],
151
+ resultLimit: 200
152
+ };
153
+ },
154
+ computed: {
155
+ rootPersonId() {
156
+ return this.person?.PersonId ?? '';
157
+ },
158
+ legalName() {
159
+ const first = this.person?.FirstName || '';
160
+ const last = this.person?.LastName || '';
161
+ return `${first} ${last}`.trim() || '-';
162
+ },
163
+ clubName() {
164
+ return this.person?.Club?.Name || '-';
165
+ },
166
+ primaryEmail() {
167
+ const emails = this.person?.PersonEmails || [];
168
+ const primary = emails.find(email => email.IsPrimary);
169
+ return primary?.EmailAddress || '-';
170
+ },
171
+ selectedIds() {
172
+ return new Set(this.selected.map(p => p.PersonId));
173
+ },
174
+ canMerge() {
175
+ return this.selected.length > 0;
176
+ },
177
+ normalizedFilterText() {
178
+ return (this.filterText || '').trim().toLowerCase();
179
+ },
180
+ candidatePeople() {
181
+ return (this.people || []).filter(
182
+ p => p && p.PersonId !== this.rootPersonId && !this.selectedIds.has(p.PersonId)
183
+ );
184
+ },
185
+ matchingPeople() {
186
+ const q = this.normalizedFilterText;
187
+
188
+ if (!q) return this.candidatePeople;
189
+
190
+ return this.candidatePeople.filter(p => this.matchesQuery(p, q));
191
+ },
192
+ totalMatches() {
193
+ return this.matchingPeople.length;
194
+ },
195
+ filteredPeople() {
196
+ return this.matchingPeople.slice(0, this.resultLimit);
197
+ }
198
+ },
199
+ watch: {
200
+ rootPersonId() {
201
+ this.selected = [];
202
+ },
203
+ people() {
204
+ this.removeUnavailableSelectedPeople();
205
+ }
206
+ },
207
+ methods: {
208
+ personClubSuffix(p) {
209
+ return ` - ${p.Club.Name}`;
210
+ },
211
+ resultTitle(p) {
212
+ const email = this.getPrimaryEmail(p);
213
+
214
+ if (!email) return p.DisplayName || '';
215
+
216
+ return `${p.DisplayName} - ${email}`;
217
+ },
218
+ getPrimaryEmail(p) {
219
+ const emails = p?.PersonEmails || [];
220
+ return emails.find(email => email.IsPrimary)?.EmailAddress || '';
221
+ },
222
+ matchesQuery(p, q) {
223
+ return personMatchesQuery(p, q);
224
+ },
225
+ removeUnavailableSelectedPeople() {
226
+ const availableIds = new Set((this.people || []).map(p => p?.PersonId));
227
+ this.selected = this.selected.filter(p => availableIds.has(p.PersonId));
228
+ },
229
+ addSelected(p) {
230
+ if (!p || p.PersonId === this.rootPersonId) return;
231
+ if (this.selectedIds.has(p.PersonId)) return;
232
+ this.selected = [...this.selected, p];
233
+ },
234
+ removeSelected(personId) {
235
+ this.selected = this.selected.filter(p => p.PersonId !== personId);
236
+ },
237
+ emitMergeAccounts() {
238
+ if (!this.canMerge) return;
239
+
240
+ this.$emit('merge:merge', {
241
+ rootPersonId: this.rootPersonId,
242
+ mergePersonIds: this.selected.map(p => p.PersonId)
243
+ });
244
+ }
245
+ }
246
+ };
247
+ </script>