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
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { BracketCompetitionProps, CompetitionProps, FocusPositionProps, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
2
+ import type { BracketCompetitionProps, CompanyProps, CompetitionProps, FocusPositionProps, GroupProps, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
3
3
  import { type ViewStyle } from 'react-native';
4
4
  type CreateEngagementProps = {
5
5
  player?: PublicPlayerProps;
@@ -11,12 +11,25 @@ type CreateEngagementProps = {
11
11
  header_style?: ViewStyle;
12
12
  flash_campaign_id?: string;
13
13
  footer_style?: ViewStyle;
14
+ bracket_id?: string;
14
15
  float?: boolean;
15
16
  onClose: () => void;
16
17
  init_engagement?: 'competition' | 'bracket' | 'squares' | 'flash';
17
18
  group_id?: string;
18
19
  company_id?: string;
19
20
  };
20
- declare const CreateEngagement: ({ float, player, flash_campaign_id, init_engagement, onFocusPostiion, group_id, company_id, header_style, footer_style, onClose, onCreateCompetition, onCreateBracketCompetition, onCreateSquaresCompetition, onCreateFlashMarket }: CreateEngagementProps) => React.JSX.Element;
21
+ declare const CreateEngagement: ({ float, player, bracket_id, flash_campaign_id, init_engagement, onFocusPostiion, group_id, company_id, header_style, footer_style, onClose, onCreateCompetition, onCreateBracketCompetition, onCreateSquaresCompetition, onCreateFlashMarket }: CreateEngagementProps) => React.JSX.Element;
21
22
  export default CreateEngagement;
23
+ type GroupSelectorProps = {
24
+ active_group?: GroupProps;
25
+ groups: GroupProps[];
26
+ onSelectGroup: (group?: GroupProps) => void;
27
+ };
28
+ export declare const GroupSelector: ({ active_group, groups, onSelectGroup }: GroupSelectorProps) => React.JSX.Element;
29
+ type CompanySelectorProps = {
30
+ active_company?: CompanyProps;
31
+ companies: CompanyProps[];
32
+ onSelectCompany: (c?: CompanyProps) => void;
33
+ };
34
+ export declare const CompanySelector: ({ active_company, companies, onSelectCompany }: CompanySelectorProps) => React.JSX.Element;
22
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/CreateEngagement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,uBAAuB,EAA4C,gBAAgB,EAA2F,kBAAkB,EAA8C,SAAS,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACpU,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAQ/D,KAAK,qBAAqB,GAAG;IACzB,MAAM,CAAC,EAAC,iBAAiB,CAAC;IAC1B,eAAe,CAAC,EAAC,CAAC,GAAG,EAAC,kBAAkB,KAAK,IAAI,CAAC;IAClD,mBAAmB,EAAC,CAAC,WAAW,EAAC,gBAAgB,KAAK,IAAI,CAAC;IAC3D,0BAA0B,EAAC,CAAC,EAAE,EAAC,uBAAuB,KAAK,IAAI,CAAC;IAChE,0BAA0B,EAAC,CAAC,EAAE,EAAC,uBAAuB,KAAK,IAAI,CAAC;IAChE,mBAAmB,EAAC,CAAC,EAAE,EAAC,SAAS,KAAK,IAAI,CAAC;IAC3C,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,iBAAiB,CAAC,EAAC,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,KAAK,CAAC,EAAC,OAAO,CAAC;IACf,OAAO,EAAC,MAAM,IAAI,CAAC;IACnB,eAAe,CAAC,EAAC,aAAa,GAAC,SAAS,GAAC,SAAS,GAAC,OAAO,CAAA;IAC1D,QAAQ,CAAC,EAAC,MAAM,CAAC;IACjB,UAAU,CAAC,EAAC,MAAM,CAAA;CACrB,CAAA;AAcD,QAAA,MAAM,gBAAgB,GAAI,qOAAmO,qBAAqB,sBAmWjR,CAAA;AAED,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/CreateEngagement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,uBAAuB,EAAoD,YAAY,EAA8B,gBAAgB,EAA2F,kBAAkB,EAAE,UAAU,EAAkC,SAAS,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AACtX,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAS/D,KAAK,qBAAqB,GAAG;IACzB,MAAM,CAAC,EAAC,iBAAiB,CAAC;IAC1B,eAAe,CAAC,EAAC,CAAC,GAAG,EAAC,kBAAkB,KAAK,IAAI,CAAC;IAClD,mBAAmB,EAAC,CAAC,WAAW,EAAC,gBAAgB,KAAK,IAAI,CAAC;IAC3D,0BAA0B,EAAC,CAAC,EAAE,EAAC,uBAAuB,KAAK,IAAI,CAAC;IAChE,0BAA0B,EAAC,CAAC,EAAE,EAAC,uBAAuB,KAAK,IAAI,CAAC;IAChE,mBAAmB,EAAC,CAAC,EAAE,EAAC,SAAS,KAAK,IAAI,CAAC;IAC3C,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,iBAAiB,CAAC,EAAC,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,KAAK,CAAC,EAAC,OAAO,CAAC;IACf,OAAO,EAAC,MAAM,IAAI,CAAC;IACnB,eAAe,CAAC,EAAC,aAAa,GAAC,SAAS,GAAC,SAAS,GAAC,OAAO,CAAA;IAC1D,QAAQ,CAAC,EAAC,MAAM,CAAC;IACjB,UAAU,CAAC,EAAC,MAAM,CAAA;CACrB,CAAA;AAcD,QAAA,MAAM,gBAAgB,GAAI,iPAA+O,qBAAqB,sBAqX7R,CAAA;AAED,eAAe,gBAAgB,CAAA;AAqa/B,KAAK,kBAAkB,GAAG;IACtB,YAAY,CAAC,EAAC,UAAU,CAAC;IACzB,MAAM,EAAC,UAAU,EAAE,CAAC;IACpB,aAAa,EAAC,CAAC,KAAK,CAAC,EAAC,UAAU,KAAK,IAAI,CAAA;CAC5C,CAAA;AACD,eAAO,MAAM,aAAa,GAAI,yCAAwC,kBAAkB,sBA0CvF,CAAA;AAMD,KAAK,oBAAoB,GAAG;IACxB,cAAc,CAAC,EAAC,YAAY,CAAC;IAC7B,SAAS,EAAC,YAAY,EAAE,CAAC;IACzB,eAAe,EAAC,CAAC,CAAC,CAAC,EAAC,YAAY,KAAK,IAAI,CAAA;CAC5C,CAAA;AACD,eAAO,MAAM,eAAe,GAAI,gDAA+C,oBAAoB,sBA0ClG,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ManageFlashMarket.d.ts","sourceRoot":"","sources":["../../../../../src/FlashMarket/components/ManageFlashMarket.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAsF,MAAM,aAAa,CAAC;AAWzJ,KAAK,sBAAsB,GAAG;IAC1B,OAAO,EAAC,MAAM,CAAC;IACf,MAAM,CAAC,EAAC,aAAa,CAAC;IACtB,KAAK,CAAC,EAAC,OAAO,CAAC;IACf,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,OAAO,EAAC,MAAM,IAAI,CAAC;IACnB,eAAe,CAAC,EAAC,CAAC,GAAG,EAAC,kBAAkB,KAAK,IAAI,CAAA;CACpD,CAAA;AAGD,QAAA,MAAM,iBAAiB,GAAI,oEAAmE,sBAAsB,sBAquBnH,CAAA;AAED,eAAe,iBAAiB,CAAA"}
1
+ {"version":3,"file":"ManageFlashMarket.d.ts","sourceRoot":"","sources":["../../../../../src/FlashMarket/components/ManageFlashMarket.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAsF,MAAM,aAAa,CAAC;AAWzJ,KAAK,sBAAsB,GAAG;IAC1B,OAAO,EAAC,MAAM,CAAC;IACf,MAAM,CAAC,EAAC,aAAa,CAAC;IACtB,KAAK,CAAC,EAAC,OAAO,CAAC;IACf,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,YAAY,CAAC,EAAC,SAAS,CAAC;IACxB,OAAO,EAAC,MAAM,IAAI,CAAC;IACnB,eAAe,CAAC,EAAC,CAAC,GAAG,EAAC,kBAAkB,KAAK,IAAI,CAAA;CACpD,CAAA;AAGD,QAAA,MAAM,iBAAiB,GAAI,oEAAmE,sBAAsB,sBAqyBnH,CAAA;AAED,eAAe,iBAAiB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "be-components",
3
- "version": "7.3.0",
3
+ "version": "7.3.2",
4
4
  "description": "Components for BettorEdge Apps",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -3,11 +3,13 @@ import { Button, Text, TextInput, View } from "../../Components/Themed"
3
3
  import { FlatList, Image, Platform } from 'react-native';
4
4
  import { Icons, Switch, Toggle } from '../../Components';
5
5
  import { BracketApi, BracketComeptitionApi, BracketCompetitionHelpers } from '../api';
6
- import type { BracketCompetitionProps, BracketCompetitionScoringRuleProps, BracketProps, BracketRoundProps, CompetitionPlayerBracketProps, CompetitionResultTypeProps, LeagueProps } from '../../types';
6
+ import type { BracketCompetitionProps, BracketCompetitionScoringRuleProps, CompanyProps, BracketProps, BracketRoundProps, CompetitionPlayerBracketProps, CompetitionResultTypeProps, LeagueProps, GroupProps } from '../../types';
7
7
  import { useColors } from '../../constants/useColors';
8
8
  import moment from 'moment-mini';
9
9
  import SearchBox from '../../Components/SearchBox';
10
10
  import ImageUploader from '../../Components/ImageUploader';
11
+ import { CompanySelector, GroupSelector } from '../../CreateEngagement';
12
+ import { CreateEngagementApi } from '../../CreateEngagement/api';
11
13
 
12
14
  const sections = ['header', 'share', 'toggle', 'select_bracket', 'info', 'scoring', 'settings'];
13
15
 
@@ -51,6 +53,8 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
51
53
  active_league?:LeagueProps,
52
54
  selected_bracket_rounds:BracketRoundProps[],
53
55
  leagues:LeagueProps[],
56
+ companies:CompanyProps[],
57
+ groups:GroupProps[],
54
58
  available_brackets:BracketProps[],
55
59
  draft_competition?:BracketCompetitionProps,
56
60
  }>({
@@ -58,9 +62,11 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
58
62
  available_brackets: [],
59
63
  competition_player_brackets:[],
60
64
  competition_result_types:[],
65
+ companies:[],
66
+ groups:[],
61
67
  selected_bracket_rounds:[]
62
68
  });
63
- const { competition_result_types, bracket_competition, available_brackets, competition_player_brackets, active_league, selected_bracket_rounds, leagues, selected_bracket, draft_competition} = form_data;
69
+ const { competition_result_types, companies, groups, bracket_competition, available_brackets, competition_player_brackets, active_league, selected_bracket_rounds, leagues, selected_bracket, draft_competition} = form_data;
64
70
  const unique_league_ids = [ ...new Set(available_brackets.map(b => b.league_id)) ]
65
71
 
66
72
  let filtered_brackets = [...available_brackets]
@@ -74,9 +80,12 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
74
80
  const { info_valid, settings_valid, bracket_valid, scoring_valid } = BracketCompetitionHelpers.isBracketValid(bracket_scoring_rules, selected_bracket_rounds, competition_result_types, bracket_competition )
75
81
  const valid = info_valid && settings_valid && bracket_valid && scoring_valid ? true : false
76
82
  const can_delete = moment().isBefore(moment(bracket_competition?.scheduled_datetime)) && competition_player_brackets.length == 0 ? true : false
83
+ const active_company = companies.find(c => c.company_id == bracket_competition?.company_id);
84
+ const active_group = groups.find(g => g.group_id == bracket_competition?.group_id);
77
85
 
78
86
  useEffect(() => {
79
87
  BracketApi.setEnvironment();
88
+ CreateEngagementApi.setEnvironment();
80
89
  if(!bracket_competition_id){ return }
81
90
  getData(bracket_competition_id);
82
91
  },[bracket_competition_id])
@@ -98,6 +107,8 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
98
107
  bk_rounds = bracket_resp.bracket_rounds
99
108
  }
100
109
 
110
+ const s_companies = await CreateEngagementApi.getMyCompanies();
111
+ const s_groups = await CreateEngagementApi.getMyGroups(0);
101
112
  //Lets Check if we need to adjust scoring rules right away!
102
113
  let draft_rules = BracketCompetitionHelpers.checkRules(id, bk_rounds, bk_resp.bracket_competition_scoring_rules);
103
114
  if(JSON.stringify(draft_rules) != JSON.stringify(bk_resp.bracket_competition_scoring_rules)){
@@ -114,6 +125,8 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
114
125
  draft_competition: bk_resp.bracket_competition,
115
126
  competition_result_types: options.competition_result_types.filter(crt => crt.type != 'outpace'),
116
127
  leagues: lgs,
128
+ groups: s_groups.groups,
129
+ companies: s_companies.companies,
117
130
  competition_player_brackets: bk_resp.competition_player_brackets,
118
131
  available_brackets: bk_options.filter(bk => moment(bk.scheduled_datetime).isAfter(moment())),
119
132
  selected_bracket_rounds: bk_rounds,
@@ -544,6 +557,46 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
544
557
  })}
545
558
  />
546
559
  </View>
560
+ {groups.length > 0 ?
561
+ <View style={{ padding:10 }}>
562
+ <Text theme='h2' style={{ marginBottom:8 }}>Group</Text>
563
+ <GroupSelector
564
+ groups={groups}
565
+ active_group={active_group}
566
+ onSelectGroup={async(g) => {
567
+ if(info_loading){ return }
568
+ setInfoLoading(true);
569
+ const new_bc = await BracketComeptitionApi.updateBracketCompetition({ ...draft_competition, group_id: g?.group_id });
570
+ setFormData({
571
+ ...form_data,
572
+ bracket_competition: new_bc,
573
+ draft_competition: new_bc
574
+ })
575
+ setInfoLoading(false);
576
+ }}
577
+ />
578
+ </View>
579
+ :<></>}
580
+ {companies.length > 0 ?
581
+ <View style={{ padding:10 }}>
582
+ <Text theme='h2' style={{ marginBottom:8 }}>Company</Text>
583
+ <CompanySelector
584
+ companies={companies}
585
+ active_company={active_company}
586
+ onSelectCompany={async(c) => {
587
+ if(info_loading){ return }
588
+ setInfoLoading(true);
589
+ const new_bc = await BracketComeptitionApi.updateBracketCompetition({ ...draft_competition, company_id: c?.company_id });
590
+ setFormData({
591
+ ...form_data,
592
+ bracket_competition: new_bc,
593
+ draft_competition: new_bc
594
+ })
595
+ setInfoLoading(false);
596
+ }}
597
+ />
598
+ </View>
599
+ :<></>}
547
600
  <View type='row' style={{ padding:10 }}>
548
601
  <View transparent style={{ flex:1 }}>
549
602
  <Text theme='h2'>Start Time</Text>
@@ -1,5 +1,5 @@
1
1
  import axios from "axios";
2
- import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, GroupPlayerProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, SquaresCompetitionProps } from "../../types";
2
+ import type { BracketCompetitionProps, BracketCompetitionScoringRuleProps, BracketGroupProps, BracketProps, BracketRoundProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, GroupPlayerProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, RoundEventProps, SquaresCompetitionProps } from "../../types";
3
3
  import { APIOverrides } from "../../ApiOverrides";
