@dcrackel/hematournamentui 1.0.709 → 1.0.711

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 (24) hide show
  1. package/README.md +16 -0
  2. package/dist/HemaTournamentUI-lib.es.js +4343 -4086
  3. package/dist/HemaTournamentUI-lib.umd.js +27 -27
  4. package/dist/hematournamentui-tailwind.css +3 -0
  5. package/package.json +1 -1
  6. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.stories.js +48 -41
  7. package/src/stories/Organisms/Wizards/EditEventWizard/BasicEventInfo/BasicEventInfo.vue +227 -206
  8. package/src/stories/Organisms/Wizards/EditEventWizard/DirectElimination/DirectElimination.vue +226 -225
  9. package/src/stories/Organisms/Wizards/EditEventWizard/DirectEliminationPromotion/DirectEliminationPromotion.vue +204 -204
  10. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.stories.js +133 -91
  11. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.test.js +191 -0
  12. package/src/stories/Organisms/Wizards/EditEventWizard/EditEventWizard.vue +366 -309
  13. package/src/stories/Organisms/Wizards/EditEventWizard/EventCustomization/EventCustomization.vue +172 -171
  14. package/src/stories/Organisms/Wizards/EditEventWizard/PoolConfiguration/PoolConfiguration.vue +216 -215
  15. package/src/stories/Organisms/Wizards/EditEventWizard/PriceFields.test.js +79 -0
  16. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.stories.js +93 -52
  17. package/src/stories/Templates/EventManagement/EditEventInfo/EditEventInfo.vue +91 -75
  18. package/src/stories/Templates/TournamentManagement/TournamentManagement.stories.js +84 -83
  19. package/src/stories/Templates/TournamentManagement/TournamentManagement.test.js +114 -0
  20. package/src/stories/Templates/TournamentManagement/TournamentManagement.vue +363 -360
  21. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.stories.js +116 -113
  22. package/src/stories/Templates/TournamentManagement/TournamentPageOne/TournamentPageOne.vue +307 -280
  23. package/src/stories/Util/Validations/PriceValidation.js +6 -0
  24. package/src/stories/Util/Validations/TournamentFieldsValidations.js +4 -0
