be-components 0.7.4 → 0.7.6
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/Authenticator/Components/AuthStrategyIdentifier.js +113 -0
- package/lib/commonjs/Authenticator/Components/AuthStrategyIdentifier.js.map +1 -0
- package/lib/commonjs/Authenticator/Components/StrategyForm.js +238 -71
- package/lib/commonjs/Authenticator/Components/StrategyForm.js.map +1 -1
- package/lib/commonjs/Authenticator/index.js +7 -4
- package/lib/commonjs/Authenticator/index.js.map +1 -1
- package/lib/commonjs/Poll/api/index.js +38 -1
- package/lib/commonjs/Poll/api/index.js.map +1 -1
- package/lib/commonjs/Poll/flashmarket/index.js +354 -0
- package/lib/commonjs/Poll/flashmarket/index.js.map +1 -0
- package/lib/commonjs/Poll/index.js +21 -6
- package/lib/commonjs/Poll/index.js.map +1 -1
- package/lib/module/Authenticator/Components/AuthStrategyIdentifier.js +106 -0
- package/lib/module/Authenticator/Components/AuthStrategyIdentifier.js.map +1 -0
- package/lib/module/Authenticator/Components/StrategyForm.js +239 -72
- package/lib/module/Authenticator/Components/StrategyForm.js.map +1 -1
- package/lib/module/Authenticator/index.js +7 -4
- package/lib/module/Authenticator/index.js.map +1 -1
- package/lib/module/Poll/api/index.js +38 -1
- package/lib/module/Poll/api/index.js.map +1 -1
- package/lib/module/Poll/flashmarket/index.js +345 -0
- package/lib/module/Poll/flashmarket/index.js.map +1 -0
- package/lib/module/Poll/index.js +21 -6
- package/lib/module/Poll/index.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/Authenticator/Components/AuthStrategyIdentifier.d.ts +11 -0
- package/lib/typescript/src/Authenticator/Components/AuthStrategyIdentifier.d.ts.map +1 -0
- package/lib/typescript/src/Authenticator/Components/StrategyForm.d.ts +4 -1
- package/lib/typescript/src/Authenticator/Components/StrategyForm.d.ts.map +1 -1
- package/lib/typescript/src/Authenticator/index.d.ts +2 -1
- package/lib/typescript/src/Authenticator/index.d.ts.map +1 -1
- package/lib/typescript/src/Poll/api/index.d.ts +5 -1
- package/lib/typescript/src/Poll/api/index.d.ts.map +1 -1
- package/lib/typescript/src/Poll/flashmarket/index.d.ts +10 -0
- package/lib/typescript/src/Poll/flashmarket/index.d.ts.map +1 -0
- package/lib/typescript/src/Poll/index.d.ts +8 -2
- package/lib/typescript/src/Poll/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Authenticator/Components/AuthStrategyIdentifier.tsx +72 -0
- package/src/Authenticator/Components/StrategyForm.tsx +208 -53
- package/src/Authenticator/api/types.d.ts +2 -1
- package/src/Authenticator/index.tsx +8 -3
- package/src/Poll/api/index.ts +35 -1
- package/src/Poll/flashmarket/index.tsx +231 -0
- package/src/Poll/index.tsx +29 -9
- package/src/index.tsx +1 -0
- package/src/types.d.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Authenticator/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,OAAO,KAAK,EAAkD,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKtG,KAAK,uBAAuB,GAAG;IAC3B,gBAAgB,EAAC,MAAM,CAAC;IACxB,KAAK,EAAC,MAAM,CAAC;IACb,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,YAAY,CAAC,EAAC,OAAO,GAAC,UAAU,CAAA;IAChC,aAAa,CAAC,EAAC,OAAO,CAAC;IACvB,MAAM,EAAC,MAAM,CAAC;IACd,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,aAAa,CAAC,EAAC,MAAM,CAAC;IACtB,OAAO,CAAC,EAAC,OAAO,CAAC;IACjB,eAAe,EAAE,CAAC,aAAa,EAAC,kBAAkB,KAAK,IAAI,CAAC;IAC5D,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAC,MAAM,EAAE,MAAM,EAAC,SAAS,GAAC,MAAM,KAAK,IAAI,CAAA;IACvE,OAAO,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAED,QAAA,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Authenticator/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAOnD,OAAO,KAAK,EAAkD,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAKtG,KAAK,uBAAuB,GAAG;IAC3B,gBAAgB,EAAC,MAAM,CAAC;IACxB,KAAK,EAAC,MAAM,CAAC;IACb,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,YAAY,CAAC,EAAC,OAAO,GAAC,UAAU,CAAA;IAChC,aAAa,CAAC,EAAC,OAAO,CAAC;IACvB,MAAM,EAAC,MAAM,CAAC;IACd,KAAK,CAAC,EAAC,MAAM,GAAC,MAAM,CAAA;IACpB,UAAU,CAAC,EAAC,MAAM,CAAC;IACnB,aAAa,CAAC,EAAC,MAAM,CAAC;IACtB,OAAO,CAAC,EAAC,OAAO,CAAC;IACjB,eAAe,EAAE,CAAC,aAAa,EAAC,kBAAkB,KAAK,IAAI,CAAC;IAC5D,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAC,MAAM,EAAE,MAAM,EAAC,SAAS,GAAC,MAAM,KAAK,IAAI,CAAA;IACvE,OAAO,EAAE,MAAM,IAAI,CAAA;CACtB,CAAA;AAED,QAAA,MAAM,aAAa,yKAAyK,uBAAuB,sBAuGlN,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PollCampaignGoalProps, PollCampaignLeaderProps, PollCampaignProps, PollOptionProps, PollProps, PollResponseProps, PollSummaryProps } from "../../types";
|
|
2
|
-
export { PollCampaignApi, PollCampaignHelpers, PollApi, PollCampaignGoalApi, PollOptionApi, PollResponseApi };
|
|
2
|
+
export { PollCampaignApi, PollCampaignHelpers, PollApi, PollCampaignGoalApi, PollOptionApi, PollResponseApi, PollResponseHelpers };
|
|
3
3
|
declare const PollCampaignApi: {
|
|
4
4
|
setEnvironment: () => void;
|
|
5
5
|
getPlayersByPlayerIds: (player_ids: string[]) => Promise<any>;
|
|
@@ -54,6 +54,10 @@ declare const PollResponseApi: {
|
|
|
54
54
|
getRespondersByCampaignId: (poll_campaign_id: string, offset: number) => Promise<string[]>;
|
|
55
55
|
getMyCampaignResponses: (poll_campaign_id: string) => Promise<PollResponseProps[]>;
|
|
56
56
|
};
|
|
57
|
+
declare const PollResponseHelpers: {
|
|
58
|
+
getOptionColor: (po: PollOptionProps, pr?: PollResponseProps) => string;
|
|
59
|
+
updateSummariesWithResponse: (pr: PollResponseProps, summaries: PollSummaryProps[]) => PollSummaryProps[];
|
|
60
|
+
};
|
|
57
61
|
declare const PollOptionApi: {
|
|
58
62
|
createPollOption: (poll_option: PollOptionProps) => Promise<PollOptionProps>;
|
|
59
63
|
updatePollOption: (poll_option: PollOptionProps) => Promise<PollOptionProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Poll/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,eAAe,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Poll/api/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type FlashMarketProps = {
|
|
3
|
+
poll_id: string;
|
|
4
|
+
next_allowed?: boolean;
|
|
5
|
+
player_id?: string;
|
|
6
|
+
onRequestAuthenticate: () => void;
|
|
7
|
+
};
|
|
8
|
+
declare const FlashMarket: ({ poll_id, player_id, onRequestAuthenticate }: FlashMarketProps) => React.JSX.Element;
|
|
9
|
+
export default FlashMarket;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/Poll/flashmarket/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAUnD,KAAK,gBAAgB,GAAG;IACpB,OAAO,EAAC,MAAM,CAAC;IACf,YAAY,CAAC,EAAC,OAAO,CAAC;IACtB,SAAS,CAAC,EAAC,MAAM,CAAC;IAClB,qBAAqB,EAAC,MAAM,IAAI,CAAA;CACnC,CAAA;AAKD,QAAA,MAAM,WAAW,kDAAkD,gBAAgB,sBAgNlF,CAAA;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
type PollCampaignModuleProps = {
|
|
3
|
-
poll_campaign_id
|
|
3
|
+
poll_campaign_id?: string;
|
|
4
|
+
poll_id?: string;
|
|
5
|
+
player_id?: string;
|
|
6
|
+
height?: number;
|
|
7
|
+
width?: number;
|
|
8
|
+
type: 'campaign' | 'poll';
|
|
9
|
+
onRequestAuthenticate: () => void;
|
|
4
10
|
};
|
|
5
|
-
declare const PollCampaign: ({ poll_campaign_id }: PollCampaignModuleProps) => React.JSX.Element;
|
|
11
|
+
declare const PollCampaign: ({ poll_campaign_id, poll_id, type, player_id, onRequestAuthenticate }: PollCampaignModuleProps) => React.JSX.Element;
|
|
6
12
|
export default PollCampaign;
|
|
7
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Poll/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Poll/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,KAAK,uBAAuB,GAAG;IAC3B,gBAAgB,CAAC,EAAC,MAAM,CAAC;IACzB,OAAO,CAAC,EAAC,MAAM,CAAC;IAChB,SAAS,CAAC,EAAC,MAAM,CAAC;IAClB,MAAM,CAAC,EAAC,MAAM,CAAC;IACf,KAAK,CAAC,EAAC,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,IAAI,CAAA;CACpC,CAAA;AACD,QAAA,MAAM,YAAY,0EAA2E,uBAAuB,sBA2BnH,CAAA;AAED,eAAe,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAC1D,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,QAAQ,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,iBAAiB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,cAAc,MAAM,8BAA8B,CAAC;AAC1D,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,QAAQ,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,iBAAiB,MAAM,eAAe,CAAC;AAE9C,OAAO,EACL,aAAa,EACb,QAAQ,EACR,UAAU,EACV,SAAS,EACT,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,iBAAiB,EAClB,CAAA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from "react-native"
|
|
3
|
+
import { Icons, Text, TextInput } from "../../Components"
|
|
4
|
+
import type { AuthStrategyIdentifierProps } from '../api/types';
|
|
5
|
+
import Colors from '../../constants/colors';
|
|
6
|
+
import { AuthenticateHelpers } from '../api';
|
|
7
|
+
|
|
8
|
+
type AuthStrategyIdentifierCardProps = {
|
|
9
|
+
auth_strategy_identifier:AuthStrategyIdentifierProps,
|
|
10
|
+
auth_request?: any,
|
|
11
|
+
auto_focus?:boolean,
|
|
12
|
+
onChangeIdentifier: (text:string, is_valid:boolean, pretty_value?:string) => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const AuthStrategyIdentifier = ({ auth_strategy_identifier, auto_focus, auth_request, onChangeIdentifier }:AuthStrategyIdentifierCardProps) => {
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const getAttributeIcon = (attribute:string) => {
|
|
19
|
+
switch(attribute){
|
|
20
|
+
case 'email': return <Icons.EmailIcon size={20} color={Colors.brand.midnight}/>
|
|
21
|
+
case 'phone': return <Icons.PhoneIcon size={20} color={Colors.brand.midnight} />
|
|
22
|
+
case 'username': return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
23
|
+
default: return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if(!auth_strategy_identifier.auth_identifier){ return <></> }
|
|
28
|
+
const is_valid = AuthenticateHelpers.isAttributeValid(auth_request.attribute, auth_request.value)
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<View>
|
|
32
|
+
<View style={{ margin:10 }}>
|
|
33
|
+
<Text size={16} color={Colors.brand.midnight} weight='bold'>{auth_strategy_identifier.label}</Text>
|
|
34
|
+
<Text style={{ marginTop:4 }} size={14} color={Colors.brand.midnight} weight='regular'>{auth_strategy_identifier.description}</Text>
|
|
35
|
+
<View style={{ marginTop:5, flexDirection:'row', alignItems:'center', borderRadius:22, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
36
|
+
<View style={{ paddingLeft:10, paddingRight:15 }}>
|
|
37
|
+
{getAttributeIcon(auth_strategy_identifier.auth_identifier.attribute)}
|
|
38
|
+
</View>
|
|
39
|
+
<TextInput
|
|
40
|
+
style={{ flex:1 }}
|
|
41
|
+
value={auth_request.pretty_value ?? auth_request.value}
|
|
42
|
+
placeholder={`${auth_strategy_identifier.label}`}
|
|
43
|
+
autoFocus={auto_focus}
|
|
44
|
+
placeholderTextColor={Colors.brand.slate}
|
|
45
|
+
onChangeText={(text) => {
|
|
46
|
+
let pretty_value:string | undefined = undefined
|
|
47
|
+
if(auth_request.attribute == 'phone'){
|
|
48
|
+
text = AuthenticateHelpers.unformatPhone(text)
|
|
49
|
+
pretty_value = AuthenticateHelpers.formatPhone(text)
|
|
50
|
+
}
|
|
51
|
+
onChangeIdentifier(text, is_valid.valid, pretty_value)
|
|
52
|
+
}}
|
|
53
|
+
/>
|
|
54
|
+
{auth_request.value ?
|
|
55
|
+
<View style={{ padding:10 }}>
|
|
56
|
+
{ is_valid.valid ?
|
|
57
|
+
<Icons.CheckCirlceIcon color={Colors.utility.success} size={14} />
|
|
58
|
+
:
|
|
59
|
+
<Icons.AlertIcon color={Colors.utility.warning} size={14} />
|
|
60
|
+
}
|
|
61
|
+
</View>
|
|
62
|
+
:<></>}
|
|
63
|
+
</View>
|
|
64
|
+
{auth_request.value && !is_valid.valid ?
|
|
65
|
+
<Text style={{ marginTop:2 }} size={12} color={Colors.utility.warning} weight='semibold' textAlign="right">{is_valid.error}</Text>
|
|
66
|
+
:<></>}
|
|
67
|
+
</View>
|
|
68
|
+
</View>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default AuthStrategyIdentifier
|
|
@@ -3,10 +3,11 @@ import { Button, Checkbox, Icons, Text, TextInput } from "../../Components";
|
|
|
3
3
|
import Colors from "../../constants/colors";
|
|
4
4
|
import type { AuthExecutionRequestProps, AuthStrategyIdentifierProps, AuthStrategyProps, AuthenticatedProps } from '../api/types';
|
|
5
5
|
import { AuthenticateApi, AuthenticateHelpers } from '../api';
|
|
6
|
-
import { Linking, TouchableOpacity, View , FlatList} from 'react-native';
|
|
7
|
-
import type { PlayerReferralProps, PromoProps, PublicPlayerProps } from '../../types';
|
|
6
|
+
import { Linking, TouchableOpacity, View , FlatList, Image } from 'react-native';
|
|
7
|
+
import type { CompanyProps, PlayerReferralProps, PromoProps, PublicPlayerProps } from '../../types';
|
|
8
8
|
import { view_styles } from '../../constants/styles';
|
|
9
9
|
import { ProfileHelpers } from '../../ProfileManager/api';
|
|
10
|
+
import AuthStrategyIdentifier from './AuthStrategyIdentifier';
|
|
10
11
|
|
|
11
12
|
type StrategyFormProps = {
|
|
12
13
|
visible:boolean,
|
|
@@ -16,6 +17,8 @@ type StrategyFormProps = {
|
|
|
16
17
|
company_id?:string,
|
|
17
18
|
distinct_id:string,
|
|
18
19
|
source:string,
|
|
20
|
+
theme?:'full'|'mini',
|
|
21
|
+
company?:CompanyProps,
|
|
19
22
|
opt_in_url?:string,
|
|
20
23
|
show_referral?:boolean,
|
|
21
24
|
referral_code?:string,
|
|
@@ -23,7 +26,9 @@ type StrategyFormProps = {
|
|
|
23
26
|
onAuthenticated: (auth_response:AuthenticatedProps) => void
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
const
|
|
29
|
+
const mini_steps = ['intro', 'execution', 'verify']
|
|
30
|
+
|
|
31
|
+
const StrategyForm = ({ visible, company, theme, strategy, auth_strategy_id, company_id, distinct_id, source, show_referral, referral_code, width, opt_in_url, onAuthenticated, onLogin }:StrategyFormProps) => {
|
|
27
32
|
|
|
28
33
|
const [ action_loading, setActionLoading ] = useState(false);
|
|
29
34
|
const [ active_view, setActiveView ] = useState('authenticate');
|
|
@@ -32,7 +37,9 @@ const StrategyForm = ({ visible, strategy, auth_strategy_id, company_id, distinc
|
|
|
32
37
|
promo?:PromoProps,
|
|
33
38
|
referrer?:PublicPlayerProps
|
|
34
39
|
}>({})
|
|
40
|
+
const [ active_mini_index, setActiveMiniIndex ] = useState(0);
|
|
35
41
|
const [ opted_in, setOptedIn ] = useState(true);
|
|
42
|
+
const [ active_index, setActiveIndex ] = useState<number>(0)
|
|
36
43
|
const [ token, setToken ] = useState('');
|
|
37
44
|
const [ verify_error, setVerifyError ] = useState<string|undefined>();
|
|
38
45
|
const [ verify_attempt_allowed, setVeryAttemptAllowed ] = useState(true);
|
|
@@ -54,7 +61,7 @@ const StrategyForm = ({ visible, strategy, auth_strategy_id, company_id, distinc
|
|
|
54
61
|
|
|
55
62
|
|
|
56
63
|
const { auth_strategy, auth_strategy_identifiers } = strategy;
|
|
57
|
-
const verify_strategy_identifier = auth_strategy_identifiers
|
|
64
|
+
const verify_strategy_identifier = auth_strategy_identifiers[0]//.find(asi => asi.auth_strategy_identifier_id == verify_state?.auth_strategy_identifier_id);
|
|
58
65
|
|
|
59
66
|
useEffect(() => {
|
|
60
67
|
if(!auth_strategy){ return }
|
|
@@ -73,7 +80,6 @@ const StrategyForm = ({ visible, strategy, auth_strategy_id, company_id, distinc
|
|
|
73
80
|
//if(!asi.auth_identifier){ return }
|
|
74
81
|
return { attribute: asi.auth_identifier?.attribute ?? '', value: '' }
|
|
75
82
|
})
|
|
76
|
-
|
|
77
83
|
setAuthExecutionRequest({
|
|
78
84
|
auth_strategy_id,
|
|
79
85
|
company_id,
|
|
@@ -86,15 +92,6 @@ const StrategyForm = ({ visible, strategy, auth_strategy_id, company_id, distinc
|
|
|
86
92
|
|
|
87
93
|
}
|
|
88
94
|
|
|
89
|
-
const getAttributeIcon = (attribute:string) => {
|
|
90
|
-
switch(attribute){
|
|
91
|
-
case 'email': return <Icons.EmailIcon size={20} color={Colors.brand.midnight}/>
|
|
92
|
-
case 'phone': return <Icons.PhoneIcon size={20} color={Colors.brand.midnight} />
|
|
93
|
-
case 'username': return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
94
|
-
default: return <Icons.UserIcon size={20} color={Colors.brand.midnight} />
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
95
|
const verifyAuthStrategyIdentifier = async() => {
|
|
99
96
|
if(authenticated){ return }
|
|
100
97
|
if(!verify_state){ return }
|
|
@@ -146,62 +143,220 @@ const StrategyForm = ({ visible, strategy, auth_strategy_id, company_id, distinc
|
|
|
146
143
|
if(!data.item.auth_identifier){ return <></> }
|
|
147
144
|
const auth_request = auth_execution_request.attributes.find(a => a.attribute == data.item.auth_identifier?.attribute)
|
|
148
145
|
if(!auth_request){ return <></> }
|
|
149
|
-
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<AuthStrategyIdentifier
|
|
149
|
+
auth_strategy_identifier={data.item}
|
|
150
|
+
auth_request={auth_request}
|
|
151
|
+
onChangeIdentifier={(text, is_valid, pretty_value) => {
|
|
152
|
+
setAuthExecutionRequest({
|
|
153
|
+
...auth_execution_request,
|
|
154
|
+
attributes: auth_execution_request.attributes.filter(a => a.attribute != auth_request.attribute).concat({
|
|
155
|
+
attribute: auth_request.attribute,
|
|
156
|
+
value: text,
|
|
157
|
+
pretty_value,
|
|
158
|
+
is_valid
|
|
159
|
+
})
|
|
160
|
+
})
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const strategy_valid = AuthenticateHelpers.isStrategyValid(auth_execution_request)
|
|
167
|
+
if(!visible || !auth_strategy){ return <></> }
|
|
168
|
+
|
|
169
|
+
if(theme == 'mini'){
|
|
170
|
+
const active_mini_step = mini_steps[active_mini_index];
|
|
171
|
+
const active_strategy_identifier = auth_strategy_identifiers[active_index]
|
|
172
|
+
const auth_request = auth_execution_request.attributes.find(a => a.attribute == active_strategy_identifier?.auth_identifier?.attribute)
|
|
173
|
+
const last_index = auth_strategy_identifiers.length - 1 == active_index ? true : false
|
|
174
|
+
if(!auth_request || !active_mini_step){ return <></> }
|
|
150
175
|
return (
|
|
151
|
-
<View>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
<
|
|
155
|
-
|
|
156
|
-
<View style={{
|
|
157
|
-
|
|
176
|
+
<View style={{ width }}>
|
|
177
|
+
{active_mini_step == 'intro' ?
|
|
178
|
+
<View>
|
|
179
|
+
<View style={{ flexDirection:'row' }}>
|
|
180
|
+
{company ?
|
|
181
|
+
<View style={{ padding:10 }}>
|
|
182
|
+
<Image
|
|
183
|
+
source={{ uri: company.company_image?.url }}
|
|
184
|
+
style={{ height:60, width:60 }}
|
|
185
|
+
resizeMode='cover'
|
|
186
|
+
/>
|
|
187
|
+
</View>
|
|
188
|
+
:<></>}
|
|
189
|
+
<View style={{ flex:1, padding:10 }}>
|
|
190
|
+
<Text size={16} color={Colors.brand.midnight} weight='bold'>Welcome!</Text>
|
|
191
|
+
<Text style={{ marginTop:4 }} size={14} color={Colors.brand.midnight}>Please complete the required steps to participate with {company?.company_name ?? 'Bettoredge'}</Text>
|
|
158
192
|
</View>
|
|
193
|
+
</View>
|
|
194
|
+
<View style={{ flexDirection:'row', padding:10, paddingTop:0 }}>
|
|
195
|
+
{opt_in_url ?
|
|
196
|
+
<View style={{ flex:1, flexDirection:'row', alignItems:'center' }}>
|
|
197
|
+
<Checkbox
|
|
198
|
+
size={20}
|
|
199
|
+
checked={opted_in}
|
|
200
|
+
onSelect={(checked) => setOptedIn(checked)}
|
|
201
|
+
/>
|
|
202
|
+
<Text style={{ marginLeft:15 }} size={14} color={Colors.brand.midnight}>By continuing, you agree to the terms and conditions outlined
|
|
203
|
+
<TouchableOpacity onPress={() => Linking.openURL(opt_in_url) }>
|
|
204
|
+
<Text size={14} color={Colors.brand.electric} weight='bold'> here.</Text>
|
|
205
|
+
</TouchableOpacity>
|
|
206
|
+
</Text>
|
|
207
|
+
</View>
|
|
208
|
+
:<></>}
|
|
209
|
+
<Button
|
|
210
|
+
title={`Next`}
|
|
211
|
+
style={{ opacity:opt_in_url && !opted_in ? 0.5:1 }}
|
|
212
|
+
disabled={opt_in_url && !opted_in ? true : false}
|
|
213
|
+
title_color={Colors.shades.white}
|
|
214
|
+
backgroundColor={Colors.brand.electric}
|
|
215
|
+
//borderRadius={8}
|
|
216
|
+
padding={15}
|
|
217
|
+
onPress={() => {
|
|
218
|
+
setActiveMiniIndex(active_mini_index + 1)
|
|
219
|
+
}}
|
|
220
|
+
/>
|
|
221
|
+
</View>
|
|
222
|
+
</View>
|
|
223
|
+
:active_mini_step == 'execution' ?
|
|
224
|
+
<View>
|
|
225
|
+
|
|
226
|
+
{active_view == 'authenticate' && active_strategy_identifier?
|
|
227
|
+
<View>
|
|
228
|
+
<AuthStrategyIdentifier
|
|
229
|
+
auth_strategy_identifier={active_strategy_identifier}
|
|
230
|
+
auth_request={auth_request}
|
|
231
|
+
auto_focus={true}
|
|
232
|
+
onChangeIdentifier={(text, is_valid, pretty_value) => {
|
|
233
|
+
setAuthExecutionRequest({
|
|
234
|
+
...auth_execution_request,
|
|
235
|
+
attributes: auth_execution_request.attributes.filter(a => a.attribute != auth_request.attribute).concat({
|
|
236
|
+
attribute: auth_request.attribute,
|
|
237
|
+
value: text,
|
|
238
|
+
pretty_value,
|
|
239
|
+
is_valid
|
|
240
|
+
})
|
|
241
|
+
})
|
|
242
|
+
}}
|
|
243
|
+
/>
|
|
244
|
+
<View style={{ flexDirection:'row', alignItems:'center', padding:10, paddingTop:0 }}>
|
|
245
|
+
{active_index != 0 ?
|
|
246
|
+
<Button
|
|
247
|
+
title={`Back`}
|
|
248
|
+
style={{ flex:1, marginRight:5}}
|
|
249
|
+
title_color={Colors.brand.electric}
|
|
250
|
+
borderWidth={1}
|
|
251
|
+
borderColor={Colors.brand.electric}
|
|
252
|
+
backgroundColor={Colors.shades.white}
|
|
253
|
+
//borderRadius={8}
|
|
254
|
+
padding={15}
|
|
255
|
+
onPress={() => {
|
|
256
|
+
setActiveIndex(active_index - 1)
|
|
257
|
+
}}
|
|
258
|
+
/>
|
|
259
|
+
:<></>}
|
|
260
|
+
{last_index ?
|
|
261
|
+
<Button
|
|
262
|
+
title={`Let's Go!`}
|
|
263
|
+
loading={action_loading}
|
|
264
|
+
|
|
265
|
+
style={{ flex:3, opacity:strategy_valid && opted_in && !action_loading?1:0.5 }}
|
|
266
|
+
disabled={action_loading || !strategy_valid || !opted_in}
|
|
267
|
+
title_color={Colors.shades.white}
|
|
268
|
+
backgroundColor={Colors.brand.electric}
|
|
269
|
+
//borderRadius={8}
|
|
270
|
+
padding={15}
|
|
271
|
+
onPress={() => {
|
|
272
|
+
executeAuthStrategy()
|
|
273
|
+
}}
|
|
274
|
+
/>
|
|
275
|
+
:
|
|
276
|
+
|
|
277
|
+
<Button
|
|
278
|
+
title={`Next`}
|
|
279
|
+
style={{ flex:3, opacity:auth_request?.is_valid?1:0.5 }}
|
|
280
|
+
disabled={!auth_request?.is_valid}
|
|
281
|
+
title_color={Colors.shades.white}
|
|
282
|
+
backgroundColor={Colors.brand.electric}
|
|
283
|
+
//borderRadius={8}
|
|
284
|
+
padding={15}
|
|
285
|
+
onPress={() => {
|
|
286
|
+
setActiveIndex(active_index + 1)
|
|
287
|
+
}}
|
|
288
|
+
/>
|
|
289
|
+
}
|
|
290
|
+
</View>
|
|
291
|
+
</View>
|
|
292
|
+
: active_view == 'verify' && verify_strategy_identifier ?
|
|
293
|
+
<View nativeID="sign_up" style={{ flex:1 }}>
|
|
294
|
+
<View style={{ padding:10 }}>
|
|
295
|
+
<Text size={18} color={Colors.brand.midnight} weight='semibold'>{verify_strategy_identifier.verify_label??'Enter Verification Code'}</Text>
|
|
296
|
+
<View style={{ padding:10 }}>
|
|
159
297
|
<TextInput
|
|
160
|
-
style={{
|
|
161
|
-
value={
|
|
162
|
-
|
|
163
|
-
|
|
298
|
+
style={{ textAlign:'center', fontFamily:'barlow-bold', fontSize:14, borderWidth:1, borderColor:Colors.shades.shade600 }}
|
|
299
|
+
value={token}
|
|
300
|
+
keyboardType='default'
|
|
301
|
+
placeholder='Enter Code'
|
|
302
|
+
autoFocus
|
|
303
|
+
textContentType={verify_strategy_identifier.secure_text_entry ? undefined : 'oneTimeCode'}
|
|
304
|
+
secureTextEntry={verify_strategy_identifier.secure_text_entry}
|
|
164
305
|
placeholderTextColor={Colors.brand.slate}
|
|
165
306
|
onChangeText={(text) => {
|
|
166
|
-
|
|
167
|
-
if(auth_request.attribute == 'phone'){
|
|
168
|
-
text = AuthenticateHelpers.unformatPhone(text)
|
|
169
|
-
pretty_value = AuthenticateHelpers.formatPhone(text)
|
|
170
|
-
}
|
|
171
|
-
setAuthExecutionRequest({
|
|
172
|
-
...auth_execution_request,
|
|
173
|
-
attributes: auth_execution_request.attributes.filter(a => a.attribute != auth_request.attribute).concat({
|
|
174
|
-
attribute: auth_request.attribute,
|
|
175
|
-
value: text,
|
|
176
|
-
pretty_value
|
|
177
|
-
})
|
|
178
|
-
})
|
|
307
|
+
setToken(text);
|
|
179
308
|
}}
|
|
180
309
|
/>
|
|
181
|
-
{auth_request.value ?
|
|
182
|
-
<View style={{ padding:10 }}>
|
|
183
|
-
{ is_valid.valid ?
|
|
184
|
-
<Icons.CheckCirlceIcon color={Colors.utility.success} size={14} />
|
|
185
|
-
:
|
|
186
|
-
<Icons.AlertIcon color={Colors.utility.warning} size={14} />
|
|
187
|
-
}
|
|
188
|
-
</View>
|
|
189
|
-
:<></>}
|
|
190
310
|
</View>
|
|
191
|
-
{
|
|
192
|
-
<Text style={{ marginTop:
|
|
311
|
+
{verify_error ?
|
|
312
|
+
<Text style={{ marginTop:10 }} size={14} color={Colors.utility.warning}>{verify_error}</Text>
|
|
193
313
|
:<></>}
|
|
194
314
|
</View>
|
|
315
|
+
<View nativeID="action_row" style={{ flexDirection:'row', padding:10, paddingTop:0 }}>
|
|
316
|
+
<Button
|
|
317
|
+
title={'BACK'}
|
|
318
|
+
loading={action_loading}
|
|
319
|
+
style={{ flex:1, marginRight:5 }}
|
|
320
|
+
//disabled={!token || action_loading || !verify_attempt_allowed}
|
|
321
|
+
title_color={Colors.brand.electric}
|
|
322
|
+
borderColor={Colors.brand.electric}
|
|
323
|
+
borderWidth={1}
|
|
324
|
+
//backgroundColor={Colors.utility.success}
|
|
325
|
+
//borderRadius={8}
|
|
326
|
+
padding={15}
|
|
327
|
+
onPress={() => {
|
|
328
|
+
setActiveView('authenticate');
|
|
329
|
+
setVerifyState(undefined)
|
|
330
|
+
}}
|
|
331
|
+
/>
|
|
332
|
+
<Button
|
|
333
|
+
title={verify_attempt_allowed && !action_loading? 'Verify': 'Retry in 10 seconds'}
|
|
334
|
+
loading={action_loading}
|
|
335
|
+
style={{ flex:3, opacity:token&&verify_attempt_allowed?1:0.5 }}
|
|
336
|
+
disabled={!token || action_loading || !verify_attempt_allowed}
|
|
337
|
+
title_color={Colors.shades.white}
|
|
338
|
+
backgroundColor={Colors.utility.success}
|
|
339
|
+
//borderRadius={8}
|
|
340
|
+
padding={15}
|
|
341
|
+
onPress={() => {
|
|
342
|
+
verifyAuthStrategyIdentifier()
|
|
343
|
+
}}
|
|
344
|
+
/>
|
|
345
|
+
</View>
|
|
346
|
+
</View>
|
|
347
|
+
:<></> }
|
|
348
|
+
|
|
349
|
+
</View>
|
|
350
|
+
:<></>}
|
|
351
|
+
|
|
352
|
+
|
|
195
353
|
</View>
|
|
196
354
|
)
|
|
197
355
|
}
|
|
198
356
|
|
|
199
|
-
const strategy_valid = AuthenticateHelpers.isStrategyValid(auth_execution_request)
|
|
200
|
-
if(!visible || !auth_strategy){ return <></> }
|
|
201
357
|
return (
|
|
202
358
|
<View style={{ width:width, flex:1 }}>
|
|
203
359
|
{active_view == 'authenticate' ?
|
|
204
|
-
|
|
205
360
|
<View nativeID="sign_up" style={{ flex:1 }}>
|
|
206
361
|
{show_referral && code_details.player_referral && code_details.promo ?
|
|
207
362
|
<View style={{ margin:15, flexDirection:'row', backgroundColor:Colors.shades.white, borderRadius:8, ...view_styles.float }}>
|
|
@@ -17,6 +17,7 @@ type AuthenticateWizardProps = {
|
|
|
17
17
|
default_view?:'login'|'register'
|
|
18
18
|
show_referral?:boolean,
|
|
19
19
|
source:string,
|
|
20
|
+
theme?:'full'|'mini'
|
|
20
21
|
opt_in_url?:string,
|
|
21
22
|
referral_code?:string,
|
|
22
23
|
visible?:boolean,
|
|
@@ -25,7 +26,7 @@ type AuthenticateWizardProps = {
|
|
|
25
26
|
onClose: () => void
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
const Authenticator = ({ visible, show_referral, auth_strategy_id, default_view, company_id, source, referral_code, width, opt_in_url, onTryAuthenticate, onAuthenticated, onClose }:AuthenticateWizardProps) => {
|
|
29
|
+
const Authenticator = ({ visible, theme, show_referral, auth_strategy_id, default_view, company_id, source, referral_code, width, opt_in_url, onTryAuthenticate, onAuthenticated, onClose }:AuthenticateWizardProps) => {
|
|
29
30
|
const [ loaded, setLoaded ] = useState(false);
|
|
30
31
|
const [ company, setCompany ] = useState<CompanyProps>();
|
|
31
32
|
const [ distinct_id, setDistinctID ] = useState<string>();
|
|
@@ -75,8 +76,8 @@ const Authenticator = ({ visible, show_referral, auth_strategy_id, default_view,
|
|
|
75
76
|
if(!loaded || !distinct_id){ return <></> }
|
|
76
77
|
if(!visible){ return <></> }
|
|
77
78
|
return (
|
|
78
|
-
<View style={{ flex:1, width, minHeight:600 }}>
|
|
79
|
-
{company ?
|
|
79
|
+
<View style={{ flex:1, width, minHeight:theme!='mini'?600:undefined }}>
|
|
80
|
+
{company && theme != 'mini' ?
|
|
80
81
|
<View style={{ padding:20, flexDirection:'row', alignItems:'center', borderTopRightRadius:22, borderTopLeftRadius:22, borderBottomWidth:1, borderColor:Colors.accents.accent200 }}>
|
|
81
82
|
<View style={{ flex:1, marginRight:10 }}>
|
|
82
83
|
<Text size={28} weight='bold' color={Colors.brand.midnight}>{active_view == 'login' ? 'Log In!': 'Welcome!'}</Text>
|
|
@@ -94,7 +95,9 @@ const Authenticator = ({ visible, show_referral, auth_strategy_id, default_view,
|
|
|
94
95
|
<StrategyForm
|
|
95
96
|
visible={active_view == 'register' ? true : false}
|
|
96
97
|
width={width}
|
|
98
|
+
company={company}
|
|
97
99
|
strategy={strategy}
|
|
100
|
+
theme={theme}
|
|
98
101
|
onLogin={() => setActiveView('login')}
|
|
99
102
|
auth_strategy_id={auth_strategy_id}
|
|
100
103
|
company_id={company_id}
|
|
@@ -112,6 +115,7 @@ const Authenticator = ({ visible, show_referral, auth_strategy_id, default_view,
|
|
|
112
115
|
onTryAuthenticate={(attribute, result) => onTryAuthenticate ? onTryAuthenticate(attribute, result) : console.log()}
|
|
113
116
|
onRegister={() => setActiveView('register')}
|
|
114
117
|
/>
|
|
118
|
+
{theme != 'mini' ?
|
|
115
119
|
<View style={{ padding:10 }}>
|
|
116
120
|
<Button
|
|
117
121
|
title='CLOSE'
|
|
@@ -122,6 +126,7 @@ const Authenticator = ({ visible, show_referral, auth_strategy_id, default_view,
|
|
|
122
126
|
onPress={() => onClose()}
|
|
123
127
|
/>
|
|
124
128
|
</View>
|
|
129
|
+
:<></>}
|
|
125
130
|
</View>
|
|
126
131
|
)
|
|
127
132
|
}
|
package/src/Poll/api/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import axios from "axios"
|
|
2
2
|
import type { PollCampaignGoalProps, PollCampaignLeaderProps, PollCampaignProps, PollOptionProps, PollProps, PollResponseProps, PollSummaryProps } from "../../types";
|
|
3
3
|
import { APIOverrides } from "../../ApiOverrides";
|
|
4
|
+
import Colors from "../../constants/colors";
|
|
4
5
|
|
|
5
6
|
let AUTH_SVC_API = ''
|
|
6
7
|
|
|
@@ -10,7 +11,8 @@ export {
|
|
|
10
11
|
PollApi,
|
|
11
12
|
PollCampaignGoalApi,
|
|
12
13
|
PollOptionApi,
|
|
13
|
-
PollResponseApi
|
|
14
|
+
PollResponseApi,
|
|
15
|
+
PollResponseHelpers
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
const PollCampaignApi = {
|
|
@@ -120,7 +122,9 @@ const PollApi = {
|
|
|
120
122
|
return resp.data.polls
|
|
121
123
|
},
|
|
122
124
|
getPollById : async(poll_id:string):Promise<{ poll:PollProps, poll_options:PollOptionProps[], poll_summaries: PollSummaryProps[] }> => {
|
|
125
|
+
console.log('getting data')
|
|
123
126
|
const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/poll/${poll_id}`)
|
|
127
|
+
|
|
124
128
|
const { poll, poll_options, poll_summaries } = resp.data;
|
|
125
129
|
return { poll, poll_options, poll_summaries }
|
|
126
130
|
}
|
|
@@ -164,6 +168,36 @@ const PollResponseApi = {
|
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
170
|
|
|
171
|
+
const PollResponseHelpers = {
|
|
172
|
+
getOptionColor: (po:PollOptionProps, pr?:PollResponseProps) => {
|
|
173
|
+
if(!pr){ return Colors.shades.white }
|
|
174
|
+
if(pr.status == 'pending'){ return Colors.shades.white }
|
|
175
|
+
switch(po.result_ind){
|
|
176
|
+
case 'win':
|
|
177
|
+
return Colors.highlights.highlight400Faded
|
|
178
|
+
case 'lose':
|
|
179
|
+
return Colors.highlights.highlight300Faded
|
|
180
|
+
case 'draw':
|
|
181
|
+
return Colors.brand.slate
|
|
182
|
+
default:
|
|
183
|
+
if(pr?.poll_option_id == po.poll_option_id){ return Colors.brand.midnight }
|
|
184
|
+
return 'transparent'
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
updateSummariesWithResponse : (pr:PollResponseProps, summaries:PollSummaryProps[]) => {
|
|
188
|
+
let new_total = summaries.reduce((a,b) => a + parseFloat(b.stake as unknown as string), 0) + parseFloat(pr.stake as string)
|
|
189
|
+
summaries = summaries.map(s => {
|
|
190
|
+
if(s.poll_option_id == pr.poll_option_id){
|
|
191
|
+
s.count += 1
|
|
192
|
+
s.stake += parseFloat(pr.stake as string)
|
|
193
|
+
}
|
|
194
|
+
s.pct = s.stake / new_total
|
|
195
|
+
return s
|
|
196
|
+
})
|
|
197
|
+
return summaries
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
167
201
|
const PollOptionApi = {
|
|
168
202
|
createPollOption : async(poll_option:PollOptionProps):Promise<PollOptionProps> => {
|
|
169
203
|
const resp = await axios.post(`${AUTH_SVC_API}/v1/polls/poll/option/create`, { poll_option })
|