@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.
Files changed (61) hide show
  1. package/.dist/graphql/mutations/createSeason.mutation.js +1 -0
  2. package/.dist/graphql/mutations/createSeason.mutation.js.map +1 -1
  3. package/.dist/graphql/mutations/publishSeason.mutation.js +1 -0
  4. package/.dist/graphql/mutations/publishSeason.mutation.js.map +1 -1
  5. package/.dist/graphql/mutations/updateOrganization.mutation.js +3 -0
  6. package/.dist/graphql/mutations/updateOrganization.mutation.js.map +1 -1
  7. package/.dist/graphql/mutations/updateSeason.mutation.js +1 -0
  8. package/.dist/graphql/mutations/updateSeason.mutation.js.map +1 -1
  9. package/.dist/graphql/queries/profile.query.js +3 -0
  10. package/.dist/graphql/queries/profile.query.js.map +1 -1
  11. package/.dist/graphql/queries/publicEvent.query.js +3 -0
  12. package/.dist/graphql/queries/publicEvent.query.js.map +1 -1
  13. package/.dist/graphql/queries/publicSeason.query.js +7 -0
  14. package/.dist/graphql/queries/publicSeason.query.js.map +1 -1
  15. package/.dist/interfaces/ICreateOrderParams.d.ts +2 -0
  16. package/.dist/interfaces/IEvent.d.ts +11 -11
  17. package/.dist/interfaces/IEvent.js +2 -2
  18. package/.dist/interfaces/IEvent.js.map +1 -1
  19. package/.dist/interfaces/IOrderTicket.d.ts +2 -0
  20. package/.dist/interfaces/IOrganization.d.ts +3 -0
  21. package/.dist/interfaces/ISeason.d.ts +1 -0
  22. package/.dist/interfaces/ITeiMemberInfo.d.ts +6 -0
  23. package/.dist/interfaces/ITeiMemberInfo.js +3 -0
  24. package/.dist/interfaces/ITeiMemberInfo.js.map +1 -0
  25. package/.dist/interfaces/ITicketType.d.ts +2 -0
  26. package/.dist/schemas/Order.d.ts +18 -0
  27. package/.dist/schemas/Order.js +20 -1
  28. package/.dist/schemas/Order.js.map +1 -1
  29. package/.dist/schemas/Organization.d.ts +15 -0
  30. package/.dist/schemas/Organization.js +12 -0
  31. package/.dist/schemas/Organization.js.map +1 -1
  32. package/.dist/schemas/Season.d.ts +5 -0
  33. package/.dist/schemas/Season.js +5 -1
  34. package/.dist/schemas/Season.js.map +1 -1
  35. package/.dist/sellout-proto.js +396 -0
  36. package/.dist/utils/SeasonUtil.d.ts +2 -0
  37. package/.dist/utils/SeasonUtil.js +75 -0
  38. package/.dist/utils/SeasonUtil.js.map +1 -1
  39. package/package.json +3 -3
  40. package/src/graphql/mutations/createSeason.mutation.ts +1 -0
  41. package/src/graphql/mutations/publishSeason.mutation.ts +1 -0
  42. package/src/graphql/mutations/updateOrganization.mutation.ts +3 -0
  43. package/src/graphql/mutations/updateSeason.mutation.ts +1 -0
  44. package/src/graphql/queries/profile.query.ts +3 -0
  45. package/src/graphql/queries/publicEvent.query.ts +3 -0
  46. package/src/graphql/queries/publicSeason.query.ts +7 -0
  47. package/src/interfaces/ICreateOrderParams.ts +2 -0
  48. package/src/interfaces/IEvent.ts +27 -28
  49. package/src/interfaces/IOrderTicket.ts +2 -1
  50. package/src/interfaces/IOrganization.ts +3 -0
  51. package/src/interfaces/ISeason.ts +1 -0
  52. package/src/interfaces/ITeiMemberInfo.ts +6 -0
  53. package/src/interfaces/ITicketType.ts +2 -0
  54. package/src/proto/order.proto +9 -0
  55. package/src/proto/organization.proto +3 -0
  56. package/src/proto/season.proto +1 -0
  57. package/src/schemas/Order.ts +32 -12
  58. package/src/schemas/Organization.ts +12 -0
  59. package/src/schemas/Season.ts +5 -1
  60. package/src/utils/EventUtil.ts +1 -1
  61. package/src/utils/SeasonUtil.ts +84 -0
@@ -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
  };