be-components 7.3.0 → 7.3.2

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 (52) hide show
  1. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js +70 -2
  2. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  3. package/lib/commonjs/CreateEngagement/api/index.js +78 -1
  4. package/lib/commonjs/CreateEngagement/api/index.js.map +1 -1
  5. package/lib/commonjs/CreateEngagement/index.js +351 -14
  6. package/lib/commonjs/CreateEngagement/index.js.map +1 -1
  7. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js +140 -18
  8. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js.map +1 -1
  9. package/lib/commonjs/PartnerPortal/components/CompetitionSelector.js +1 -1
  10. package/lib/commonjs/PartnerPortal/components/FlashCampaignManager.js +3 -1
  11. package/lib/commonjs/PartnerPortal/components/FlashCampaignManager.js.map +1 -1
  12. package/lib/commonjs/types.d.js.map +1 -1
  13. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js +70 -2
  14. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  15. package/lib/module/CreateEngagement/api/index.js +78 -1
  16. package/lib/module/CreateEngagement/api/index.js.map +1 -1
  17. package/lib/module/CreateEngagement/index.js +350 -15
  18. package/lib/module/CreateEngagement/index.js.map +1 -1
  19. package/lib/module/FlashMarket/components/ManageFlashMarket.js +140 -18
  20. package/lib/module/FlashMarket/components/ManageFlashMarket.js.map +1 -1
  21. package/lib/module/PartnerPortal/components/CompetitionSelector.js +1 -1
  22. package/lib/module/PartnerPortal/components/FlashCampaignManager.js +3 -1
  23. package/lib/module/PartnerPortal/components/FlashCampaignManager.js.map +1 -1
  24. package/lib/module/types.d.js.map +1 -1
  25. package/lib/typescript/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.d.ts.map +1 -1
  26. package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts +29 -1
  27. package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts.map +1 -1
  28. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts +12 -1
  29. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
  30. package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
  31. package/lib/typescript/lib/commonjs/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -1
  32. package/lib/typescript/lib/module/Bracket/components/ManageBracketCompetitionForm.d.ts.map +1 -1
  33. package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts +29 -1
  34. package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts.map +1 -1
  35. package/lib/typescript/lib/module/CreateEngagement/index.d.ts +12 -1
  36. package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
  37. package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
  38. package/lib/typescript/lib/module/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -1
  39. package/lib/typescript/src/Bracket/components/ManageBracketCompetitionForm.d.ts.map +1 -1
  40. package/lib/typescript/src/CreateEngagement/api/index.d.ts +14 -2
  41. package/lib/typescript/src/CreateEngagement/api/index.d.ts.map +1 -1
  42. package/lib/typescript/src/CreateEngagement/index.d.ts +15 -2
  43. package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
  44. package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/Bracket/components/ManageBracketCompetitionForm.tsx +55 -2
  47. package/src/CreateEngagement/api/index.ts +60 -2
  48. package/src/CreateEngagement/index.tsx +207 -9
  49. package/src/FlashMarket/components/ManageFlashMarket.tsx +74 -10
  50. package/src/PartnerPortal/components/CompetitionSelector.tsx +1 -1
  51. package/src/PartnerPortal/components/FlashCampaignManager.tsx +1 -1
  52. package/src/types.d.ts +1 -0
@@ -7,6 +7,7 @@ import { useColors } from '../constants/useColors';
7
7
  import ImageUploader from '../Components/ImageUploader';
8
8
  import moment from 'moment-mini';
9
9
  import LeagueSchedule from '../MarketComponents/components/LeagueSchedule';
10
+ import { BracketCompetitionHelpers } from '../Bracket/api';
10
11
  const sections = ['header', 'intro', 'step', 'info', 'groups', 'companies', 'create', 'image', 'success'];
