be-components 7.0.5 → 7.0.8
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/lib/commonjs/Components/BETimePicker.js +110 -0
- package/lib/commonjs/Components/BETimePicker.js.map +1 -0
- package/lib/commonjs/Components/Icons.js +37 -0
- package/lib/commonjs/Components/Icons.js.map +1 -1
- package/lib/commonjs/Components/ImageUploader.js +4 -0
- package/lib/commonjs/Components/ImageUploader.js.map +1 -1
- package/lib/commonjs/Components/Slider.js +2 -0
- package/lib/commonjs/Components/Slider.js.map +1 -1
- package/lib/commonjs/Components/Themed.js +4 -2
- package/lib/commonjs/Components/Themed.js.map +1 -1
- package/lib/commonjs/CreateEngagement/api/index.js +89 -1
- package/lib/commonjs/CreateEngagement/api/index.js.map +1 -1
- package/lib/commonjs/CreateEngagement/index.js +306 -5
- package/lib/commonjs/CreateEngagement/index.js.map +1 -1
- package/lib/commonjs/Discord/api/index.js +61 -0
- package/lib/commonjs/Discord/api/index.js.map +1 -0
- package/lib/commonjs/Discord/index.js +516 -0
- package/lib/commonjs/Discord/index.js.map +1 -0
- package/lib/commonjs/FlashMarket/FlashHolder.js +14 -1
- package/lib/commonjs/FlashMarket/FlashHolder.js.map +1 -1
- package/lib/commonjs/FlashMarket/api/index.js +42 -0
- package/lib/commonjs/FlashMarket/api/index.js.map +1 -1
- package/lib/commonjs/FlashMarket/components/FlashOptionCard.js +265 -0
- package/lib/commonjs/FlashMarket/components/FlashOptionCard.js.map +1 -0
- package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js +1222 -0
- package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js.map +1 -0
- package/lib/commonjs/FlashMarket/index.js +18 -6
- package/lib/commonjs/FlashMarket/index.js.map +1 -1
- package/lib/commonjs/Group/api/index.js +6 -3
- package/lib/commonjs/Group/api/index.js.map +1 -1
- package/lib/commonjs/Group/index.js +135 -20
- package/lib/commonjs/Group/index.js.map +1 -1
- package/lib/commonjs/Poll/api/index.js +0 -1
- package/lib/commonjs/Poll/api/index.js.map +1 -1
- package/lib/commonjs/Squares/index.js +0 -3
- package/lib/commonjs/Squares/index.js.map +1 -1
- package/lib/commonjs/SquaresManager/index.js +1 -1
- package/lib/commonjs/SquaresManager/index.js.map +1 -1
- package/lib/commonjs/constants/useColors.js +2 -0
- package/lib/commonjs/constants/useColors.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types.d.js +2 -0
- package/lib/commonjs/types.d.js.map +1 -1
- package/lib/module/Components/BETimePicker.js +102 -0
- package/lib/module/Components/BETimePicker.js.map +1 -0
- package/lib/module/Components/Icons.js +37 -0
- package/lib/module/Components/Icons.js.map +1 -1
- package/lib/module/Components/ImageUploader.js +4 -0
- package/lib/module/Components/ImageUploader.js.map +1 -1
- package/lib/module/Components/Slider.js +2 -0
- package/lib/module/Components/Slider.js.map +1 -1
- package/lib/module/Components/Themed.js +4 -2
- package/lib/module/Components/Themed.js.map +1 -1
- package/lib/module/CreateEngagement/api/index.js +89 -1
- package/lib/module/CreateEngagement/api/index.js.map +1 -1
- package/lib/module/CreateEngagement/index.js +306 -5
- package/lib/module/CreateEngagement/index.js.map +1 -1
- package/lib/module/Discord/api/index.js +54 -0
- package/lib/module/Discord/api/index.js.map +1 -0
- package/lib/module/Discord/index.js +509 -0
- package/lib/module/Discord/index.js.map +1 -0
- package/lib/module/FlashMarket/FlashHolder.js +14 -1
- package/lib/module/FlashMarket/FlashHolder.js.map +1 -1
- package/lib/module/FlashMarket/api/index.js +42 -0
- package/lib/module/FlashMarket/api/index.js.map +1 -1
- package/lib/module/FlashMarket/components/FlashOptionCard.js +258 -0
- package/lib/module/FlashMarket/components/FlashOptionCard.js.map +1 -0
- package/lib/module/FlashMarket/components/ManageFlashMarket.js +1214 -0
- package/lib/module/FlashMarket/components/ManageFlashMarket.js.map +1 -0
- package/lib/module/FlashMarket/index.js +18 -6
- package/lib/module/FlashMarket/index.js.map +1 -1
- package/lib/module/Group/api/index.js +6 -3
- package/lib/module/Group/api/index.js.map +1 -1
- package/lib/module/Group/index.js +135 -20
- package/lib/module/Group/index.js.map +1 -1
- package/lib/module/Poll/api/index.js +0 -1
- package/lib/module/Poll/api/index.js.map +1 -1
- package/lib/module/Squares/index.js +0 -3
- package/lib/module/Squares/index.js.map +1 -1
- package/lib/module/SquaresManager/index.js +1 -1
- package/lib/module/SquaresManager/index.js.map +1 -1
- package/lib/module/constants/useColors.js +2 -0
- package/lib/module/constants/useColors.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.d.js +2 -0
- package/lib/module/types.d.js.map +1 -1
- package/lib/typescript/lib/commonjs/Components/BETimePicker.d.ts +8 -0
- package/lib/typescript/lib/commonjs/Components/BETimePicker.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
- package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/Slider.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Components/Slider.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Components/Themed.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts +40 -1
- package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Discord/api/index.d.ts +9 -0
- package/lib/typescript/lib/commonjs/Discord/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/Discord/index.d.ts +11 -0
- package/lib/typescript/lib/commonjs/Discord/index.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts +3 -1
- package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/FlashMarket/components/FlashOptionCard.d.ts +13 -0
- package/lib/typescript/lib/commonjs/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts +9 -0
- package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts +2 -1
- package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Group/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Group/index.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Group/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Poll/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/constants/useColors.d.ts +1 -0
- package/lib/typescript/lib/commonjs/constants/useColors.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/BETimePicker.d.ts +8 -0
- package/lib/typescript/lib/module/Components/BETimePicker.d.ts.map +1 -0
- package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
- package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/ImageUploader.d.ts +2 -1
- package/lib/typescript/lib/module/Components/ImageUploader.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/Slider.d.ts +2 -1
- package/lib/typescript/lib/module/Components/Slider.d.ts.map +1 -1
- package/lib/typescript/lib/module/Components/Themed.d.ts.map +1 -1
- package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts +41 -1
- package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Discord/api/index.d.ts +8 -0
- package/lib/typescript/lib/module/Discord/api/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/Discord/index.d.ts +11 -0
- package/lib/typescript/lib/module/Discord/index.d.ts.map +1 -0
- package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts +3 -1
- package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts.map +1 -1
- package/lib/typescript/lib/module/FlashMarket/api/index.d.ts +2 -0
- package/lib/typescript/lib/module/FlashMarket/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/FlashMarket/components/FlashOptionCard.d.ts +13 -0
- package/lib/typescript/lib/module/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
- package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts +9 -0
- package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
- package/lib/typescript/lib/module/FlashMarket/index.d.ts +2 -1
- package/lib/typescript/lib/module/FlashMarket/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Group/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Group/index.d.ts +2 -1
- package/lib/typescript/lib/module/Group/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Poll/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/constants/useColors.d.ts +1 -0
- package/lib/typescript/lib/module/constants/useColors.d.ts.map +1 -1
- package/lib/typescript/lib/module/index.d.ts +3 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/Components/BETimePicker.d.ts +11 -0
- package/lib/typescript/src/Components/BETimePicker.d.ts.map +1 -0
- package/lib/typescript/src/Components/Icons.d.ts +1 -0
- package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/src/Components/ImageUploader.d.ts +2 -1
- package/lib/typescript/src/Components/ImageUploader.d.ts.map +1 -1
- package/lib/typescript/src/Components/Slider.d.ts +2 -1
- package/lib/typescript/src/Components/Slider.d.ts.map +1 -1
- package/lib/typescript/src/Components/Themed.d.ts.map +1 -1
- package/lib/typescript/src/CreateEngagement/api/index.d.ts +8 -2
- package/lib/typescript/src/CreateEngagement/api/index.d.ts.map +1 -1
- package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/src/Discord/api/index.d.ts +9 -0
- package/lib/typescript/src/Discord/api/index.d.ts.map +1 -0
- package/lib/typescript/src/Discord/index.d.ts +13 -0
- package/lib/typescript/src/Discord/index.d.ts.map +1 -0
- package/lib/typescript/src/FlashMarket/FlashHolder.d.ts +4 -2
- package/lib/typescript/src/FlashMarket/FlashHolder.d.ts.map +1 -1
- package/lib/typescript/src/FlashMarket/api/index.d.ts +2 -0
- package/lib/typescript/src/FlashMarket/api/index.d.ts.map +1 -1
- package/lib/typescript/src/FlashMarket/components/FlashOptionCard.d.ts +15 -0
- package/lib/typescript/src/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
- package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts +11 -0
- package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
- package/lib/typescript/src/FlashMarket/index.d.ts +2 -1
- package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -1
- package/lib/typescript/src/Group/api/index.d.ts +5 -2
- package/lib/typescript/src/Group/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Group/index.d.ts +3 -2
- package/lib/typescript/src/Group/index.d.ts.map +1 -1
- package/lib/typescript/src/Poll/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Squares/index.d.ts.map +1 -1
- package/lib/typescript/src/constants/useColors.d.ts +1 -0
- package/lib/typescript/src/constants/useColors.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/Components/BETimePicker.tsx +77 -0
- package/src/Components/Icons.tsx +17 -0
- package/src/Components/ImageUploader.tsx +3 -1
- package/src/Components/Slider.tsx +3 -1
- package/src/Components/Themed.tsx +6 -4
- package/src/CreateEngagement/api/index.ts +78 -2
- package/src/CreateEngagement/index.tsx +181 -7
- package/src/Discord/api/index.ts +57 -0
- package/src/Discord/index.tsx +300 -0
- package/src/FlashMarket/FlashHolder.tsx +11 -2
- package/src/FlashMarket/api/index.ts +24 -1
- package/src/FlashMarket/components/FlashOptionCard.tsx +174 -0
- package/src/FlashMarket/components/ManageFlashMarket.tsx +766 -0
- package/src/FlashMarket/index.tsx +14 -8
- package/src/Group/api/index.ts +5 -5
- package/src/Group/index.tsx +84 -9
- package/src/Poll/api/index.ts +0 -2
- package/src/Squares/index.tsx +0 -1
- package/src/SquaresManager/index.tsx +1 -1
- package/src/constants/useColors.tsx +2 -0
- package/src/index.tsx +4 -0
- package/src/types.d.ts +23 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, GroupPlayerProps, GroupProps, LeagueProps, SquaresCompetitionProps } from "../../types";
|
|
2
|
+
import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, GroupPlayerProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, SquaresCompetitionProps } from "../../types";
|
|
3
3
|
import { APIOverrides } from "../../ApiOverrides";
|
|
4
4
|
import type { CompanyMemberProps } from "../../Authenticator/api/types";
|
|
5
|
+
import moment from "moment-mini";
|
|
5
6
|
|
|
6
7
|
let AUTH_SVC_API = ''
|
|
7
8
|
let TP_SVC_API = ''
|
|
@@ -80,12 +81,45 @@ const CreateEngagementApi = {
|
|
|
80
81
|
} catch (e) {
|
|
81
82
|
return undefined
|
|
82
83
|
}
|
|
84
|
+
},
|
|
85
|
+
createPoll : async(poll:PollProps):Promise<PollProps | undefined> => {
|
|
86
|
+
try {
|
|
87
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/polls/poll/create`, { poll })
|
|
88
|
+
return resp.data.poll
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return undefined
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
createPollCampaign: async(poll_campaign:PollCampaignProps):Promise<PollCampaignProps | undefined> => {
|
|
94
|
+
try {
|
|
95
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/polls/campaigns/campaign/create`, { poll_campaign })
|
|
96
|
+
return resp.data.poll_campaign
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return undefined
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
getMyAdminFlashCampaigns: async():Promise<PollCampaignProps[]> => {
|
|
102
|
+
try {
|
|
103
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/admin/active`);
|
|
104
|
+
return resp.data.poll_campaigns
|
|
105
|
+
} catch (e) {
|
|
106
|
+
return []
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
getCompanyActiveFlashCampaigns: async(company_id:string):Promise<PollCampaignProps[]> => {
|
|
110
|
+
try {
|
|
111
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/company/active/${company_id}`);
|
|
112
|
+
return resp.data.poll_campaigns
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.log(e);
|
|
115
|
+
return []
|
|
116
|
+
}
|
|
83
117
|
}
|
|
84
118
|
}
|
|
85
119
|
|
|
86
120
|
|
|
87
121
|
const CreateEngagementHelpers = {
|
|
88
|
-
isStepValid: (step:CreateEngagementStepProps, active_engagement?:string, draft_competition?:any, draft_squares?:SquaresCompetitionProps):string[] => {
|
|
122
|
+
isStepValid: (step:CreateEngagementStepProps, active_engagement?:string, draft_competition?:any, draft_squares?:SquaresCompetitionProps, draft_flash?:PollProps):string[] => {
|
|
89
123
|
let errors:string[] = []
|
|
90
124
|
switch(step.step_key){
|
|
91
125
|
case 'intro': return errors
|
|
@@ -107,6 +141,11 @@ const CreateEngagementHelpers = {
|
|
|
107
141
|
if(!draft_squares.sq_comp_description){ errors.push('Please add a description') }
|
|
108
142
|
if(!draft_squares.event_id){ errors.push('Please add an event') }
|
|
109
143
|
break
|
|
144
|
+
case 'flash':
|
|
145
|
+
if(!draft_flash){ errors.push('Please complete the required steps') }
|
|
146
|
+
if(!draft_flash?.poll_question){ errors.push('Please add a poll question') }
|
|
147
|
+
if(!draft_flash?.poll_campaign_id){ errors.push('Please add to a compaign') }
|
|
148
|
+
break
|
|
110
149
|
default: break
|
|
111
150
|
}
|
|
112
151
|
break
|
|
@@ -134,5 +173,42 @@ const CreateEngagementHelpers = {
|
|
|
134
173
|
potential_winnings: 0,
|
|
135
174
|
create_datetime: '',last_update_datetime: ''
|
|
136
175
|
}
|
|
176
|
+
},
|
|
177
|
+
generateEmptyFlashCampaign:():PollCampaignProps => {
|
|
178
|
+
return {
|
|
179
|
+
poll_campaign_id: '',
|
|
180
|
+
name: '',
|
|
181
|
+
market_type: 'FOR_MONEY',
|
|
182
|
+
admins: [],
|
|
183
|
+
player_id: '',
|
|
184
|
+
company_id: '',
|
|
185
|
+
status: 'active',
|
|
186
|
+
phone: '0',
|
|
187
|
+
total_responses: 0,
|
|
188
|
+
create_datetime: '', last_update_datetime: '',
|
|
189
|
+
campaign_type: 'predict',
|
|
190
|
+
close_message_sent: false
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
generateFlashMarket: ():PollProps => {
|
|
194
|
+
return {
|
|
195
|
+
poll_campaign_id:'',
|
|
196
|
+
poll_id:'',
|
|
197
|
+
poll_question: '',
|
|
198
|
+
max_stake: 25,
|
|
199
|
+
minimum_stake: 1,
|
|
200
|
+
market_type: 'FOR_MONEY',
|
|
201
|
+
status: 'pending',
|
|
202
|
+
base_stake: 10,
|
|
203
|
+
require_resolution: true,
|
|
204
|
+
poll_type: 'select',
|
|
205
|
+
show_responses: true,
|
|
206
|
+
priority: 1,
|
|
207
|
+
end_datetime: moment().add(1, 'day'),
|
|
208
|
+
manual_close_only: false,
|
|
209
|
+
stake_increase_allowed: true,
|
|
210
|
+
multi_responses_allowed: true,
|
|
211
|
+
create_datetime: '', last_update_datetime:''
|
|
212
|
+
}
|
|
137
213
|
}
|
|
138
214
|
}
|
|
@@ -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, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
|
|
3
|
+
import type { BracketCompetitionProps, 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';
|
|
@@ -49,7 +49,8 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
|
|
|
49
49
|
squares_competition?:SquaresCompetitionProps
|
|
50
50
|
}>({
|
|
51
51
|
create_loading: false
|
|
52
|
-
})
|
|
52
|
+
});
|
|
53
|
+
const [ draft_flash, setDraftFlash ] = useState<PollProps | undefined>(undefined);
|
|
53
54
|
const [ draft_competition, setDraftCompetition ] = useState<undefined | {
|
|
54
55
|
loading:boolean,
|
|
55
56
|
types_visible:boolean,
|
|
@@ -66,7 +67,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
|
|
|
66
67
|
}>(undefined);
|
|
67
68
|
|
|
68
69
|
const [ draft_image, setDraftImage ] = useState<any>(undefined);
|
|
69
|
-
const [ active_step, setActiveStep ] = useState<CreateEngagementStepProps>(steps[
|
|
70
|
+
const [ active_step, setActiveStep ] = useState<CreateEngagementStepProps>(steps[4] as CreateEngagementStepProps)
|
|
70
71
|
const [ state, setState ] = useState<{
|
|
71
72
|
loading: boolean,
|
|
72
73
|
active_engagment?:'competition'|'squares'|'flash'|'bracket',
|
|
@@ -77,6 +78,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
|
|
|
77
78
|
}>({
|
|
78
79
|
loading:false,
|
|
79
80
|
groups: [],
|
|
81
|
+
active_engagment: 'flash',
|
|
80
82
|
companies: []
|
|
81
83
|
});
|
|
82
84
|
|
|
@@ -103,7 +105,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
|
|
|
103
105
|
loading:false
|
|
104
106
|
})
|
|
105
107
|
}
|
|
106
|
-
const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares);
|
|
108
|
+
const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash);
|
|
107
109
|
|
|
108
110
|
const handleNextStep = async() => {
|
|
109
111
|
if(errors.length > 0){ return alert(errors.map(e => e)) }
|
|
@@ -164,6 +166,14 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
|
|
|
164
166
|
const new_squares_comp = await CreateEngagementApi.createSquaresCompetition({ ...draft_squares, image: draft_image, company_id: active_company?.company_id, group_id: active_group?.group_id});
|
|
165
167
|
setPendingEngagement({ ...pending_engagement, create_loading: false, squares_competition: new_squares_comp });
|
|
166
168
|
break
|
|
169
|
+
case 'flash':
|
|
170
|
+
if(!draft_flash){ return alert('Unable to process') }
|
|
171
|
+
if(errors.length > 0){ return alert(errors.map(e => e)) }
|
|
172
|
+
setPendingEngagement({ ...pending_engagement, create_loading: true });
|
|
173
|
+
const new_flash_market = await CreateEngagementApi.createPoll({ ...draft_flash, poll_image: draft_image });
|
|
174
|
+
if(!new_flash_market){ return alert('Unable to process') }
|
|
175
|
+
setPendingEngagement({ ...pending_engagement, create_loading: false, poll: new_flash_market });
|
|
176
|
+
break
|
|
167
177
|
default: return //We cdont have one!
|
|
168
178
|
}
|
|
169
179
|
|
|
@@ -305,11 +315,14 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
|
|
|
305
315
|
)
|
|
306
316
|
case 'create':
|
|
307
317
|
if(active_step.step_key != 'create'){ return <></> }
|
|
318
|
+
if(!player){ return <></> }
|
|
308
319
|
switch(active_engagment){
|
|
309
320
|
case 'competition':
|
|
310
321
|
return <CreateCompetition onUpdateDraft={(d) => setDraftCompetition(d)} onFocusPosition={onFocusPostiion} />
|
|
311
322
|
case 'squares':
|
|
312
323
|
return <CreateSquares onUpdateDraft={(d) => setDraftSquares(d)} onFocusPosition={onFocusPostiion}/>
|
|
324
|
+
case 'flash':
|
|
325
|
+
return <CreateFlashMarket group={active_group} onUpdateDraft={(d) => setDraftFlash(d)} onFocusPosition={onFocusPostiion} company={active_company}/>
|
|
313
326
|
default: return <></>
|
|
314
327
|
}
|
|
315
328
|
default: return <></>
|
|
@@ -396,6 +409,169 @@ const IntroInfo = () => {
|
|
|
396
409
|
)
|
|
397
410
|
}
|
|
398
411
|
|
|
412
|
+
type CreateFlashMarketProps = {
|
|
413
|
+
company?:CompanyProps,
|
|
414
|
+
group?:GroupProps,
|
|
415
|
+
onFocusPosition?:(pos:FocusPositionProps) => void,
|
|
416
|
+
onUpdateDraft: (poll:PollProps) => void
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
const CreateFlashMarket = ({ company, group, onFocusPosition, onUpdateDraft }:CreateFlashMarketProps) => {
|
|
420
|
+
//Get active campaigns
|
|
421
|
+
const Colors = useColors();
|
|
422
|
+
const [ create_state, setCreateState ] = useState<{
|
|
423
|
+
draft_poll: PollProps,
|
|
424
|
+
campaign_loading:boolean,
|
|
425
|
+
new_campaign?:boolean,
|
|
426
|
+
draft_campaign:PollCampaignProps,
|
|
427
|
+
campaigns_visible:boolean,
|
|
428
|
+
poll_campaigns:PollCampaignProps[]
|
|
429
|
+
}>({
|
|
430
|
+
draft_poll: CreateEngagementHelpers.generateFlashMarket(),
|
|
431
|
+
campaigns_visible: false,
|
|
432
|
+
new_campaign: false,
|
|
433
|
+
campaign_loading:false,
|
|
434
|
+
draft_campaign: CreateEngagementHelpers.generateEmptyFlashCampaign(),
|
|
435
|
+
poll_campaigns: []
|
|
436
|
+
});
|
|
437
|
+
const { draft_poll, campaigns_visible, campaign_loading, draft_campaign, poll_campaigns, new_campaign } = create_state;
|
|
438
|
+
const active_campaign = poll_campaigns.find(pc => pc.poll_campaign_id == draft_poll.poll_campaign_id);
|
|
439
|
+
useEffect(() => {
|
|
440
|
+
getData();
|
|
441
|
+
},[company?.company_id, group?.group_id]);
|
|
442
|
+
|
|
443
|
+
useEffect(() => {
|
|
444
|
+
onUpdateDraft(draft_poll);
|
|
445
|
+
},[JSON.stringify(draft_poll)]);
|
|
446
|
+
|
|
447
|
+
const getData = async() => {
|
|
448
|
+
let pc = await CreateEngagementApi.getMyAdminFlashCampaigns();
|
|
449
|
+
if(company){
|
|
450
|
+
pc = await CreateEngagementApi.getCompanyActiveFlashCampaigns(company.company_id)
|
|
451
|
+
}
|
|
452
|
+
if(group){
|
|
453
|
+
pc = pc.filter(c => c.group_id == group.group_id)
|
|
454
|
+
}
|
|
455
|
+
setCreateState({
|
|
456
|
+
...create_state,
|
|
457
|
+
poll_campaigns: pc.filter(pc => pc.market_type == 'FOR_MONEY')
|
|
458
|
+
})
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const renderCampaigns = (data:{ item:PollCampaignProps, index:number }) => {
|
|
462
|
+
return (
|
|
463
|
+
<Button
|
|
464
|
+
transparent
|
|
465
|
+
style={{ flexDirection:'row', alignItems:'center', padding:10, borderRadius:0, borderBottomWidth:1, borderColor:Colors.borders.light }}
|
|
466
|
+
onPress={() => setCreateState({ ...create_state, campaigns_visible:false, draft_poll: { ...draft_poll, poll_campaign_id: data.item.poll_campaign_id } })}
|
|
467
|
+
>
|
|
468
|
+
<Image
|
|
469
|
+
source={{ uri: data.item.campaign_image?.url }}
|
|
470
|
+
style={{ height:40, width:40 }}
|
|
471
|
+
resizeMode='cover'
|
|
472
|
+
/>
|
|
473
|
+
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
474
|
+
<Text theme='h1'>{data.item.name}</Text>
|
|
475
|
+
</View>
|
|
476
|
+
</Button>
|
|
477
|
+
)
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return (
|
|
481
|
+
<View style={{ padding:10 }}>
|
|
482
|
+
<View style={{ padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
483
|
+
<View transparent style={{ flexDirection:'row', alignItems:'center', marginBottom:10 }}>
|
|
484
|
+
<View transparent style={{ flex:1 }}>
|
|
485
|
+
<Text theme='h1'>Select Campaign</Text>
|
|
486
|
+
<Text theme='description' style={{ marginTop:4 }}>Group your flash markets into like campaigns to better manage them</Text>
|
|
487
|
+
<Button
|
|
488
|
+
title={!new_campaign?'Create a new campaign' : 'Select Existing Campaign'}
|
|
489
|
+
title_color={ new_campaign?Colors.text.action:Colors.text.success }
|
|
490
|
+
transparent
|
|
491
|
+
style={{ alignItems:'flex-start', padding:10, paddingLeft:0 }}
|
|
492
|
+
onPress={() => setCreateState({ ...create_state, new_campaign: !new_campaign })}
|
|
493
|
+
/>
|
|
494
|
+
</View>
|
|
495
|
+
</View>
|
|
496
|
+
{!new_campaign ?
|
|
497
|
+
<Button float onPress={() => setCreateState({ ...create_state, campaigns_visible:!campaigns_visible }) }>
|
|
498
|
+
<View transparent style={{ flexDirection:'row', alignItems:'center' }}>
|
|
499
|
+
<Text style={{ flex:1, marginRight:10 }} theme='h1'>{active_campaign?.name ?? 'No Campaign'}</Text>
|
|
500
|
+
<Icons.ChevronIcon direction={campaigns_visible?'up':'down'} color={Colors.text.h1} size={8} />
|
|
501
|
+
</View>
|
|
502
|
+
{campaigns_visible ?
|
|
503
|
+
<View transparent style={{ marginTop:20 }}>
|
|
504
|
+
<FlatList
|
|
505
|
+
data={poll_campaigns}
|
|
506
|
+
key={'campaign_selector'}
|
|
507
|
+
keyExtractor={item => item.poll_campaign_id.toString()}
|
|
508
|
+
renderItem={renderCampaigns}
|
|
509
|
+
/>
|
|
510
|
+
</View>
|
|
511
|
+
:<></>}
|
|
512
|
+
</Button>
|
|
513
|
+
:
|
|
514
|
+
<View>
|
|
515
|
+
<View transparent style={{ marginBottom:10 }}>
|
|
516
|
+
<Text theme='h1'>Campaign Name</Text>
|
|
517
|
+
<Text theme='description' style={{ marginTop:4 }}>Enter the campaign name here. Use a name that appropriately groups the flash markets</Text>
|
|
518
|
+
</View>
|
|
519
|
+
<TextInput
|
|
520
|
+
placeholder='Add Campaign Name here...'
|
|
521
|
+
value={draft_campaign.name}
|
|
522
|
+
onFocusPosition={onFocusPosition}
|
|
523
|
+
style={{ borderColor:draft_campaign.name ? Colors.text.success : Colors.text.warning }}
|
|
524
|
+
onChangeText={(text) => setCreateState({ ...create_state, draft_campaign: { ...draft_campaign, name: text } })}
|
|
525
|
+
/>
|
|
526
|
+
<Button
|
|
527
|
+
title='CREATE CAMPAIGN'
|
|
528
|
+
loading={campaign_loading}
|
|
529
|
+
type='success'
|
|
530
|
+
disabled={!draft_campaign.name ? true : false}
|
|
531
|
+
style={{ opacity: campaign_loading || !draft_campaign.name ? 0.5: 1, marginTop:10 }}
|
|
532
|
+
onPress={async() => {
|
|
533
|
+
if(campaign_loading){ return }
|
|
534
|
+
if(!draft_campaign.name){ return }
|
|
535
|
+
//Create the new campaign!
|
|
536
|
+
setCreateState({ ...create_state, campaign_loading:true });
|
|
537
|
+
const new_pc = await CreateEngagementApi.createPollCampaign({ ...draft_campaign, group_id: group?.group_id, company_id: company?.company_id, campaign_image: company?.company_image })
|
|
538
|
+
if(!new_pc){
|
|
539
|
+
alert('Unable to create a campaign at this time');
|
|
540
|
+
setCreateState({ ...create_state, campaign_loading: false });
|
|
541
|
+
return
|
|
542
|
+
}
|
|
543
|
+
setCreateState({
|
|
544
|
+
...create_state,
|
|
545
|
+
campaign_loading: false,
|
|
546
|
+
new_campaign: false,
|
|
547
|
+
draft_poll: { ...draft_poll, poll_campaign_id: new_pc.poll_campaign_id },
|
|
548
|
+
poll_campaigns: poll_campaigns.concat(new_pc)
|
|
549
|
+
});
|
|
550
|
+
}}
|
|
551
|
+
/>
|
|
552
|
+
</View>
|
|
553
|
+
}
|
|
554
|
+
{group && !new_campaign ?
|
|
555
|
+
<Text theme='warning' style={{ marginTop:5 }}>Only showing campaigns associated with the {group.name} group. If you need a different campaign - go back and unselect this group.</Text>
|
|
556
|
+
:<></>}
|
|
557
|
+
</View>
|
|
558
|
+
<View style={{ padding:10 }}>
|
|
559
|
+
<View transparent style={{ marginBottom:10 }}>
|
|
560
|
+
<Text theme='h1'>Question Name</Text>
|
|
561
|
+
<Text theme='description' style={{ marginTop:4 }}>Enter the question here. You can modify it up until you activate it.</Text>
|
|
562
|
+
</View>
|
|
563
|
+
<TextInput
|
|
564
|
+
placeholder='Add Question here...'
|
|
565
|
+
value={draft_poll.poll_question}
|
|
566
|
+
onFocusPosition={onFocusPosition}
|
|
567
|
+
style={{ borderColor:draft_poll.poll_question ? Colors.text.success : Colors.text.warning }}
|
|
568
|
+
onChangeText={(text) => setCreateState({ ...create_state, draft_poll: { ...draft_poll, poll_question: text } })}
|
|
569
|
+
/>
|
|
570
|
+
</View>
|
|
571
|
+
</View>
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
|
|
399
575
|
type EngagementOptionProps = {
|
|
400
576
|
active_engagement?: 'competition'|'squares'|'flash'|'bracket',
|
|
401
577
|
onSelectEngagement: (engagement:'competition'|'squares'|'flash'|'bracket') => void
|
|
@@ -442,7 +618,6 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
|
|
|
442
618
|
</View>
|
|
443
619
|
</Button>
|
|
444
620
|
:<></>}
|
|
445
|
-
{false ?
|
|
446
621
|
<Button
|
|
447
622
|
key='flash'
|
|
448
623
|
float
|
|
@@ -455,7 +630,6 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
|
|
|
455
630
|
<Text theme='description' color={active_engagement == 'flash' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create a custom flash market. Players bet on the perimutuel outcomes, get it right and get paid!</Text>
|
|
456
631
|
</View>
|
|
457
632
|
</Button>
|
|
458
|
-
:<></>}
|
|
459
633
|
</View>
|
|
460
634
|
)
|
|
461
635
|
}
|
|
@@ -719,6 +893,7 @@ const CreateCompetition = ({ onFocusPosition, onUpdateDraft }:CCProps) => {
|
|
|
719
893
|
const { competition_name, competition_template_id, templates_visible, competition_description,competition_result_types, types_visible, competition_types, results_visible, competition_type, competition_result_type } = draft;
|
|
720
894
|
const template = templates.find(t => t.competition_id == competition_template_id)
|
|
721
895
|
useEffect(() => {
|
|
896
|
+
CreateEngagementApi.setEnvironment();
|
|
722
897
|
getData();
|
|
723
898
|
},[]);
|
|
724
899
|
|
|
@@ -728,7 +903,6 @@ const CreateCompetition = ({ onFocusPosition, onUpdateDraft }:CCProps) => {
|
|
|
728
903
|
|
|
729
904
|
const getData = async() => {
|
|
730
905
|
setDraft({ ...draft, loading:true });
|
|
731
|
-
CreateEngagementApi.setEnvironment();
|
|
732
906
|
let options = await CreateEngagementApi.getCompetitionOptions();
|
|
733
907
|
let temps = await CreateEngagementApi.getTemplateCompetitions();
|
|
734
908
|
setDraft({
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
import { APIOverrides } from '../../ApiOverrides';
|
|
4
|
+
import type { DiscordPlayerProps } from '../../types';
|
|
5
|
+
|
|
6
|
+
//let SOCIAL_SVC_API = '';
|
|
7
|
+
//let EVENT_SVC_API = '';
|
|
8
|
+
//let MK_SVC_API = '';
|
|
9
|
+
let AUTH_SVC_API = '';
|
|
10
|
+
//let TP_SVC_API = ''
|
|
11
|
+
|
|
12
|
+
export const DiscordPlayerApi = {
|
|
13
|
+
setEnvironment: () => {
|
|
14
|
+
const endpoints = APIOverrides.getEndpoints();
|
|
15
|
+
//SOCIAL_SVC_API = endpoints['SOCIAL_SVC_API'] as string;
|
|
16
|
+
//EVENT_SVC_API = endpoints['EVENT_SVC_API'] as string;
|
|
17
|
+
//MK_SVC_API = endpoints['MK_SVC_API'] as string;
|
|
18
|
+
AUTH_SVC_API = endpoints['AUTH_SVC_API'] as string;
|
|
19
|
+
//TP_SVC_API = endpoints['TP_SVC_API'] as string;
|
|
20
|
+
},
|
|
21
|
+
getMyDiscordConnection: async():Promise<DiscordPlayerProps | undefined> => {
|
|
22
|
+
try {
|
|
23
|
+
const resp = await axios.get(`${AUTH_SVC_API}/v1/players/discord/me`);
|
|
24
|
+
return resp.data.discord_player
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.log(e);
|
|
27
|
+
return undefined
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
startConnnection: async():Promise<DiscordPlayerProps | undefined> => {
|
|
31
|
+
try {
|
|
32
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/players/discord/connect`);
|
|
33
|
+
return resp.data.discord_player
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.log(e)
|
|
36
|
+
return undefined
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
confirmConnection: async():Promise<DiscordPlayerProps | undefined> => {
|
|
41
|
+
try {
|
|
42
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/players/discord/confirm`);
|
|
43
|
+
return resp.data.discord_player
|
|
44
|
+
} catch (e) {
|
|
45
|
+
console.log(e);
|
|
46
|
+
return undefined
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
disconnect: async():Promise<DiscordPlayerProps | undefined> => {
|
|
50
|
+
try {
|
|
51
|
+
const resp = await axios.post(`${AUTH_SVC_API}/v1/players/discord/disconnect`);
|
|
52
|
+
return resp.data.discord_player
|
|
53
|
+
} catch (e) {
|
|
54
|
+
return undefined
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|