4
4
  import type { CompanyMemberProps } from "../../Authenticator/api/types";
5
5
  import moment from "moment-mini";
@@ -28,6 +28,22 @@ const CreateEngagementApi = {
28
28
  return []
29
29
  }
30
30
  },
31
+ getActiveBrackets: async():Promise<BracketProps[]> => {
32
+ try {
33
+ const resp = await axios.get(`${EVENT_SVC_API}/v1/brackets/active`);
34
+ return resp.data.brackets
35
+ } catch (e) {
36
+ return []
37
+ }
38
+ },
39
+ getBracketById: async(bracket_id:string):Promise<undefined | {bracket:BracketProps, bracket_rounds:BracketRoundProps[], round_events:RoundEventProps[], bracket_groups:BracketGroupProps[]}> => {
40
+ try {
41
+ const resp = await axios.get(`${EVENT_SVC_API}/v1/brackets/bracket/${bracket_id}`);
42
+ return resp.data
43
+ } catch (e) {
44
+ return undefined
45
+ }
46
+ },
31
47
  getMyCompanies : async():Promise<{companies:CompanyProps[], company_members:CompanyMemberProps[]}> => {
32
48
  const resp = await axios.get(`${AUTH_SVC_API}/v1/companies/me`)
33
49
  const { companies, company_members } = resp.data
@@ -74,6 +90,7 @@ const CreateEngagementApi = {
74
90
  return undefined
75
91
  }
76
92
  },