11
12
  const steps = [{
12
13
  step_key: 'intro',
@@ -47,6 +48,7 @@ const steps = [{
47
48
  const CreateEngagement = ({
48
49
  float,
49
50
  player,
51
+ bracket_id,
50
52
  flash_campaign_id,
51
53
  init_engagement,
52
54
  onFocusPostiion,
@@ -66,6 +68,7 @@ const CreateEngagement = ({
66
68
  height: 0
67
69
  });
68
70
  const [draft_squares, setDraftSquares] = useState(undefined);
71
+ const [draft_bracket_competition, setDraftBracketCompetition] = useState(undefined);
69
72
  const [pending_engagement, setPendingEngagement] = useState({
70
73
  create_loading: false
71
74
  });
@@ -108,7 +111,7 @@ const CreateEngagement = ({
108
111
  loading: false
109
112
  });
110
113
  };
111
- const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash);
114
+ const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash, draft_bracket_competition);
112
115
  const handleNextStep = async () => {
113
116
  if (errors.length > 0) {
114
117
  return alert(errors.map(e => e));
@@ -228,6 +231,37 @@ const CreateEngagement = ({
228
231
  poll: new_flash_market
229
232
  });
230
233
  break;
234
+ case 'bracket':
235
+ if (!draft_bracket_competition) {
236
+ return alert('Unable to process');
237
+ }
238
+ if (errors.length > 0) {
239
+ return alert(errors.map(e => e));
240
+ }
241
+ setPendingEngagement({
242
+ ...pending_engagement,
243
+ create_loading: true
244
+ });
245
+ const bracket_resp = await CreateEngagementApi.getBracketById(draft_bracket_competition.bracket_id);
246
+ if (!bracket_resp) {
247
+ return alert('Unable to process. Please try again later');
248
+ }
249
+ const scoring = BracketCompetitionHelpers.getDefaultScoringRules('', bracket_resp.bracket_rounds);
250
+ const comp_response = await CreateEngagementApi.createBracketCompetition({
251
+ ...draft_bracket_competition,
252
+ image: draft_image,
253
+ company_id: active_company?.company_id,
254
+ group_id: active_group?.group_id
255
+ }, scoring);
256
+ if (!comp_response) {
257
+ return alert('Unable to process');
258
+ }
259
+ setPendingEngagement({
260
+ ...pending_engagement,
261
+ create_loading: false,
262
+ bracket_competition: comp_response.bracket_competition
263
+ });
264
+ break;
231
265
  default:
232
266
  return;
233
267
  //We cdont have one!
@@ -423,26 +457,36 @@ const CreateEngagement = ({
423
457
  if (active_step.step_key != 'group') {
424
458
  return /*#__PURE__*/React.createElement(React.Fragment, null);
425
459
  }
426
- return /*#__PURE__*/React.createElement(GroupSelector, {
460
+ return /*#__PURE__*/React.createElement(View, {
461
+ transparent: true,
462
+ style: {
463
+ margin: 20
464
+ }
465
+ }, /*#__PURE__*/React.createElement(GroupSelector, {
427
466
  groups: groups,
428
467
  active_group: active_group,
429
468
  onSelectGroup: g => setState({
430
469
  ...state,
431
470
  active_group: g
432
471
  })
433
- });
472
+ }));
434
473
  case 'companies':
435
474
  if (active_step.step_key != 'company') {
436
475
  return /*#__PURE__*/React.createElement(React.Fragment, null);
437
476
  }
438
- return /*#__PURE__*/React.createElement(CompanySelector, {
477
+ return /*#__PURE__*/React.createElement(View, {
478
+ transparent: true,
479
+ style: {
480
+ margin: 20
481
+ }
482
+ }, /*#__PURE__*/React.createElement(CompanySelector, {
439
483
  companies: companies,
440
484
  active_company: active_company,
441
485
  onSelectCompany: c => setState({
442
486
  ...state,
443
487
  active_company: c
444
488
  })
445
- });
489
+ }));
446
490
  case 'create':
447
491
  if (active_step.step_key != 'create') {
448
492
  return /*#__PURE__*/React.createElement(React.Fragment, null);
@@ -469,6 +513,14 @@ const CreateEngagement = ({
469
513
  onFocusPosition: onFocusPostiion,
470
514
  company: active_company
471
515
  });
516
+ case 'bracket':
517
+ return /*#__PURE__*/React.createElement(CreateBracketCompetition, {
518
+ group: active_group,
519
+ bracket_id: bracket_id,
520
+ onUpdateDraft: d => setDraftBracketCompetition(d),
521
+ onFocusPosition: onFocusPostiion,
522
+ company: active_company
523
+ });
472
524
  default:
473
525
  return /*#__PURE__*/React.createElement(React.Fragment, null);
474
526
  }
@@ -612,6 +664,207 @@ const IntroInfo = () => {
612
664
  }
613
665
  }, "\uD83D\uDCCA Track & Compete \u2013 See results, leaderboards, and bragging rights update in real time"));
614
666
  };
667
+ const CreateBracketCompetition = ({
668
+ bracket_id,
669
+ company,
670
+ group,
671
+ onFocusPosition,
672
+ onUpdateDraft
673
+ }) => {
674
+ const Colors = useColors();
675
+ const [create_state, setCreateState] = useState({
676
+ brackets: [],
677
+ leagues: [],
678
+ results_visible: false,
679
+ competition_result_types: [],
680
+ scoring: [],
681
+ loading: false,
682
+ draft_bracket_competition: {
683
+ ...CreateEngagementHelpers.generateBracketCompetition(),
684
+ bracket_id: bracket_id ?? '',
685
+ group_id: group?.group_id,
686
+ company_id: company?.company_id
687
+ }
688
+ });
689
+ const {
690
+ brackets,
691
+ leagues,
692
+ results_visible,
693
+ draft_bracket_competition,
694
+ competition_result_types
695
+ } = create_state;
696
+ const active_bracket = brackets.find(b => b.bracket_id == draft_bracket_competition.bracket_id);
697
+ const competition_result_type = competition_result_types.find(rt => rt.competition_result_type_id == draft_bracket_competition.competition_result_type_id);
698
+ useEffect(() => {
699
+ getData();
700
+ }, []);
701
+ useEffect(() => {
702
+ onUpdateDraft(draft_bracket_competition);
703
+ }, [JSON.stringify(draft_bracket_competition)]);
704
+ const getData = async () => {
705
+ setCreateState({
706
+ ...create_state,
707
+ loading: true
708
+ });
709
+ const s_leagues = await CreateEngagementApi.getLeagues();
710
+ const s_brackets = await CreateEngagementApi.getActiveBrackets();
711
+ let options = await CreateEngagementApi.getCompetitionOptions();
712
+ setCreateState({
713
+ ...create_state,
714
+ brackets: s_brackets,
715
+ competition_result_types: options.competition_result_types,
716
+ leagues: s_leagues,
717
+ loading: false
718
+ });
719
+ };
720
+ const renderResultTypes = data => {
721
+ return /*#__PURE__*/React.createElement(Button, {
722
+ transparent: true,
723
+ style: {
724
+ flexDirection: 'row',
725
+ borderRadius: 0,
726
+ padding: 10,
727
+ alignItems: 'center',
728
+ borderBottomWidth: 1,
729
+ borderColor: Colors.borders.light
730
+ },
731
+ onPress: () => setCreateState({
732
+ ...create_state,
733
+ results_visible: false,
734
+ draft_bracket_competition: {
735
+ ...draft_bracket_competition,
736
+ competition_result_type_id: data.item.competition_result_type_id
737
+ }
738
+ })
739
+ }, /*#__PURE__*/React.createElement(View, {
740
+ transparent: true,
741
+ style: {
742
+ flex: 1
743
+ }
744
+ }, /*#__PURE__*/React.createElement(Text, {
745
+ theme: "h1"
746
+ }, data.item.label), /*#__PURE__*/React.createElement(Text, {
747
+ theme: "description",
748
+ style: {
749
+ marginTop: 3
750
+ }
751
+ }, data.item.description)));
752
+ };
753
+ return /*#__PURE__*/React.createElement(View, null, /*#__PURE__*/React.createElement(View, {
754
+ style: {
755
+ padding: 10
756
+ }
757
+ }, /*#__PURE__*/React.createElement(Text, {
758
+ theme: "h1",
759
+ style: {
760
+ marginBottom: 10
761
+ }
762
+ }, "Competition Name"), /*#__PURE__*/React.createElement(TextInput, {
763
+ placeholder: "Add Name here...",
764
+ value: draft_bracket_competition.competition_name,
765
+ onFocusPosition: onFocusPosition,
766
+ style: {
767
+ borderColor: draft_bracket_competition.competition_name ? Colors.text.success : Colors.text.warning
768
+ },
769
+ onChangeText: text => setCreateState({
770
+ ...create_state,
771
+ draft_bracket_competition: {
772
+ ...draft_bracket_competition,
773
+ competition_name: text
774
+ }
775
+ })
776
+ })), /*#__PURE__*/React.createElement(View, {
777
+ style: {
778
+ padding: 10
779
+ }
780
+ }, /*#__PURE__*/React.createElement(Text, {
781
+ theme: "h1",
782
+ style: {
783
+ marginBottom: 10
784
+ }
785
+ }, "Competition Description"), /*#__PURE__*/React.createElement(TextInput, {
786
+ placeholder: "Add Description here...",
787
+ value: draft_bracket_competition.competition_description,
788
+ onFocusPosition: onFocusPosition,
789
+ style: {
790
+ borderColor: draft_bracket_competition.competition_description ? Colors.text.success : Colors.text.warning
791
+ },
792
+ onChangeText: text => setCreateState({
793
+ ...create_state,
794
+ draft_bracket_competition: {
795
+ ...draft_bracket_competition,
796
+ competition_description: text
797
+ }
798
+ })
799
+ })), /*#__PURE__*/React.createElement(View, {
800
+ style: {
801
+ padding: 10
802
+ }
803
+ }, /*#__PURE__*/React.createElement(Text, {
804
+ theme: "h1",
805
+ style: {
806
+ marginBottom: 10
807
+ }
808
+ }, "Select a Bracket"), /*#__PURE__*/React.createElement(BracketSelector, {
809
+ leagues: leagues,
810
+ brackets: brackets.filter(b => moment().isBefore(moment(b.scheduled_datetime))),
811
+ active_bracket: active_bracket,
812
+ onSelectBracket: bracket => {
813
+ setCreateState({
814
+ ...create_state,
815
+ draft_bracket_competition: {
816
+ ...draft_bracket_competition,
817
+ bracket_id: bracket?.bracket_id ?? '',
818
+ scheduled_datetime: bracket?.scheduled_datetime
819
+ }
820
+ });
821
+ }
822
+ })), /*#__PURE__*/React.createElement(View, {
823
+ style: {
824
+ padding: 10
825
+ }
826
+ }, /*#__PURE__*/React.createElement(Text, {
827
+ theme: "h1",
828
+ style: {
829
+ marginBottom: 10
830
+ }
831
+ }, "Payout Type"), /*#__PURE__*/React.createElement(Button, {
832
+ float: true,
833
+ style: {
834
+ borderColor: competition_result_type ? Colors.text.success : Colors.text.warning
835
+ },
836
+ onPress: () => setCreateState({
837
+ ...create_state,
838
+ results_visible: !results_visible
839
+ })
840
+ }, /*#__PURE__*/React.createElement(View, {
841
+ transparent: true,
842
+ style: {
843
+ flexDirection: 'row',
844
+ alignItems: 'center'
845
+ }
846
+ }, /*#__PURE__*/React.createElement(Text, {
847
+ style: {
848
+ flex: 1,
849
+ marginRight: 10
850
+ },
851
+ theme: "h1"
852
+ }, competition_result_type?.label ?? 'Select Payout'), /*#__PURE__*/React.createElement(Icons.ChevronIcon, {
853
+ direction: results_visible ? 'up' : 'down',
854
+ color: Colors.text.h1,
855
+ size: 8
856
+ })), results_visible ? /*#__PURE__*/React.createElement(View, {
857
+ transparent: true,
858
+ style: {
859
+ marginTop: 20
860
+ }
861
+ }, /*#__PURE__*/React.createElement(FlatList, {
862
+ data: competition_result_types.sort((a, b) => a.label.localeCompare(b.label)),
863
+ key: 'competition_reult_types',
864
+ keyExtractor: item => item.competition_result_type_id.toString(),
865
+ renderItem: renderResultTypes
866
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null))));
867
+ };
615
868
  const CreateFlashMarket = ({
616
869
  company,
617
870
  group,
@@ -945,7 +1198,7 @@ const EngagementOptions = ({
945
1198
  style: {
946
1199
  marginTop: 4
947
1200
  }
948
- }, "Create an auction squares game. Bid on squares until the auction ends. Buy and sell squares throughout the game."))), false ? /*#__PURE__*/React.createElement(Button, {
1201
+ }, "Create an auction squares game. Bid on squares until the auction ends. Buy and sell squares throughout the game."))), /*#__PURE__*/React.createElement(Button, {
949
1202
  key: "bracket",
950
1203
  float: true,
951
1204
  style: {
@@ -974,7 +1227,7 @@ const EngagementOptions = ({
974
1227
  style: {
975
1228
  marginTop: 4
976
1229
  }
977
- }, "Create a bracket. Make picks until the championship. Pick more correctly and win!"))) : /*#__PURE__*/React.createElement(React.Fragment, null), companies.length > 0 ? /*#__PURE__*/React.createElement(Button, {
1230
+ }, "Create a bracket. Make picks until the championship. Pick more correctly and win!"))), companies.length > 0 ? /*#__PURE__*/React.createElement(Button, {
978
1231
  key: "flash",
979
1232
  float: true,
980
1233
  style: {
@@ -1005,7 +1258,95 @@ const EngagementOptions = ({
1005
1258
  }
1006
1259
  }, "Create a custom flash market. Players bet on the perimutuel outcomes, get it right and get paid!"))) : /*#__PURE__*/React.createElement(React.Fragment, null));
1007
1260
  };