@@ -1,280 +1,307 @@
1
- <template>
2
- <section class="w-full">
3
- <div v-if="isNewTournament" class="w-full flex flex-row justify-center">
4
- <BaseText
5
- :color="'quaternary'"
6
- :size="'sm'"
7
- :text="'Step 1 out of 2'"
8
- :weight="'normal'"
9
- data-testid="text-step"
10
- />
11
- </div>
12
- <div class="w-full flex flex-row justify-center my-4">
13
- <BaseText
14
- v-if="isNewTournament"
15
- :color="'primaryHighlight'"
16
- :size="'2xl'"
17
- :text="'Add New Tournament'"
18
- :weight="'normal'"
19
- data-testid="text-add-tournament"
20
- />
21
- <BaseText
22
- v-if="!isNewTournament"
23
- :color="'primaryHighlight'"
24
- :size="'2xl'"
25
- :text="'Basic Tournament Information'"
26
- :weight="'normal'"
27
- data-testid="text-add-tournament"
28
- />
29
- </div>
30
- <div class="w-full flex flex-row justify-center my-4">
31
- <ImageCropper
32
- :urlToImage="tournamentImage"
33
- :uploadImageName="uploadImageName"
34
- :uploadServer="uploadServer"
35
- :imageServer="imageServer"
36
- @update:url="handleNewImageUrl"
37
- />
38
- </div>
39
-
40
- <TitledInput
41
- :inputValue="tournamentName"
42
- :invalid="isFieldInvalid('Name')"
43
- :title="getValidationLabel('Name', 'Tournament Name')"
44
- placeholder="Enter Tournament Name"
45
- @update:value="emitUpdate('Name', $event)"
46
- class="mb-4"
47
- />
48
-
49
- <div class="flex flex-col mb-4">
50
- <BaseText
51
- :color="'primaryHighlight'"
52
- :invalid="isFieldInvalid('Address')"
53
- :text="getValidationLabel('Address', 'Location')"
54
- :size="'sm'"
55
- :weight="'normal'"
56
- class="mb-1"
57
- data-testid="text-address"
58
- />
59
- <FindLocation
60
- :placeholder="addressName"
61
- :addBorder="true"
62
- :locations="locations"
63
- :invalid="isFieldInvalid('Address')"
64
- addNewText="Add New"
65
- @update:location="handleAddressUpdate"
66
- @submit:location="handleAddressUpdate"
67
- @submit:addNewAddress="handleAddNewAddress"
68
- />
69
- </div>
70
-
71
- <div class="flex flex-row mb-4">
72
- <div class="w-3/4 mr-1">
73
- <BaseText
74
- :color="'primaryHighlight'"
75
- :invalid="isFieldInvalid('StartDate')"
76
- :size="'sm'"
77
- :text="getValidationLabel('StartDate', 'Start Date')"
78
- :weight="'normal'"
79
- class="mb-1"
80
- data-testid="text-start-date"
81
- />
82
- <DatePicker
83
- :invalid="isFieldInvalid('StartDate')"
84
- :setDate="startDate"
85
- :userLevel="userLevel"
86
- @update:selectedDate="emitUpdate('StartDate', $event)"
87
- />
88
- </div>
89
- <div>
90
- <TitledInput
91
- :inputValue="totalDays"
92
- :invalid="isFieldInvalid('TotalDays')"
93
- :placeholder="'Number of Days'"
94
- :inputType="'number'"
95
- :title="getValidationLabel('TotalDays', 'Number of Days')"
96
- @update:value="emitUpdate('TotalDays', $event)"
97
- />
98
- </div>
99
- </div>
100
-
101
- <div class="w-full mr-1 mb-4">
102
- <BaseText
103
- :color="'primaryHighlight'"
104
- :invalid="isFieldInvalid('RegistrationCutOff')"
105
- :size="'sm'"
106
- :text="getValidationLabel('RegistrationCutOff', 'Registration Cut Off')"
107
- :weight="'normal'"
108
- class="mb-1"
109
- data-testid="text-start-date"
110
- />
111
- <DatePicker
112
- :invalid="isFieldInvalid('RegistrationCutOff')"
113
- :setDate="registrationCutOff"
114
- :userLevel="userLevel"
115
- @update:selectedDate="emitUpdate('RegistrationCutOff', $event)"
116
- />
117
- </div>
118
-
119
- <div class="flex flex-col mb-4">
120
- <BaseText
121
- :color="'primaryHighlight'"
122
- :invalid="isFieldInvalid('Description')"
123
- :size="'sm'"
124
- :text="getValidationLabel('Description', 'Description')"
125
- :weight="'normal'"
126
- class="mb-1"
127
- data-testid="text-description"
128
- />
129
- <TextBoxEditor
130
- :invalid="isFieldInvalid('Description')"
131
- :initialContent="description"
132
- @update:editorContent="emitUpdate('Description', $event)"
133
- />
134
- </div>
135
-
136
- <div class="flex flex-col pb-4 mr-4">
137
- <BaseText
138
- :color="'primaryHighlight'"
139
- :invalid="false"
140
- :size="'sm'"
141
- :text="'Primary Contact'"
142
- :weight="'normal'"
143
- class="mb-1"
144
- data-testid="text-primary-contact"
145
- />
146
- <FindPerson
147
- :addBorder="true"
148
- :persons="persons"
149
- :defaultValue="getDefaultPerson"
150
- addNewText="Add New Person"
151
- @add-new-person="handleAddNewPerson"
152
- @person-selected="handlePrimaryContactUpdate"
153
- />
154
- </div>
155
- </section>
156
- </template>
157
-
158
- <script>
159
- import TitledInput from '../../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
160
- import FindLocation from '../../../Organisms/ComplexInputs/FindLocation/FindLocation.vue';
161
- import DatePicker from '../../../Organisms/ComplexInputs/DatePicker/DatePicker.vue';
162
- import BaseText from '../../../Atoms/Text/BaseText.vue';
163
- import TextBoxEditor from '../../../Organisms/ComplexInputs/TextBoxEditor/TextBoxEditor.vue';
164
- import ImageCropper from '../../../Organisms/ComplexInputs/ImageCropper/ImageCropper.vue';
165
- import FindPerson from '../../../Organisms/ComplexInputs/FindPerson/FindPerson.vue';
166
-
167
- export default {
168
- name: 'TournamentPageOne',
169
- emits: ['update:tournament', 'update:image', 'update:address', 'add:newAddress', 'add:newPerson'],
170
- props: {
171
- tournament: {
172
- type: Object,
173
- required: true
174
- },
175
- locations: {
176
- type: Array,
177
- required: true
178
- },
179
- persons: {
180
- type: Array,
181
- required: true
182
- },
183
- validation: {
184
- type: Object,
185
- required: true
186
- },
187
- uploadImageName: {
188
- type: String,
189
- default: 't-default-image'
190
- },
191
- uploadServer: {
192
- type: String,
193
- default: ''
194
- },
195
- imageServer: {
196
- type: String,
197
- default: ''
198
- },
199
- isNewTournament: {
200
- type: Boolean,
201
- default: true
202
- },
203
- userLevel: {
204
- type: String,
205
- default: 'Club'
206
- }
207
- },
208
- components: {
209
- FindPerson,
210
- ImageCropper,
211
- BaseText,
212
- DatePicker,
213
- FindLocation,
214
- TitledInput,
215
- TextBoxEditor
216
- },
217
- computed: {
218
- tournamentImage() {
219
- if (this.tournament.Images && this.tournament.Images.length > 0) {
220
- return this.tournament.Images[0].URL;
221
- }
222
- return '';
223
- },
224
- tournamentName() {
225
- return this.tournament?.Name || '';
226
- },
227
- addressName() {
228
- return this.tournament?.Address?.Name || '';
229
- },
230
- startDate() {
231
- return this.tournament?.StartDate || new Date();
232
- },
233
- totalDays() {
234
- return this.tournament?.TotalDays || 1;
235
- },
236
- registrationCutOff() {
237
- return this.tournament?.RegistrationCutOff || new Date();
238
- },
239
- description() {
240
- return this.tournament?.Description || '';
241
- },
242
- getDefaultPerson: function () {
243
- const person = this.persons.find(p => p.PersonId === this.tournament?.PrimaryContactId);
244
- return person ? person.DisplayName : '';
245
- }
246
- },
247
- methods: {
248
- handleNewImageUrl(url) {
249
- this.$emit('update:image', { ImageLink: url });
250
- },
251
- handleAddNewAddress(newAddress) {
252
- this.$emit('add:newAddress', newAddress);
253
- },
254
- handleAddressUpdate(updatedAddress) {
255
- this.$emit('update:address', updatedAddress);
256
- },
257
- handleAddNewPerson(personName) {
258
- this.$emit('add:newPerson', personName);
259
- },
260
- handlePrimaryContactUpdate(person) {
261
- if (!person) return;
262
- this.$emit('update:tournament', { PrimaryContactId: person.PersonId });
263
- },
264
- emitUpdate(field, value) {
265
- this.$emit('update:tournament', { [field]: value });
266
- },
267
- getFieldValidation(field) {
268
- return this.validation?.[field] || { invalid: false, message: '' };
269
- },
270
- isFieldInvalid(field) {
271
- return this.getFieldValidation(field).invalid;
272
- },
273
- getValidationLabel(field, label) {
274
- const fieldValidation = this.getFieldValidation(field);
275
- if (!fieldValidation.invalid) return label;
276
- return `${label} - ${fieldValidation.message}`;
277
- }
278
- }
279
- };
280
- </script>
1
+ <template>
2
+ <section class="w-full">
3
+ <div v-if="isNewTournament" class="w-full flex flex-row justify-center">
4
+ <BaseText
5
+ :color="'quaternary'"
6
+ :size="'sm'"
7
+ :text="'Step 1 out of 2'"
8
+ :weight="'normal'"
9
+ data-testid="text-step"
10
+ />
11
+ </div>
12
+ <div class="w-full flex flex-row justify-center my-4">
13
+ <BaseText
14
+ v-if="isNewTournament"
15
+ :color="'primaryHighlight'"
16
+ :size="'2xl'"
17
+ :text="'Add New Tournament'"
18
+ :weight="'normal'"
19
+ data-testid="text-add-tournament"
20
+ />
21
+ <BaseText
22
+ v-if="!isNewTournament"
23
+ :color="'primaryHighlight'"
24
+ :size="'2xl'"
25
+ :text="'Basic Tournament Information'"
26
+ :weight="'normal'"
27
+ data-testid="text-add-tournament"
28
+ />
29
+ </div>
30
+ <div class="w-full flex flex-row justify-center my-4">
31
+ <ImageCropper
32
+ :urlToImage="tournamentImage"
33
+ :uploadImageName="uploadImageName"
34
+ :uploadServer="uploadServer"
35
+ :imageServer="imageServer"
36
+ @update:url="handleNewImageUrl"
37
+ />
38
+ </div>
39
+
40
+ <TitledInput
41
+ :inputValue="tournamentName"
42
+ :invalid="isFieldInvalid('Name')"
43
+ :title="getValidationLabel('Name', 'Tournament Name')"
44
+ placeholder="Enter Tournament Name"
45
+ @update:value="emitUpdate('Name', $event)"
46
+ class="mb-4"
47
+ />
48
+
49
+ <TitledInput
50
+ :inputValue="basePrice"
51
+ :invalid="isFieldInvalid('BasePrice')"
52
+ :title="getValidationLabel('BasePrice', 'Base Price')"
53
+ placeholder="0.00"
54
+ @update:value="handleBasePriceUpdate"
55
+ @focusout="handleBasePriceBlur"
56
+ class="mb-4"
57
+ />
58
+
59
+ <div class="flex flex-col mb-4">
60
+ <BaseText
61
+ :color="'primaryHighlight'"
62
+ :invalid="isFieldInvalid('Address')"
63
+ :text="getValidationLabel('Address', 'Location')"
64
+ :size="'sm'"
65
+ :weight="'normal'"
66
+ class="mb-1"
67
+ data-testid="text-address"
68
+ />
69
+ <FindLocation
70
+ :placeholder="addressName"
71
+ :addBorder="true"
72
+ :locations="locations"
73
+ :invalid="isFieldInvalid('Address')"
74
+ addNewText="Add New"
75
+ @update:location="handleAddressUpdate"
76
+ @submit:location="handleAddressUpdate"
77
+ @submit:addNewAddress="handleAddNewAddress"
78
+ />
79
+ </div>
80
+
81
+ <div class="flex flex-row mb-4">
82
+ <div class="w-3/4 mr-1">
83
+ <BaseText
84
+ :color="'primaryHighlight'"
85
+ :invalid="isFieldInvalid('StartDate')"
86
+ :size="'sm'"
87
+ :text="getValidationLabel('StartDate', 'Start Date')"
88
+ :weight="'normal'"
89
+ class="mb-1"
90
+ data-testid="text-start-date"
91
+ />
92
+ <DatePicker
93
+ :invalid="isFieldInvalid('StartDate')"
94
+ :setDate="startDate"
95
+ :userLevel="userLevel"
96
+ @update:selectedDate="emitUpdate('StartDate', $event)"
97
+ />
98
+ </div>
99
+ <div>
100
+ <TitledInput
101
+ :inputValue="totalDays"
102
+ :invalid="isFieldInvalid('TotalDays')"
103
+ :placeholder="'Number of Days'"
104
+ :inputType="'number'"
105
+ :title="getValidationLabel('TotalDays', 'Number of Days')"
106
+ @update:value="emitUpdate('TotalDays', $event)"
107
+ />
108
+ </div>
109
+ </div>
110
+
111
+ <div class="w-full mr-1 mb-4">
112
+ <BaseText
113
+ :color="'primaryHighlight'"
114
+ :invalid="isFieldInvalid('RegistrationCutOff')"
115
+ :size="'sm'"
116
+ :text="getValidationLabel('RegistrationCutOff', 'Registration Cut Off')"
117
+ :weight="'normal'"
118
+ class="mb-1"
119
+ data-testid="text-start-date"
120
+ />
121
+ <DatePicker
122
+ :invalid="isFieldInvalid('RegistrationCutOff')"
123
+ :setDate="registrationCutOff"
124
+ :userLevel="userLevel"
125
+ @update:selectedDate="emitUpdate('RegistrationCutOff', $event)"
126
+ />
127
+ </div>
128
+
129
+ <div class="flex flex-col mb-4">
130
+ <BaseText
131
+ :color="'primaryHighlight'"
132
+ :invalid="isFieldInvalid('Description')"
133
+ :size="'sm'"
134
+ :text="getValidationLabel('Description', 'Description')"
135
+ :weight="'normal'"
136
+ class="mb-1"
137
+ data-testid="text-description"
138
+ />
139
+ <TextBoxEditor
140
+ :invalid="isFieldInvalid('Description')"
141
+ :initialContent="description"
142
+ @update:editorContent="emitUpdate('Description', $event)"
143
+ />
144
+ </div>
145
+
146
+ <div class="flex flex-col pb-4 mr-4">
147
+ <BaseText
148
+ :color="'primaryHighlight'"
149
+ :invalid="false"
150
+ :size="'sm'"
151
+ :text="'Primary Contact'"
152
+ :weight="'normal'"
153
+ class="mb-1"
154
+ data-testid="text-primary-contact"
155
+ />
156
+ <FindPerson
157
+ :addBorder="true"
158
+ :persons="persons"
159
+ :defaultValue="getDefaultPerson"
160
+ addNewText="Add New Person"
161
+ @add-new-person="handleAddNewPerson"
162
+ @person-selected="handlePrimaryContactUpdate"
163
+ />
164
+ </div>
165
+ </section>
166
+ </template>
167
+
168
+ <script>
169
+ import TitledInput from '../../../Molecules/CombinationInputs/TitledInput/TitledInput.vue';
170
+ import FindLocation from '../../../Organisms/ComplexInputs/FindLocation/FindLocation.vue';
171
+ import DatePicker from '../../../Organisms/ComplexInputs/DatePicker/DatePicker.vue';
172
+ import BaseText from '../../../Atoms/Text/BaseText.vue';
173
+ import TextBoxEditor from '../../../Organisms/ComplexInputs/TextBoxEditor/TextBoxEditor.vue';
174
+ import ImageCropper from '../../../Organisms/ComplexInputs/ImageCropper/ImageCropper.vue';
175
+ import FindPerson from '../../../Organisms/ComplexInputs/FindPerson/FindPerson.vue';
176
+
177
+ export default {
178
+ name: 'TournamentPageOne',
179
+ emits: ['update:tournament', 'update:image', 'update:address', 'add:newAddress', 'add:newPerson'],
180
+ props: {
181
+ tournament: {
182
+ type: Object,
183
+ required: true
184
+ },
185
+ locations: {
186
+ type: Array,
187
+ required: true
188
+ },
189
+ persons: {
190
+ type: Array,
191
+ required: true
192
+ },
193
+ validation: {
194
+ type: Object,
195
+ required: true
196
+ },
197
+ uploadImageName: {
198
+ type: String,
199
+ default: 't-default-image'
200
+ },
201
+ uploadServer: {
202
+ type: String,
203
+ default: ''
204
+ },
205
+ imageServer: {
206
+ type: String,
207
+ default: ''
208
+ },
209
+ isNewTournament: {
210
+ type: Boolean,
211
+ default: true
212
+ },
213
+ userLevel: {
214
+ type: String,
215
+ default: 'Club'
216
+ }
217
+ },
218
+ components: {
219
+ FindPerson,
220
+ ImageCropper,
221
+ BaseText,
222
+ DatePicker,
223
+ FindLocation,
224
+ TitledInput,
225
+ TextBoxEditor
226
+ },
227
+ data() {
228
+ return { basePriceDraft: null };
229
+ },
230
+ computed: {
231
+ tournamentImage() {
232
+ if (this.tournament.Images && this.tournament.Images.length > 0) {
233
+ return this.tournament.Images[0].URL;
234
+ }
235
+ return '';
236
+ },
237
+ tournamentName() {
238
+ return this.tournament?.Name || '';
239
+ },
240
+ basePrice() {
241
+ const price = this.tournament?.BasePrice ?? '';
242
+ if (price === '' || price === this.basePriceDraft) return price;
243
+ const amount = Number(price);
244
+ if (!Number.isFinite(amount)) return price;
245
+ return amount.toFixed(2);
246
+ },
247
+ addressName() {
248
+ return this.tournament?.Address?.Name || '';
249
+ },
250
+ startDate() {
251
+ return this.tournament?.StartDate || new Date();
252
+ },
253
+ totalDays() {
254
+ return this.tournament?.TotalDays || 1;
255
+ },
256
+ registrationCutOff() {
257
+ return this.tournament?.RegistrationCutOff || new Date();
258
+ },
259
+ description() {
260
+ return this.tournament?.Description || '';
261
+ },
262
+ getDefaultPerson: function () {
263
+ const person = this.persons.find(p => p.PersonId === this.tournament?.PrimaryContactId);
264
+ return person ? person.DisplayName : '';
265
+ }
266
+ },
267
+ methods: {
268
+ handleBasePriceUpdate(value) {
269
+ this.basePriceDraft = value;
270
+ this.emitUpdate('BasePrice', value);
271
+ },
272
+ handleBasePriceBlur() {
273
+ this.basePriceDraft = null;
274
+ },
275
+ handleNewImageUrl(url) {
276
+ this.$emit('update:image', { ImageLink: url });
277
+ },
278
+ handleAddNewAddress(newAddress) {
279
+ this.$emit('add:newAddress', newAddress);
280
+ },
281
+ handleAddressUpdate(updatedAddress) {
282
+ this.$emit('update:address', updatedAddress);
283
+ },
284
+ handleAddNewPerson(personName) {
285
+ this.$emit('add:newPerson', personName);
286
+ },
287
+ handlePrimaryContactUpdate(person) {
288
+ if (!person) return;
289
+ this.$emit('update:tournament', { PrimaryContactId: person.PersonId });
290
+ },
291
+ emitUpdate(field, value) {
292
+ this.$emit('update:tournament', { [field]: value });
293
+ },
294
+ getFieldValidation(field) {
295
+ return this.validation?.[field] || { invalid: false, message: '' };
296
+ },
297
+ isFieldInvalid(field) {
298
+ return this.getFieldValidation(field).invalid;
299
+ },
300
+ getValidationLabel(field, label) {
301
+ const fieldValidation = this.getFieldValidation(field);
302
+ if (!fieldValidation.invalid) return label;
303
+ return `${label} - ${fieldValidation.message}`;
304
+ }
305
+ }
306
+ };
307
+ </script>
@@ -0,0 +1,6 @@
1
+ export function validatePrice(value) {
2
+ const amount = Number(value);
3
+ const invalid = !Number.isFinite(amount) || amount < 0;
4
+
5
+ return { invalid, message: invalid ? 'Price must be a non-negative number.' : '' };
6
+ }
@@ -1,4 +1,8 @@
1
+ import { validatePrice } from './PriceValidation.js';
2
+
1
3
  export function validateField(field, value) {
4
+ if (field === 'BasePrice') return validatePrice(value);
5
+
2
6
  const rules = {
3
7
  Name: [
4
8
  { check: v => !v || v.trim().length === 0, message: 'Must have a name.' },