@sellout/models 0.0.159 → 0.0.161
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/graphql/mutations/createSeason.mutation.js +1 -0
- package/.dist/graphql/mutations/createSeason.mutation.js.map +1 -1
- package/.dist/graphql/mutations/publishSeason.mutation.js +1 -0
- package/.dist/graphql/mutations/publishSeason.mutation.js.map +1 -1
- package/.dist/graphql/mutations/updateOrganization.mutation.js +3 -0
- package/.dist/graphql/mutations/updateOrganization.mutation.js.map +1 -1
- package/.dist/graphql/mutations/updateSeason.mutation.js +1 -0
- package/.dist/graphql/mutations/updateSeason.mutation.js.map +1 -1
- package/.dist/graphql/queries/profile.query.js +3 -0
- package/.dist/graphql/queries/profile.query.js.map +1 -1
- package/.dist/graphql/queries/publicEvent.query.js +3 -0
- package/.dist/graphql/queries/publicEvent.query.js.map +1 -1
- package/.dist/graphql/queries/publicSeason.query.js +7 -0
- package/.dist/graphql/queries/publicSeason.query.js.map +1 -1
- package/.dist/interfaces/ICreateOrderParams.d.ts +2 -0
- package/.dist/interfaces/IEvent.d.ts +11 -11
- package/.dist/interfaces/IEvent.js +2 -2
- package/.dist/interfaces/IEvent.js.map +1 -1
- package/.dist/interfaces/IOrderTicket.d.ts +2 -0
- package/.dist/interfaces/IOrganization.d.ts +3 -0
- package/.dist/interfaces/ISeason.d.ts +1 -0
- package/.dist/interfaces/ITeiMemberInfo.d.ts +6 -0
- package/.dist/interfaces/ITeiMemberInfo.js +3 -0
- package/.dist/interfaces/ITeiMemberInfo.js.map +1 -0
- package/.dist/interfaces/ITicketType.d.ts +2 -0
- package/.dist/schemas/Order.d.ts +18 -0
- package/.dist/schemas/Order.js +20 -1
- package/.dist/schemas/Order.js.map +1 -1
- package/.dist/schemas/Organization.d.ts +15 -0
- package/.dist/schemas/Organization.js +12 -0
- package/.dist/schemas/Organization.js.map +1 -1
- package/.dist/schemas/Season.d.ts +5 -0
- package/.dist/schemas/Season.js +5 -1
- package/.dist/schemas/Season.js.map +1 -1
- package/.dist/sellout-proto.js +396 -0
- package/.dist/utils/SeasonUtil.d.ts +2 -0
- package/.dist/utils/SeasonUtil.js +75 -0
- package/.dist/utils/SeasonUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/graphql/mutations/createSeason.mutation.ts +1 -0
- package/src/graphql/mutations/publishSeason.mutation.ts +1 -0
- package/src/graphql/mutations/updateOrganization.mutation.ts +3 -0
- package/src/graphql/mutations/updateSeason.mutation.ts +1 -0
- package/src/graphql/queries/profile.query.ts +3 -0
- package/src/graphql/queries/publicEvent.query.ts +3 -0
- package/src/graphql/queries/publicSeason.query.ts +7 -0
- package/src/interfaces/ICreateOrderParams.ts +2 -0
- package/src/interfaces/IEvent.ts +27 -28
- package/src/interfaces/IOrderTicket.ts +2 -1
- package/src/interfaces/IOrganization.ts +3 -0
- package/src/interfaces/ISeason.ts +1 -0
- package/src/interfaces/ITeiMemberInfo.ts +6 -0
- package/src/interfaces/ITicketType.ts +2 -0
- package/src/proto/order.proto +9 -0
- package/src/proto/organization.proto +3 -0
- package/src/proto/season.proto +1 -0
- package/src/schemas/Order.ts +32 -12
- package/src/schemas/Organization.ts +12 -0
- package/src/schemas/Season.ts +5 -1
- package/src/utils/EventUtil.ts +1 -1
- package/src/utils/SeasonUtil.ts +84 -0
package/src/utils/SeasonUtil.ts
CHANGED
|
@@ -6,6 +6,9 @@ import * as Time from "@sellout/utils/.dist/time";
|
|
|
6
6
|
import ISeason from "../interfaces/ISeason";
|
|
7
7
|
import ITicketType from "../interfaces/ITicketType";
|
|
8
8
|
import ISeasonCustomField from "../interfaces/ISeasonCustomField";
|
|
9
|
+
import IOrderCustomField from "../interfaces/IOrderCustomField";
|
|
10
|
+
import { CustomFieldTypeEnum } from "../enums/CustomFieldTypeEnum";
|
|
11
|
+
import { DropDownEnum } from "../enums/DropDownEnum";
|
|
9
12
|
|
|
10
13
|
export default {
|
|
11
14
|
/****************************************************************************************
|
|
@@ -373,4 +376,85 @@ export default {
|
|
|
373
376
|
.unknown(true);
|
|
374
377
|
return customFieldSchema.validate(customField);
|
|
375
378
|
},
|
|
379
|
+
customFieldsAreValid(
|
|
380
|
+
seasonCustomFields: ISeasonCustomField[],
|
|
381
|
+
orderCustomFields: IOrderCustomField[]
|
|
382
|
+
): boolean {
|
|
383
|
+
const activeFields =
|
|
384
|
+
seasonCustomFields?.filter(
|
|
385
|
+
(seasonCustomField) => seasonCustomField.active
|
|
386
|
+
) ?? [];
|
|
387
|
+
|
|
388
|
+
const validFields =
|
|
389
|
+
activeFields?.filter((eventCustomField) => {
|
|
390
|
+
const { _id, minLength, maxLength, minValue, maxValue, required } =
|
|
391
|
+
eventCustomField;
|
|
392
|
+
|
|
393
|
+
const orderCustomField = orderCustomFields?.find(
|
|
394
|
+
(orderCustomField) => orderCustomField.customFieldId === _id
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
// Field is not required and orderCustomField not empty
|
|
398
|
+
if (!required && !orderCustomField) return true;
|
|
399
|
+
|
|
400
|
+
// Field has not been filled out
|
|
401
|
+
if (!orderCustomField) return false;
|
|
402
|
+
|
|
403
|
+
let { value } = orderCustomField;
|
|
404
|
+
|
|
405
|
+
if (
|
|
406
|
+
!required &&
|
|
407
|
+
(value === undefined ||
|
|
408
|
+
value === "NaN" ||
|
|
409
|
+
value === "" ||
|
|
410
|
+
value === DropDownEnum.Select)
|
|
411
|
+
) {
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if (eventCustomField?.type === CustomFieldTypeEnum.Text) {
|
|
416
|
+
value = <string>value;
|
|
417
|
+
if (value) {
|
|
418
|
+
if (minLength === 0 && maxLength === 0 && value.length > 0) {
|
|
419
|
+
return true;
|
|
420
|
+
} else if (minLength === 0 && value.length <= maxLength) {
|
|
421
|
+
return true;
|
|
422
|
+
} else if (maxLength === 0 && minLength <= value.length) {
|
|
423
|
+
return true;
|
|
424
|
+
} else if (minLength <= value.length && value.length <= maxLength) {
|
|
425
|
+
return true;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return false;
|
|
429
|
+
} else if (eventCustomField.type === CustomFieldTypeEnum.Dropdown) {
|
|
430
|
+
value = <string>value;
|
|
431
|
+
if (value !== "" && value !== DropDownEnum.Select) {
|
|
432
|
+
return true;
|
|
433
|
+
}
|
|
434
|
+
return false;
|
|
435
|
+
} else if (eventCustomField.type === CustomFieldTypeEnum.Address) {
|
|
436
|
+
value = <string>value;
|
|
437
|
+
if (value !== "") {
|
|
438
|
+
return true;
|
|
439
|
+
}
|
|
440
|
+
return false;
|
|
441
|
+
} else {
|
|
442
|
+
value = <number>value;
|
|
443
|
+
if (value) {
|
|
444
|
+
if (minValue === 0 && maxValue === 0 && value > 0) {
|
|
445
|
+
return true;
|
|
446
|
+
} else if (minValue === 0 && value <= maxValue) {
|
|
447
|
+
return true;
|
|
448
|
+
} else if (maxValue === 0 && minValue <= value) {
|
|
449
|
+
return true;
|
|
450
|
+
} else if (minValue <= value && value <= maxValue) {
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
}) ?? [];
|
|
457
|
+
|
|
458
|
+
return validFields.length === activeFields.length;
|
|
459
|
+
},
|
|
376
460
|
};
|