1008
- const GroupSelector = ({
1261
+ const BracketSelector = ({
1262
+ active_bracket,
1263
+ brackets,
1264
+ leagues,
1265
+ onSelectBracket
1266
+ }) => {
1267
+ const Colors = useColors();
1268
+ const [visible, setVisible] = useState(false);
1269
+ const renderBrackets = data => {
1270
+ const league = leagues.find(l => l.league_id == data.item.league_id);
1271
+ if (!league) {
1272
+ return /*#__PURE__*/React.createElement(React.Fragment, null);
1273
+ }
1274
+ return /*#__PURE__*/React.createElement(Button, {
1275
+ transparent: true,
1276
+ style: {
1277
+ flexDirection: 'row',
1278
+ alignItems: 'center',
1279
+ padding: 10,
1280
+ borderRadius: 0,
1281
+ borderBottomWidth: 1,
1282
+ borderColor: Colors.borders.light
1283
+ },
1284
+ onPress: () => {
1285
+ setVisible(false);
1286
+ onSelectBracket(data.item);
1287
+ }
1288
+ }, /*#__PURE__*/React.createElement(Image, {
1289
+ source: {
1290
+ uri: league.league_image
1291
+ },
1292
+ style: {
1293
+ height: 40,
1294
+ width: 40
1295
+ },
1296
+ resizeMode: "cover"
1297
+ }), /*#__PURE__*/React.createElement(View, {
1298
+ transparent: true,
1299
+ style: {
1300
+ flex: 1,
1301
+ marginLeft: 10
1302
+ }
1303
+ }, /*#__PURE__*/React.createElement(Text, {
1304
+ theme: "h1"
1305
+ }, data.item.bracket_name), /*#__PURE__*/React.createElement(Text, {
1306
+ theme: "description",
1307
+ style: {
1308
+ marginTop: 3
1309
+ }
1310
+ }, "Begins ", moment(data.item.scheduled_datetime).format('MMM DD hh:mm a'))));
1311
+ };
1312
+ return /*#__PURE__*/React.createElement(Button, {
1313
+ float: true,
1314
+ style: {
1315
+ borderColor: active_bracket ? Colors.text.success : Colors.text.warning
1316
+ },
1317
+ onPress: () => {
1318
+ setVisible(!visible);
1319
+ onSelectBracket(undefined);
1320
+ }
1321
+ }, /*#__PURE__*/React.createElement(View, {
1322
+ transparent: true,
1323
+ style: {
1324
+ flexDirection: 'row',
1325
+ alignItems: 'center'
1326
+ }
1327
+ }, /*#__PURE__*/React.createElement(Text, {
1328
+ style: {
1329
+ flex: 1,
1330
+ marginRight: 10
1331
+ },
1332
+ theme: "h1"
1333
+ }, active_bracket?.bracket_name ?? 'No Bracket'), /*#__PURE__*/React.createElement(Icons.ChevronIcon, {
1334
+ direction: visible ? 'up' : 'down',
1335
+ color: Colors.text.h1,
1336
+ size: 8
1337
+ })), visible ? /*#__PURE__*/React.createElement(View, {
1338
+ transparent: true,
1339
+ style: {
1340
+ marginTop: 20
1341
+ }
1342
+ }, /*#__PURE__*/React.createElement(FlatList, {
1343
+ data: brackets.sort((a, b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix()),
1344
+ key: 'bracket_selector',
1345
+ keyExtractor: item => item.bracket_id.toString(),
1346
+ renderItem: renderBrackets
1347
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null));
1348
+ };
1349
+ export const GroupSelector = ({
1009
1350
  active_group,
1010
1351
  groups,
1011
1352
  onSelectGroup
@@ -1052,9 +1393,6 @@ const GroupSelector = ({
1052
1393
  }, data.item.description)));
1053
1394
  };
1054
1395
  return /*#__PURE__*/React.createElement(Button, {
1055
- style: {
1056
- margin: 20
1057
- },
1058
1396
  float: true,
1059
1397
  onPress: () => {
1060
1398
  setVisible(!visible);
@@ -1088,7 +1426,7 @@ const GroupSelector = ({
1088
1426
  renderItem: renderGroups
1089
1427
  })) : /*#__PURE__*/React.createElement(React.Fragment, null));
1090
1428
  };
1091
- const CompanySelector = ({
1429
+ export const CompanySelector = ({
1092
1430
  active_company,
1093
1431
  companies,
1094
1432
  onSelectCompany
@@ -1135,9 +1473,6 @@ const CompanySelector = ({
1135
1473
  }, data.item.company_description)));
1136
1474
  };
1137
1475
  return /*#__PURE__*/React.createElement(Button, {
1138
- style: {
1139
- margin: 20
1140
- },
1141
1476
  float: true,
1142
1477
  onPress: () => {
1143
1478
  setVisible(!visible);