93
+
77
94
  activateSquares: async(sq_comp_id:string) => {
78
95
  try {
79
96
  const resp = await axios.post(`${TP_SVC_API}/v1/squares/competition/activate`, { sq_comp_id });
@@ -89,6 +106,14 @@ const CreateEngagementApi = {
89
106
  } catch (e) {
90
107
  return undefined
91
108
  }
109
+ },
110
+ createBracketCompetition: async(bracket_competition:BracketCompetitionProps, bracket_competition_scoring_rules:BracketCompetitionScoringRuleProps[]):Promise<undefined|{bracket_competition:BracketCompetitionProps, bracket_competition_scoring_rules:BracketCompetitionScoringRuleProps[]}> => {
111
+ try {
112
+ const resp = await axios.post(`${TP_SVC_API}/v1/brackets/competition/create`, { bracket_competition, bracket_competition_scoring_rules });
113
+ return resp.data
114
+ } catch (e) {
115
+ return undefined
116
+ }
92
117
  },
93
118
  createPollCampaign: async(poll_campaign:PollCampaignProps):Promise<PollCampaignProps | undefined> => {
94
119
  try {
@@ -119,7 +144,7 @@ const CreateEngagementApi = {
119
144
 
120
145
 
121
146
  const CreateEngagementHelpers = {
122
- isStepValid: (step:CreateEngagementStepProps, active_engagement?:string, draft_competition?:any, draft_squares?:SquaresCompetitionProps, draft_flash?:PollProps):string[] => {
147
+ isStepValid: (step:CreateEngagementStepProps, active_engagement?:string, draft_competition?:any, draft_squares?:SquaresCompetitionProps, draft_flash?:PollProps, draft_bracket?:BracketCompetitionProps):string[] => {
123
148
  let errors:string[] = []
124
149
  switch(step.step_key){
125
150
  case 'intro': return errors
@@ -146,6 +171,15 @@ const CreateEngagementHelpers = {
146
171
  if(!draft_flash?.poll_question){ errors.push('Please add a poll question') }
147
172
  if(!draft_flash?.poll_campaign_id){ errors.push('Please add to a compaign') }
148
173
  break
174
+ case 'bracket':
175
+ if(!draft_bracket){ return ['Please complete the required steps'] }
176
+ if(!draft_bracket.scheduled_datetime){ errors.push('Please select a valid bracket') }
177
+ if(!draft_bracket.bracket_id){ errors.push('Please select a valid bracket') }
178
+ if(!draft_bracket.competition_name){ errors.push('Please enter a valid competition name') }
179
+ if(!draft_bracket.competition_description){ errors.push('Please enter a valid competition description') }
180
+ if(!draft_bracket.competition_result_type_id){ errors.push('Please add a valid payout type') }
181
+ if(moment().isAfter(moment(draft_bracket.scheduled_datetime))){ errors.push('The bracket selected has already started') }
182
+ break
149
183
  default: break
150
184
  }
151
185
  break
@@ -210,5 +244,29 @@ const CreateEngagementHelpers = {
210
244
  multi_responses_allowed: true,
211
245
  create_datetime: '', last_update_datetime:''
212
246
  }
247
+ },
248
+ generateBracketCompetition:():BracketCompetitionProps => {
249
+ return {
250
+ bracket_competition_id:'',
251
+ bracket_id: '',
252
+ max_brackets: 100,
253
+ max_brackets_per_player:1,
254
+ guaranteed_payout:0,
255
+ competition_code:'',
256
+ competition_name:'',
257
+ scoring_system:'progressive',
258
+ scheduled_datetime:'',
259
+ status:'pending',
260
+ buy_in: 0,
261
+ ticket_revenue:0,
262
+ tickets_sold:0,
263
+ competition_result_type_id: '',
264
+ admin_id:'',
265
+ market_type: 'FOR_MONEY',
266
+ invite_only: true,
267
+ create_datetime: '', last_update_datetime:'',
268
+ image: { url : '' },
269
+ competition_description: ''
270
+ }
213
271
  }
214
272
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { Button, Text, TextInput, View } from "../Components/Themed"
3
- import type { BracketCompetitionProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, EventProps, FocusPositionProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
3
+ import type { BracketCompetitionProps, BracketCompetitionScoringRuleProps, BracketProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, EventProps, FocusPositionProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
4
4
  import { FlatList, Image, type ViewStyle } from 'react-native';
5
5
  import { CreateEngagementApi, CreateEngagementHelpers } from './api';
6
6
  import { Icons } from '../Components';
@@ -8,6 +8,7 @@ import { useColors } from '../constants/useColors';
8
8
  import ImageUploader from '../Components/ImageUploader';
9
9
  import moment from 'moment-mini';
10
10
  import LeagueSchedule from '../MarketComponents/components/LeagueSchedule';
11
+ import { BracketCompetitionHelpers } from '../Bracket/api';
11
12
 
12
13
  type CreateEngagementProps = {
13
14
  player?:PublicPlayerProps,
@@ -19,6 +20,7 @@ type CreateEngagementProps = {
19
20
  header_style?:ViewStyle,
20
21
  flash_campaign_id?:string,
21
22
  footer_style?:ViewStyle,
23
+ bracket_id?:string,
22
24
  float?:boolean,
23
25
  onClose:() => void,
24
26
  init_engagement?:'competition'|'bracket'|'squares'|'flash'
@@ -38,10 +40,11 @@ const steps:CreateEngagementStepProps[] = [
38
40
  { step_key: 'success', num:7, title: 'Engagement Successfully Created!', description: 'Your engagement is in pending status. You can activate it when ready from your dashboard or the engagement screen!' }
39
41
  ]
40
42
 
41
- const CreateEngagement = ({ float, player, flash_campaign_id, init_engagement, onFocusPostiion, group_id, company_id, header_style, footer_style, onClose, onCreateCompetition, onCreateBracketCompetition, onCreateSquaresCompetition, onCreateFlashMarket}:CreateEngagementProps) => {
43
+ const CreateEngagement = ({ float, player, bracket_id, flash_campaign_id, init_engagement, onFocusPostiion, group_id, company_id, header_style, footer_style, onClose, onCreateCompetition, onCreateBracketCompetition, onCreateSquaresCompetition, onCreateFlashMarket}:CreateEngagementProps) => {
42
44
  const Colors = useColors();
43
45
  const [ size, setSize ] = useState({ width:0, height:0 });
44
46
  const [ draft_squares, setDraftSquares ] = useState<SquaresCompetitionProps | undefined>(undefined);
47
+ const [ draft_bracket_competition, setDraftBracketCompetition ] = useState<BracketCompetitionProps | undefined>(undefined);
45
48
  const [ pending_engagement, setPendingEngagement ] = useState<{
46
49
  create_loading:boolean,
47
50
  competition?:CompetitionProps,
@@ -105,7 +108,7 @@ const CreateEngagement = ({ float, player, flash_campaign_id, init_engagement, o
105
108
  loading:false
106
109
  })
107
110
  }
108
- const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash);
111
+ const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash, draft_bracket_competition);
109
112
 
110
113
  const handleNextStep = async() => {
111
114
  if(errors.length > 0){ return alert(errors.map(e => e)) }
@@ -174,6 +177,17 @@ const CreateEngagement = ({ float, player, flash_campaign_id, init_engagement, o
174
177
  if(!new_flash_market){ return alert('Unable to process') }
175
178
  setPendingEngagement({ ...pending_engagement, create_loading: false, poll: new_flash_market });
176
179
  break
180
+ case 'bracket':
181
+ if(!draft_bracket_competition){ return alert('Unable to process') }
182
+ if(errors.length > 0){ return alert(errors.map(e => e)) }
183
+ setPendingEngagement({ ...pending_engagement, create_loading: true });
184
+ const bracket_resp = await CreateEngagementApi.getBracketById(draft_bracket_competition.bracket_id);
185
+ if(!bracket_resp){ return alert('Unable to process. Please try again later') }
186
+ const scoring = BracketCompetitionHelpers.getDefaultScoringRules('', bracket_resp.bracket_rounds);
187
+ const comp_response = await CreateEngagementApi.createBracketCompetition({ ...draft_bracket_competition, image: draft_image, company_id: active_company?.company_id, group_id: active_group?.group_id }, scoring);
188
+ if(!comp_response){ return alert('Unable to process') }
189
+ setPendingEngagement({ ...pending_engagement, create_loading: false, bracket_competition:comp_response.bracket_competition });
190
+ break
177
191
  default: return //We cdont have one!
178
192
  }
179
193
  if(next_step){ setActiveStep(next_step)}
@@ -297,20 +311,24 @@ const CreateEngagement = ({ float, player, flash_campaign_id, init_engagement, o
297
311
  case 'groups':
298
312
  if(active_step.step_key != 'group'){ return <></> }
299
313
  return (
314
+ <View transparent style={{ margin:20 }}>
300
315
  <GroupSelector
301
316
  groups={groups}
302
317
  active_group={active_group}
303
318
  onSelectGroup={(g) => setState({ ...state, active_group: g })}
304
319
  />
320
+ </View>
305
321
  )
306
322
  case 'companies':
307
323
  if(active_step.step_key != 'company'){ return <></> }
308
324
  return (
325
+ <View transparent style={{ margin:20 }}>
309
326
  <CompanySelector
310
327
  companies={companies}
311
328
  active_company={active_company}
312
329
  onSelectCompany={(c) => setState({ ...state, active_company: c })}
313
330
  />
331
+ </View>
314
332
  )
315
333
  case 'create':
316
334
  if(active_step.step_key != 'create'){ return <></> }
@@ -322,6 +340,8 @@ const CreateEngagement = ({ float, player, flash_campaign_id, init_engagement, o
322
340
  return <CreateSquares onUpdateDraft={(d) => setDraftSquares(d)} onFocusPosition={onFocusPostiion}/>
323
341
  case 'flash':
324
342
  return <CreateFlashMarket group={active_group} flash_campaign_id={flash_campaign_id} onUpdateDraft={(d) => setDraftFlash(d)} onFocusPosition={onFocusPostiion} company={active_company}/>
343
+ case 'bracket':
344
+ return <CreateBracketCompetition group={active_group} bracket_id={bracket_id} onUpdateDraft={(d) => setDraftBracketCompetition(d)} onFocusPosition={onFocusPostiion} company={active_company}/>
325
345
  default: return <></>
326
346
  }
327
347
  default: return <></>
@@ -407,6 +427,130 @@ const IntroInfo = () => {
407
427
  </View>
408
428
  )
409
429
  }
430
+ type CreateBracketCompetitionProps = {
431
+ company?:CompanyProps,
432
+ group?:GroupProps,
433
+ onFocusPosition?:(pos:FocusPositionProps) => void,
434
+ onUpdateDraft: (poll:BracketCompetitionProps) => void,
435
+ bracket_id?:string
436
+ }
437
+ const CreateBracketCompetition = ({ bracket_id, company, group, onFocusPosition, onUpdateDraft }:CreateBracketCompetitionProps) => {
438
+ const Colors = useColors();
439
+ const [ create_state, setCreateState ] = useState<{
440
+ brackets:BracketProps[],
441
+ leagues:LeagueProps[],
442
+ loading:boolean,
443
+ results_visible:boolean,
444
+ competition_result_types:CompetitionResultTypeProps[],
445
+ draft_bracket_competition:BracketCompetitionProps,
446
+ scoring:BracketCompetitionScoringRuleProps[]
447
+ }>({
448
+ brackets:[],
449
+ leagues: [],
450
+ results_visible: false,
451
+ competition_result_types:[],
452
+ scoring:[],
453
+ loading: false,
454
+ draft_bracket_competition: { ...CreateEngagementHelpers.generateBracketCompetition(), bracket_id:bracket_id??'', group_id:group?.group_id, company_id:company?.company_id }
455
+ });
456
+ const { brackets, leagues, results_visible, draft_bracket_competition, competition_result_types } = create_state;
457
+ const active_bracket = brackets.find(b => b.bracket_id == draft_bracket_competition.bracket_id);
458
+ const competition_result_type = competition_result_types.find(rt => rt.competition_result_type_id == draft_bracket_competition.competition_result_type_id);
459
+
460
+ useEffect(() => {
461
+ getData()
462
+ },[]);
463
+
464
+ useEffect(() => {
465
+ onUpdateDraft(draft_bracket_competition);
466
+ },[JSON.stringify(draft_bracket_competition)]);
467
+
468
+
469
+ const getData = async() => {
470
+ setCreateState({ ...create_state, loading: true });
471
+ const s_leagues = await CreateEngagementApi.getLeagues();
472
+ const s_brackets = await CreateEngagementApi.getActiveBrackets();
473
+ let options = await CreateEngagementApi.getCompetitionOptions();
474
+ setCreateState({
475
+ ...create_state,
476
+ brackets: s_brackets,
477
+ competition_result_types: options.competition_result_types,
478
+ leagues: s_leagues,
479
+ loading:false
480
+ })
481
+ }
482
+
483
+ const renderResultTypes = (data:{item:CompetitionResultTypeProps, index:number}) => {
484
+ return (
485
+ <Button
486
+ transparent
487
+ style={{ flexDirection:'row', borderRadius:0, padding:10, alignItems:'center', borderBottomWidth:1, borderColor:Colors.borders.light }}
488
+ onPress={() => setCreateState({ ...create_state, results_visible: false, draft_bracket_competition: { ...draft_bracket_competition, competition_result_type_id: data.item.competition_result_type_id } })}
489
+ >
490
+ <View transparent style={{ flex:1 }}>
491
+ <Text theme='h1'>{data.item.label}</Text>
492
+ <Text theme='description' style={{ marginTop:3 }}>{data.item.description}</Text>
493
+ </View>
494
+ </Button>
495
+ )
496
+ }
497
+
498
+ return (
499
+ <View>
500
+ <View style={{ padding:10 }}>
501
+ <Text theme='h1' style={{ marginBottom:10 }}>Competition Name</Text>
502
+ <TextInput
503
+ placeholder='Add Name here...'
504
+ value={draft_bracket_competition.competition_name}
505
+ onFocusPosition={onFocusPosition}
506
+ style={{ borderColor:draft_bracket_competition.competition_name ? Colors.text.success : Colors.text.warning }}
507
+ onChangeText={(text) => setCreateState({ ...create_state, draft_bracket_competition: { ...draft_bracket_competition, competition_name: text } })}
508
+ />
509
+ </View>
510
+ <View style={{ padding:10 }}>
511
+ <Text theme='h1' style={{ marginBottom:10 }}>Competition Description</Text>
512
+ <TextInput
513
+ placeholder='Add Description here...'
514
+ value={draft_bracket_competition.competition_description}
515
+ onFocusPosition={onFocusPosition}
516
+ style={{ borderColor:draft_bracket_competition.competition_description ? Colors.text.success : Colors.text.warning }}
517
+ onChangeText={(text) => setCreateState({ ...create_state, draft_bracket_competition: { ...draft_bracket_competition, competition_description: text } })}
518
+ />
519
+ </View>
520
+ <View style={{ padding:10 }}>
521
+ <Text theme='h1' style={{ marginBottom:10 }}>Select a Bracket</Text>
522
+ <BracketSelector
523
+ leagues={leagues}
524
+ brackets={brackets.filter(b => moment().isBefore(moment(b.scheduled_datetime)))}
525
+ active_bracket={active_bracket}
526
+ onSelectBracket={(bracket) => {
527
+ setCreateState({ ...create_state, draft_bracket_competition: { ...draft_bracket_competition, bracket_id: bracket?.bracket_id ?? '', scheduled_datetime: bracket?.scheduled_datetime } })
528
+ }}
529
+ />
530
+ </View>
531
+ <View style={{ padding:10 }}>
532
+ <Text theme='h1' style={{ marginBottom:10 }}>Payout Type</Text>
533
+ <Button float style={{ borderColor:competition_result_type ? Colors.text.success: Colors.text.warning }} onPress={() => setCreateState({ ...create_state, results_visible: !results_visible })}>
534
+ <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
535
+ <Text style={{ flex:1, marginRight:10 }} theme='h1'>{competition_result_type?.label ?? 'Select Payout'}</Text>
536
+ <Icons.ChevronIcon direction={results_visible?'up':'down'} color={Colors.text.h1} size={8} />
537
+ </View>
538
+ {results_visible ?
539
+ <View transparent style={{ marginTop:20 }}>
540
+ <FlatList
541
+ data={competition_result_types.sort((a,b) => a.label.localeCompare(b.label))}
542
+ key={'competition_reult_types'}
543
+ keyExtractor={item => item.competition_result_type_id.toString()}
544
+ renderItem={renderResultTypes}
545
+ />
546
+ </View>
547
+ :<></>}
548
+ </Button>
549
+ </View>
550
+ </View>
551
+ )
552
+
553
+ }
410
554
 
411
555
  type CreateFlashMarketProps = {
412
556
  company?:CompanyProps,
@@ -606,7 +750,6 @@ const EngagementOptions = ({active_engagement, companies, onSelectEngagement}:En
606
750
  <Text theme='description' color={active_engagement == 'squares' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create an auction squares game. Bid on squares until the auction ends. Buy and sell squares throughout the game.</Text>
607
751
  </View>
608
752
  </Button>
609
- {false ?
610
753
  <Button
611
754
  key='bracket'
612
755
  float
@@ -619,7 +762,6 @@ const EngagementOptions = ({active_engagement, companies, onSelectEngagement}:En
619
762
  <Text theme='description' color={active_engagement == 'bracket' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create a bracket. Make picks until the championship. Pick more correctly and win!</Text>
620
763
  </View>
621
764
  </Button>
622
- :<></>}
623
765
  {companies.length > 0 ?
624
766
  <Button
625
767
  key='flash'
@@ -638,12 +780,68 @@ const EngagementOptions = ({active_engagement, companies, onSelectEngagement}:En
638
780
  )
639
781
  }
640
782
 
783
+
784
+
785
+ type BracketSelectorProps = {
786
+ active_bracket?:BracketProps,
787
+ brackets:BracketProps[],
788
+ leagues:LeagueProps[],
789
+ onSelectBracket:(bracket?:BracketProps) => void
790
+ }
791
+ const BracketSelector = ({ active_bracket, brackets, leagues, onSelectBracket }:BracketSelectorProps) => {
792
+ const Colors = useColors();
793
+ const [ visible, setVisible ] = useState(false);
794
+
795
+ const renderBrackets = (data:{ item:BracketProps, index:number }) => {
796
+ const league = leagues.find(l => l.league_id == data.item.league_id);
797
+ if(!league){ return <></> }
798
+ return (
799
+ <Button
800
+ transparent
801
+ style={{ flexDirection:'row', alignItems:'center', padding:10, borderRadius:0, borderBottomWidth:1, borderColor:Colors.borders.light }}
802
+ onPress={() => { setVisible(false); onSelectBracket(data.item) }}
803
+ >
804
+ <Image
805
+ source={{ uri: league.league_image }}
806
+ style={{ height:40, width:40 }}
807
+ resizeMode='cover'
808
+ />
809
+ <View transparent style={{ flex:1, marginLeft:10 }}>
810
+ <Text theme='h1'>{data.item.bracket_name}</Text>
811
+ <Text theme='description' style={{ marginTop:3 }}>Begins {moment(data.item.scheduled_datetime).format('MMM DD hh:mm a')}</Text>
812
+ </View>
813
+ </Button>
814
+ )
815
+ }
816
+
817
+ return (
818
+ <Button float style={{ borderColor:active_bracket ? Colors.text.success : Colors.text.warning }} onPress={() => { setVisible(!visible); onSelectBracket(undefined)}}>
819
+ <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
820
+ <Text style={{ flex:1, marginRight:10 }} theme='h1'>{active_bracket?.bracket_name ?? 'No Bracket'}</Text>
821
+ <Icons.ChevronIcon direction={visible?'up':'down'} color={Colors.text.h1} size={8} />
822
+ </View>
823
+ {visible ?
824
+ <View transparent style={{ marginTop:20 }}>
825
+ <FlatList
826
+ data={brackets.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
827
+ key={'bracket_selector'}
828
+ keyExtractor={item => item.bracket_id.toString()}
829
+ renderItem={renderBrackets}
830
+ />
831
+ </View>
832
+ :<></>}
833
+ </Button>
834
+ )
835
+ }
836
+
837
+
838
+
641
839
  type GroupSelectorProps = {
642
840
  active_group?:GroupProps,
643
841
  groups:GroupProps[],
644
842
  onSelectGroup:(group?:GroupProps) => void
645
843
  }
646
- const GroupSelector = ({ active_group, groups, onSelectGroup }:GroupSelectorProps) => {
844
+ export const GroupSelector = ({ active_group, groups, onSelectGroup }:GroupSelectorProps) => {
647
845
  const Colors = useColors();
648
846
  const [ visible, setVisible ] = useState(false);
649
847
 
@@ -668,7 +866,7 @@ const GroupSelector = ({ active_group, groups, onSelectGroup }:GroupSelectorProp
668
866
  }
669
867
 
670
868
  return (
671
- <Button style={{ margin:20 }} float onPress={() => { setVisible(!visible); onSelectGroup(undefined)}}>
869
+ <Button float onPress={() => { setVisible(!visible); onSelectGroup(undefined)}}>
672
870
  <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
673
871
  <Text style={{ flex:1, marginRight:10 }} theme='h1'>{active_group?.name ?? 'No Group'}</Text>
674
872
  <Icons.ChevronIcon direction={visible?'up':'down'} color={Colors.text.h1} size={8} />
@@ -696,7 +894,7 @@ type CompanySelectorProps = {
696
894
  companies:CompanyProps[],
697
895
  onSelectCompany:(c?:CompanyProps) => void
698
896
  }
699
- const CompanySelector = ({ active_company, companies, onSelectCompany }:CompanySelectorProps) => {
897
+ export const CompanySelector = ({ active_company, companies, onSelectCompany }:CompanySelectorProps) => {
700
898
  const Colors = useColors();
701
899
  const [ visible, setVisible ] = useState(false);
702
900
 
@@ -721,7 +919,7 @@ const CompanySelector = ({ active_company, companies, onSelectCompany }:CompanyS
721
919
  }
722
920
 
723
921
  return (
724
- <Button style={{ margin:20 }} float onPress={() => { setVisible(!visible); onSelectCompany(undefined) }}>
922
+ <Button float onPress={() => { setVisible(!visible); onSelectCompany(undefined) }}>
725
923
  <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
726
924
  <Text style={{ flex:1, marginRight:10 }} theme='h1'>{active_company?.company_name ?? 'No Company'}</Text>
727
925
  <Icons.ChevronIcon direction={visible?'up':'down'} color={Colors.text.h1} size={8} />