be-components 0.1.1

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 (114) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +31 -0
  3. package/lib/commonjs/AuthenticateWizard/Components/StrategyForm.js +398 -0
  4. package/lib/commonjs/AuthenticateWizard/Components/StrategyForm.js.map +1 -0
  5. package/lib/commonjs/AuthenticateWizard/api/index.js +246 -0
  6. package/lib/commonjs/AuthenticateWizard/api/index.js.map +1 -0
  7. package/lib/commonjs/AuthenticateWizard/api/types.d.js +2 -0
  8. package/lib/commonjs/AuthenticateWizard/api/types.d.js.map +1 -0
  9. package/lib/commonjs/AuthenticateWizard/index.js +85 -0
  10. package/lib/commonjs/AuthenticateWizard/index.js.map +1 -0
  11. package/lib/commonjs/Components/Button.js +84 -0
  12. package/lib/commonjs/Components/Button.js.map +1 -0
  13. package/lib/commonjs/Components/Checkbox.js +41 -0
  14. package/lib/commonjs/Components/Checkbox.js.map +1 -0
  15. package/lib/commonjs/Components/Icons.js +1492 -0
  16. package/lib/commonjs/Components/Icons.js.map +1 -0
  17. package/lib/commonjs/Components/Spring.js +44 -0
  18. package/lib/commonjs/Components/Spring.js.map +1 -0
  19. package/lib/commonjs/Components/Text.js +44 -0
  20. package/lib/commonjs/Components/Text.js.map +1 -0
  21. package/lib/commonjs/Components/TextInput.js +45 -0
  22. package/lib/commonjs/Components/TextInput.js.map +1 -0
  23. package/lib/commonjs/Components/index.js +49 -0
  24. package/lib/commonjs/Components/index.js.map +1 -0
  25. package/lib/commonjs/Font.css +23 -0
  26. package/lib/commonjs/constants/colors.js +66 -0
  27. package/lib/commonjs/constants/colors.js.map +1 -0
  28. package/lib/commonjs/constants/styles.js +43 -0
  29. package/lib/commonjs/constants/styles.js.map +1 -0
  30. package/lib/commonjs/fonts/Barlow-Bold.ttf +0 -0
  31. package/lib/commonjs/fonts/Barlow-Light.ttf +0 -0
  32. package/lib/commonjs/fonts/Barlow-Regular.ttf +0 -0
  33. package/lib/commonjs/fonts/Barlow-SemiBold.ttf +0 -0
  34. package/lib/commonjs/index.js +33 -0
  35. package/lib/commonjs/index.js.map +1 -0
  36. package/lib/module/AuthenticateWizard/Components/StrategyForm.js +389 -0
  37. package/lib/module/AuthenticateWizard/Components/StrategyForm.js.map +1 -0
  38. package/lib/module/AuthenticateWizard/api/index.js +240 -0
  39. package/lib/module/AuthenticateWizard/api/index.js.map +1 -0
  40. package/lib/module/AuthenticateWizard/api/types.d.js +2 -0
  41. package/lib/module/AuthenticateWizard/api/types.d.js.map +1 -0
  42. package/lib/module/AuthenticateWizard/index.js +77 -0
  43. package/lib/module/AuthenticateWizard/index.js.map +1 -0
  44. package/lib/module/Components/Button.js +77 -0
  45. package/lib/module/Components/Button.js.map +1 -0
  46. package/lib/module/Components/Checkbox.js +34 -0
  47. package/lib/module/Components/Checkbox.js.map +1 -0
  48. package/lib/module/Components/Icons.js +1485 -0
  49. package/lib/module/Components/Icons.js.map +1 -0
  50. package/lib/module/Components/Spring.js +37 -0
  51. package/lib/module/Components/Spring.js.map +1 -0
  52. package/lib/module/Components/Text.js +37 -0
  53. package/lib/module/Components/Text.js.map +1 -0
  54. package/lib/module/Components/TextInput.js +38 -0
  55. package/lib/module/Components/TextInput.js.map +1 -0
  56. package/lib/module/Components/index.js +8 -0
  57. package/lib/module/Components/index.js.map +1 -0
  58. package/lib/module/Font.css +23 -0
  59. package/lib/module/constants/colors.js +60 -0
  60. package/lib/module/constants/colors.js.map +1 -0
  61. package/lib/module/constants/styles.js +36 -0
  62. package/lib/module/constants/styles.js.map +1 -0
  63. package/lib/module/fonts/Barlow-Bold.ttf +0 -0
  64. package/lib/module/fonts/Barlow-Light.ttf +0 -0
  65. package/lib/module/fonts/Barlow-Regular.ttf +0 -0
  66. package/lib/module/fonts/Barlow-SemiBold.ttf +0 -0
  67. package/lib/module/index.js +4 -0
  68. package/lib/module/index.js.map +1 -0
  69. package/lib/typescript/src/AuthenticateWizard/Components/StrategyForm.d.ts +15 -0
  70. package/lib/typescript/src/AuthenticateWizard/Components/StrategyForm.d.ts.map +1 -0
  71. package/lib/typescript/src/AuthenticateWizard/api/index.d.ts +80 -0
  72. package/lib/typescript/src/AuthenticateWizard/api/index.d.ts.map +1 -0
  73. package/lib/typescript/src/AuthenticateWizard/index.d.ts +15 -0
  74. package/lib/typescript/src/AuthenticateWizard/index.d.ts.map +1 -0
  75. package/lib/typescript/src/Components/Button.d.ts +30 -0
  76. package/lib/typescript/src/Components/Button.d.ts.map +1 -0
  77. package/lib/typescript/src/Components/Checkbox.d.ts +11 -0
  78. package/lib/typescript/src/Components/Checkbox.d.ts.map +1 -0
  79. package/lib/typescript/src/Components/Icons.d.ts +44 -0
  80. package/lib/typescript/src/Components/Icons.d.ts.map +1 -0
  81. package/lib/typescript/src/Components/Spring.d.ts +11 -0
  82. package/lib/typescript/src/Components/Spring.d.ts.map +1 -0
  83. package/lib/typescript/src/Components/Text.d.ts +13 -0
  84. package/lib/typescript/src/Components/Text.d.ts.map +1 -0
  85. package/lib/typescript/src/Components/TextInput.d.ts +15 -0
  86. package/lib/typescript/src/Components/TextInput.d.ts.map +1 -0
  87. package/lib/typescript/src/Components/index.d.ts +8 -0
  88. package/lib/typescript/src/Components/index.d.ts.map +1 -0
  89. package/lib/typescript/src/constants/colors.d.ts +60 -0
  90. package/lib/typescript/src/constants/colors.d.ts.map +1 -0
  91. package/lib/typescript/src/constants/styles.d.ts +34 -0
  92. package/lib/typescript/src/constants/styles.d.ts.map +1 -0
  93. package/lib/typescript/src/index.d.ts +4 -0
  94. package/lib/typescript/src/index.d.ts.map +1 -0
  95. package/package.json +167 -0
  96. package/src/AuthenticateWizard/Components/StrategyForm.tsx +292 -0
  97. package/src/AuthenticateWizard/api/index.ts +164 -0
  98. package/src/AuthenticateWizard/api/types.d.ts +134 -0
  99. package/src/AuthenticateWizard/index.tsx +84 -0
  100. package/src/Components/Button.tsx +63 -0
  101. package/src/Components/Checkbox.tsx +28 -0
  102. package/src/Components/Icons.tsx +698 -0
  103. package/src/Components/Spring.tsx +38 -0
  104. package/src/Components/Text.tsx +35 -0
  105. package/src/Components/TextInput.tsx +45 -0
  106. package/src/Components/index.tsx +15 -0
  107. package/src/Font.css +23 -0
  108. package/src/constants/colors.ts +61 -0
  109. package/src/constants/styles.ts +40 -0
  110. package/src/fonts/Barlow-Bold.ttf +0 -0
  111. package/src/fonts/Barlow-Light.ttf +0 -0
  112. package/src/fonts/Barlow-Regular.ttf +0 -0
  113. package/src/fonts/Barlow-SemiBold.ttf +0 -0
  114. package/src/index.tsx +9 -0
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import '../font.css';
3
+ export interface TextProps {
4
+ weight?: 'bold' | 'semibold' | 'regular' | 'light';
5
+ color?: string;
6
+ size?: number;
7
+ children: any;
8
+ textAlign?: 'left' | 'center' | 'right';
9
+ style?: any;
10
+ }
11
+ declare const Text: ({ weight, color, size, children, textAlign, style }: TextProps) => React.JSX.Element;
12
+ export default Text;
13
+ //# sourceMappingURL=Text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Text.d.ts","sourceRoot":"","sources":["../../../../src/Components/Text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,aAAa,CAAC;AAIrB,MAAM,WAAW,SAAS;IACtB,MAAM,CAAC,EAAC,MAAM,GAAC,UAAU,GAAC,SAAS,GAAC,OAAO,CAAC;IAC5C,KAAK,CAAC,EAAC,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAC,GAAG,CAAC;IACb,SAAS,CAAC,EAAC,MAAM,GAAC,QAAQ,GAAC,OAAO,CAAC;IACnC,KAAK,CAAC,EAAC,GAAG,CAAA;CACb;AAED,QAAA,MAAM,IAAI,wDAAyD,SAAS,sBAiB3E,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ type TextInputProps = {
3
+ value?: string;
4
+ placeholder?: string;
5
+ autoFocus?: boolean;
6
+ keyboardType?: string;
7
+ textContentType?: string;
8
+ secureTextEntry?: boolean;
9
+ placeholderTextColor?: string;
10
+ onChangeText: (text: string) => void;
11
+ style?: any;
12
+ };
13
+ declare const TextInput: ({ onChangeText, placeholderTextColor, value, placeholder, style, autoFocus, keyboardType, textContentType, secureTextEntry }: TextInputProps) => React.JSX.Element;
14
+ export default TextInput;
15
+ //# sourceMappingURL=TextInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/Components/TextInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,KAAK,cAAc,GAAG;IAClB,KAAK,CAAC,EAAC,MAAM,CAAC;IACd,WAAW,CAAC,EAAC,MAAM,CAAC;IACpB,SAAS,CAAC,EAAC,OAAO,CAAC;IACnB,YAAY,CAAC,EAAC,MAAM,CAAC;IACrB,eAAe,CAAC,EAAC,MAAM,CAAC;IACxB,eAAe,CAAC,EAAC,OAAO,CAAC;IACzB,oBAAoB,CAAC,EAAC,MAAM,CAAC;IAC7B,YAAY,EAAC,CAAC,IAAI,EAAC,MAAM,KAAK,IAAI,CAAC;IACnC,KAAK,CAAC,EAAC,GAAG,CAAA;CACb,CAAA;AAED,QAAA,MAAM,SAAS,iIAAmI,cAAc,sBAyB/J,CAAA;AAED,eAAe,SAAS,CAAA"}
@@ -0,0 +1,8 @@
1
+ import Button from './Button';
2
+ import Text from './Text';
3
+ import Spring from './Spring';
4
+ import TextInput from './TextInput';
5
+ import Icons from './Icons';
6
+ import Checkbox from './Checkbox';
7
+ export { Button, Text, Spring, TextInput, Checkbox, Icons };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/Components/index.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,EACH,MAAM,EACN,IAAI,EACJ,MAAM,EACN,SAAS,EACT,QAAQ,EACR,KAAK,EACR,CAAA"}
@@ -0,0 +1,60 @@
1
+ declare const Colors: {
2
+ brand: {
3
+ cobalt: string;
4
+ midnight: string;
5
+ midnightTopGradient: string;
6
+ electric: string;
7
+ cyan: string;
8
+ slate: string;
9
+ mint: string;
10
+ yellow: string;
11
+ facebook: string;
12
+ new: string;
13
+ };
14
+ chart: {
15
+ cyan: string;
16
+ electric: string;
17
+ };
18
+ shades: {
19
+ white: string;
20
+ shade100: string;
21
+ shade200: string;
22
+ shade300: string;
23
+ shade400: string;
24
+ shade500: string;
25
+ shade600: string;
26
+ black: string;
27
+ black_faded: string;
28
+ black_faded_heavy: string;
29
+ black_faded_super_heavy: string;
30
+ };
31
+ accents: {
32
+ accent100: string;
33
+ accent200: string;
34
+ };
35
+ highlights: {
36
+ highlight100: string;
37
+ highlight100Faded: string;
38
+ highlight200: string;
39
+ highlight200Faded: string;
40
+ highlight300: string;
41
+ highlight300Faded: string;
42
+ highlight400: string;
43
+ highlight400Faded: string;
44
+ highlight500: string;
45
+ highlight500Faded: string;
46
+ };
47
+ utility: {
48
+ success: string;
49
+ error: string;
50
+ warning: string;
51
+ };
52
+ incentive: {
53
+ gold: string;
54
+ gold_faded: string;
55
+ silver: string;
56
+ bronze: string;
57
+ };
58
+ };
59
+ export default Colors;
60
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../../src/constants/colors.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DT,CAAA;AACD,eAAe,MAAM,CAAA"}
@@ -0,0 +1,34 @@
1
+ export declare const view_styles: {
2
+ container: {
3
+ backgroundColor: string;
4
+ borderTopRightRadius: number;
5
+ borderTopLeftRadius: number;
6
+ };
7
+ };
8
+ export declare const text_styles: {
9
+ dark_heading_1: {
10
+ fontSize: number;
11
+ color: string;
12
+ };
13
+ dark_heading_2: {
14
+ fontSize: number;
15
+ color: string;
16
+ };
17
+ dark_heading_3: {
18
+ fontSize: number;
19
+ color: string;
20
+ };
21
+ light_heading_1: {
22
+ fontSize: number;
23
+ color: string;
24
+ };
25
+ light_heading_2: {
26
+ fontSize: number;
27
+ color: string;
28
+ };
29
+ light_heading_3: {
30
+ fontSize: number;
31
+ color: string;
32
+ };
33
+ };
34
+ //# sourceMappingURL=styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/constants/styles.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW;;;;;;CAMtB,CAAA;AAGF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;CAyBtB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import AuthenticateWizard from "./AuthenticateWizard";
2
+ import { Text, Button, Spring } from './Components';
3
+ export { AuthenticateWizard, Text, Button, Spring };
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EACL,kBAAkB,EAClB,IAAI,EACJ,MAAM,EACN,MAAM,EACP,CAAA"}
package/package.json ADDED
@@ -0,0 +1,167 @@
1
+ {
2
+ "name": "be-components",
3
+ "version": "0.1.1",
4
+ "description": "Components for BettorEdge Apps",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/src/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "!ios/build",
18
+ "!android/build",
19
+ "!android/gradle",
20
+ "!android/gradlew",
21
+ "!android/gradlew.bat",
22
+ "!android/local.properties",
23
+ "!**/__tests__",
24
+ "!**/__fixtures__",
25
+ "!**/__mocks__",
26
+ "!**/.*"
27
+ ],
28
+ "scripts": {
29
+ "example": "yarn workspace be-components-example",
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "clean": "del-cli lib",
34
+ "prepare": "bob build",
35
+ "release": "release-it"
36
+ },
37
+ "keywords": [
38
+ "react-native",
39
+ "ios",
40
+ "android"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://www.bettoredge.com.git"
45
+ },
46
+ "author": "BettorEdge <james@bettoredge.com> (https://www.bettoredge.com)",
47
+ "license": "MIT",
48
+ "bugs": {
49
+ "url": "https://www.bettoredge.com/issues"
50
+ },
51
+ "homepage": "https://www.bettoredge.com#readme",
52
+ "publishConfig": {
53
+ "registry": "https://registry.npmjs.org/"
54
+ },
55
+ "devDependencies": {
56
+ "@commitlint/config-conventional": "^17.0.2",
57
+ "@evilmartians/lefthook": "^1.5.0",
58
+ "@react-native/eslint-config": "^0.73.1",
59
+ "@release-it/conventional-changelog": "^5.0.0",
60
+ "@types/jest": "^29.5.5",
61
+ "@types/react": "^18.2.44",
62
+ "commitlint": "^17.0.2",
63
+ "del-cli": "^5.1.0",
64
+ "eslint": "^8.51.0",
65
+ "eslint-config-prettier": "^9.0.0",
66
+ "eslint-plugin-prettier": "^5.0.1",
67
+ "jest": "^29.7.0",
68
+ "prettier": "^3.0.3",
69
+ "react": "18.2.0",
70
+ "react-native": "0.73.6",
71
+ "react-native-builder-bob": "^0.23.2",
72
+ "release-it": "^15.0.0",
73
+ "typescript": "^5.2.2"
74
+ },
75
+ "resolutions": {
76
+ "@types/react": "^18.2.44"
77
+ },
78
+ "peerDependencies": {
79
+ "react": "*",
80
+ "react-native": "*"
81
+ },
82
+ "workspaces": [
83
+ "example"
84
+ ],
85
+ "packageManager": "yarn@3.6.1",
86
+ "jest": {
87
+ "preset": "react-native",
88
+ "modulePathIgnorePatterns": [
89
+ "<rootDir>/example/node_modules",
90
+ "<rootDir>/lib/"
91
+ ]
92
+ },
93
+ "commitlint": {
94
+ "extends": [
95
+ "@commitlint/config-conventional"
96
+ ]
97
+ },
98
+ "release-it": {
99
+ "git": {
100
+ "commitMessage": "chore: release ${version}",
101
+ "tagName": "v${version}"
102
+ },
103
+ "npm": {
104
+ "publish": true
105
+ },
106
+ "github": {
107
+ "release": true
108
+ },
109
+ "plugins": {
110
+ "@release-it/conventional-changelog": {
111
+ "preset": "angular"
112
+ }
113
+ }
114
+ },
115
+ "eslintConfig": {
116
+ "root": true,
117
+ "extends": [
118
+ "@react-native",
119
+ "prettier"
120
+ ],
121
+ "rules": {
122
+ "prettier/prettier": [
123
+ "error",
124
+ {
125
+ "quoteProps": "consistent",
126
+ "singleQuote": true,
127
+ "tabWidth": 2,
128
+ "trailingComma": "es5",
129
+ "useTabs": false
130
+ }
131
+ ]
132
+ }
133
+ },
134
+ "eslintIgnore": [
135
+ "node_modules/",
136
+ "lib/"
137
+ ],
138
+ "prettier": {
139
+ "quoteProps": "consistent",
140
+ "singleQuote": true,
141
+ "tabWidth": 2,
142
+ "trailingComma": "es5",
143
+ "useTabs": false
144
+ },
145
+ "react-native-builder-bob": {
146
+ "source": "src",
147
+ "output": "lib",
148
+ "targets": [
149
+ "commonjs",
150
+ "module",
151
+ [
152
+ "typescript",
153
+ {
154
+ "project": "tsconfig.build.json"
155
+ }
156
+ ]
157
+ ]
158
+ },
159
+ "dependencies": {
160
+ "@react-spring/web": "^9.7.3",
161
+ "axios": "^1.6.8",
162
+ "expo-linear-gradient": "^12.7.2"
163
+ },
164
+ "directories": {
165
+ "example": "example"
166
+ }
167
+ }
@@ -0,0 +1,292 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Checkbox, Icons, Text, TextInput } from "../../Components";
3
+ import Colors from "../../constants/colors";
4
+ import type { AuthExecutionRequestProps, AuthStrategyIdentifierProps, AuthStrategyProps, CompanyProps } from '../api/types';
5
+ import { AuthenticateApi, AuthenticateHelpers } from '../api';
6
+ import { Image, Linking, TouchableOpacity, View , FlatList} from 'react-native';
7
+
8
+ type StrategyFormProps = {
9
+ visible:boolean,
10
+ auth_strategy_id:string,
11
+ width:number,
12
+ company_id?:string,
13
+ device_id?:string,
14
+ source:string,
15
+ opt_in_url?:string,
16
+ referral_code?:string,
17
+ onAuthenticated: (access_token:string, refresh_token:string, expire_datetime:any) => void
18
+ }
19
+
20
+ const StrategyForm = ({ visible, auth_strategy_id, company_id, device_id, source, referral_code, width, opt_in_url, onAuthenticated }:StrategyFormProps) => {
21
+
22
+ const [ action_loading, setActionLoading ] = useState(false);
23
+ const [ active_view, setActiveView ] = useState('authenticate');
24
+ const [ opted_in, setOptedIn ] = useState(true);
25
+ const [ token, setToken ] = useState('');
26
+ const [ verify_error, setVerifyError ] = useState<string|undefined>();
27
+ const [ verify_attempt_allowed, setVeryAttemptAllowed ] = useState(true);
28
+ const [ authenticated, setAuthenticated ] = useState(false);
29
+ console.log(authenticated)
30
+ const [ auth_execution_request, setAuthExecutionRequest ] = useState<AuthExecutionRequestProps>({
31
+ auth_strategy_id: auth_strategy_id,
32
+ device_id,
33
+ source,
34
+ referral_code,
35
+ attributes: []
36
+ })
37
+ const [ verify_state, setVerifyState ] = useState<{
38
+ verification_session_id:string,
39
+ session_expire_datetime:any,
40
+ auth_strategy_identifier_id:string
41
+ } | undefined>(undefined)
42
+ const [ strategy, setStrategy ] = useState<{
43
+ loading:boolean,
44
+ company?:CompanyProps,
45
+ auth_strategy?:AuthStrategyProps,
46
+ auth_strategy_identifiers:AuthStrategyIdentifierProps[]
47
+ }>({
48
+ loading: false,
49
+ company:undefined,
50
+ auth_strategy:undefined,
51
+ auth_strategy_identifiers:[]
52
+ });
53
+
54
+ const { company, auth_strategy_identifiers } = strategy;
55
+ const verify_strategy_identifier = auth_strategy_identifiers.find(asi => asi.auth_strategy_identifier_id == verify_state?.auth_strategy_identifier_id);
56
+
57
+ useEffect(() => {
58
+ if(!auth_strategy_id || !visible){ return }
59
+ setUpWizard(auth_strategy_id)
60
+ },[auth_strategy_id, visible])
61
+
62
+ const setUpWizard = async(auth_strategy_id:string) => {
63
+ setStrategy({ ...strategy, loading:true });
64
+ //Get auth strategy from server
65
+ const { auth_strategy, auth_strategy_identifiers } = await AuthenticateApi.getAuthStrategyById(auth_strategy_id);
66
+ let company:CompanyProps|undefined = undefined
67
+ if(company_id){
68
+ const company_resp = await AuthenticateApi.getCompanyById(company_id)
69
+ company = company_resp.company
70
+ }
71
+ let unique_attributes = auth_strategy_identifiers.map(asi => {
72
+ //if(!asi.auth_identifier){ return }
73
+ return { attribute: asi.auth_identifier?.attribute ?? '', value: '' }
74
+ })
75
+
76
+ setAuthExecutionRequest({
77
+ auth_strategy_id,
78
+ device_id,
79
+ source,
80
+ referral_code,
81
+ attributes: unique_attributes
82
+ })
83
+
84
+ setStrategy({
85
+ ...strategy,
86
+ auth_strategy,
87
+ company,
88
+ auth_strategy_identifiers,
89
+ loading:false
90
+ })
91
+ }
92
+
93
+ const verifyAuthStrategyIdentifier = async() => {
94
+ if(!verify_state){ return }
95
+ if(action_loading){ return } //No mashy mashy
96
+ if(!verify_attempt_allowed){ return }
97
+ setVeryAttemptAllowed(false);
98
+ setActionLoading(true);
99
+ const { result, access_token, refresh_token, expire_datetime } = await AuthenticateApi.verifyAuthStrategyIdentifier(verify_state.auth_strategy_identifier_id, verify_state.verification_session_id, token, device_id);
100
+ if(result == 'fail' || !access_token || !refresh_token){
101
+ setVerifyError(`Invalid code / password. Please try again after 10 seconds`)
102
+ setTimeout(() => {
103
+ setVeryAttemptAllowed(true);
104
+ setVerifyError(undefined)
105
+ }, 10000);
106
+ } else {
107
+ setAuthenticated(true);
108
+ setTimeout(() => {
109
+ onAuthenticated(access_token, refresh_token, expire_datetime);
110
+ }, 1500);
111
+ }
112
+ setActionLoading(false);
113
+
114
+
115
+ }
116
+
117
+ const executeAuthStrategy = async() => {
118
+ setActionLoading(true);
119
+ const { result, verification_session_id, session_expire_datetime, auth_strategy_identifier_id } = await AuthenticateApi.executeAuthStrategy(auth_execution_request);
120
+ if(result == 'fail'){
121
+ setActionLoading(false);
122
+ return
123
+ }
124
+ setVerifyState({
125
+ verification_session_id,
126
+ session_expire_datetime,
127
+ auth_strategy_identifier_id
128
+ })
129
+ setActiveView('verify');
130
+ setActionLoading(false);
131
+ }
132
+
133
+ const renderAuthStrategyIdentifiers = (data: { item:AuthStrategyIdentifierProps, index: number }) => {
134
+ if(!data.item.auth_identifier){ return <></> }
135
+ const auth_request = auth_execution_request.attributes.find(a => a.attribute == data.item.auth_identifier?.attribute)
136
+ if(!auth_request){ return <></> }
137
+ const is_valid = AuthenticateHelpers.isAttributeValid(auth_request.attribute, auth_request.value)
138
+ return (
139
+ <View>
140
+ <View style={{ margin:10 }}>
141
+ <Text size={16} color={Colors.brand.midnight} weight='bold'>{data.item.label}</Text>
142
+ <Text style={{ marginTop:4 }} size={14} color={Colors.brand.midnight} weight='regular'>{data.item.description}</Text>
143
+ <View style={{ marginTop:5, flexDirection:'row', alignItems:'center', borderRadius:22, borderWidth:1, borderColor:Colors.shades.shade600 }}>
144
+ <TextInput
145
+ style={{ flex:1 }}
146
+ value={auth_request.pretty_value ?? auth_request.value}
147
+ placeholder={`${data.item.label}`}
148
+ autoFocus={data.item.priority == 1 ? true : false}
149
+ placeholderTextColor={Colors.brand.slate}
150
+ onChangeText={(text) => {
151
+ let pretty_value:string | undefined = undefined
152
+ if(auth_request.attribute == 'phone'){
153
+ text = AuthenticateHelpers.unformatPhone(text)
154
+ pretty_value = AuthenticateHelpers.formatPhone(text)
155
+ }
156
+ setAuthExecutionRequest({
157
+ ...auth_execution_request,
158
+ attributes: auth_execution_request.attributes.filter(a => a.attribute != auth_request.attribute).concat({
159
+ attribute: auth_request.attribute,
160
+ value: text,
161
+ pretty_value
162
+ })
163
+ })
164
+ }}
165
+ />
166
+ {auth_request.value ?
167
+ <View style={{ padding:10 }}>
168
+ { is_valid.valid ?
169
+ <Icons.CheckCirlceIcon color={Colors.utility.success} size={14} />
170
+ :
171
+ <Icons.AlertIcon color={Colors.utility.warning} size={14} />
172
+ }
173
+ </View>
174
+ :<></>}
175
+ </View>
176
+ {auth_request.value && !is_valid.valid ?
177
+ <Text style={{ marginTop:2 }} size={12} color={Colors.utility.warning} weight='semibold' textAlign="right">{is_valid.error}</Text>
178
+ :<></>}
179
+ </View>
180
+ </View>
181
+ )
182
+ }
183
+
184
+ const strategy_valid = AuthenticateHelpers.isStrategyValid(auth_execution_request)
185
+ if(!visible){ return <></> }
186
+ return (
187
+ <View>
188
+ {company ?
189
+ <View style={{ padding:20, flexDirection:'row', alignItems:'center', borderTopRightRadius:22, borderTopLeftRadius:22, borderBottomWidth:1, borderColor:Colors.accents.accent200 }}>
190
+ <View style={{ flex:1, marginRight:10 }}>
191
+ <Text size={28} weight='bold' color={Colors.brand.midnight}>Welcome!</Text>
192
+ <Text style={{ marginTop:5 }} color={Colors.brand.midnight} size={14} weight='semibold' textAlign='left'>Continue to sign up with BettorEdge</Text>
193
+ </View>
194
+ <View>
195
+ <Image
196
+ source={{ uri: company?.company_image?.url }}
197
+ style={{ width: width * 0.15, height: width * 0.15, borderRadius:8 }}
198
+ resizeMode='cover'
199
+ />
200
+ </View>
201
+ </View>
202
+ :<></>}
203
+
204
+ {active_view == 'authenticate' ?
205
+
206
+ <View nativeID="sign_up" style={{ flex:1 }}>
207
+ <View style={{ flex:1, padding:10 }}>
208
+ <View style={{ padding:10 }}>
209
+ <FlatList
210
+ data={auth_strategy_identifiers.sort((a,b) => a.priority - b.priority)}
211
+ renderItem={renderAuthStrategyIdentifiers}
212
+ keyExtractor={(item) => item.auth_strategy_identifier_id.toString()}
213
+ />
214
+ </View>
215
+ </View>
216
+ <View nativeID="action_row" style={{ padding:10, paddingLeft:20, paddingRight:20 }}>
217
+ <Button
218
+ title={`Let's Go!`}
219
+ loading={action_loading}
220
+ style={{ opacity:strategy_valid && opted_in?1:0.5 }}
221
+ disabled={action_loading || !strategy_valid || !opted_in}
222
+ title_color={Colors.shades.white}
223
+ backgroundColor={Colors.brand.electric}
224
+ borderRadius={8}
225
+ padding={15}
226
+ onPress={() => {
227
+ executeAuthStrategy()
228
+ }}
229
+ />
230
+ </View>
231
+ {active_view == 'authenticate' && opt_in_url ?
232
+ <View style={{ flexDirection:'row', alignItems:'center', padding:20 }}>
233
+ <Checkbox
234
+ size={25}
235
+ checked={opted_in}
236
+ onSelect={(checked) => setOptedIn(checked)}
237
+ />
238
+ <Text style={{ marginLeft:15 }} size={14} color={Colors.brand.midnight}>By continuing, you agree to the terms and conditions outlined
239
+ <TouchableOpacity onPress={() => Linking.openURL(opt_in_url) }>
240
+ <Text size={14} color={Colors.brand.electric} weight='bold'> here.</Text>
241
+ </TouchableOpacity>
242
+ </Text>
243
+ </View>
244
+ :<></>}
245
+ </View>
246
+
247
+ : active_view == 'verify' && verify_strategy_identifier ?
248
+
249
+ <View nativeID="sign_up" style={{ flex:1 }}>
250
+ <View style={{ flex:1, justifyContent:'center', alignItems:'center', padding:20 }}>
251
+ <Text size={18} color={Colors.brand.midnight} weight='semibold' textAlign="center">{verify_strategy_identifier.verify_label??'Enter Verification Code'}</Text>
252
+ <View style={{ padding:10 }}>
253
+ <TextInput
254
+ style={{ textAlign:'center', fontFamily:'barlow-bold', fontSize:14, padding:12, borderRadius:8, borderWidth:1, borderColor:Colors.shades.shade600 }}
255
+ value={token}
256
+ keyboardType='default'
257
+ autoFocus
258
+ textContentType={verify_strategy_identifier.secure_text_entry ? undefined : 'oneTimeCode'}
259
+ secureTextEntry={verify_strategy_identifier.secure_text_entry}
260
+ placeholderTextColor={Colors.brand.slate}
261
+ onChangeText={(text) => {
262
+ setToken(text);
263
+ }}
264
+ />
265
+ </View>
266
+ {verify_error ?
267
+ <Text style={{ marginTop:10 }} size={14} color={Colors.utility.warning}>{verify_error}</Text>
268
+ :<></>}
269
+ </View>
270
+ <View nativeID="action_row" style={{ flexDirection:'row', padding:10, paddingLeft:20, paddingRight:20 }}>
271
+ <Button
272
+ title={verify_attempt_allowed? 'Verify': 'Retry in 10 seconds'}
273
+ loading={action_loading}
274
+ style={{ flex:3, opacity:token&&verify_attempt_allowed?1:0.5 }}
275
+ disabled={!token || action_loading || !verify_attempt_allowed}
276
+ title_color={Colors.shades.white}
277
+ backgroundColor={Colors.utility.success}
278
+ borderRadius={8}
279
+ padding={15}
280
+ onPress={() => {
281
+ verifyAuthStrategyIdentifier()
282
+ }}
283
+ />
284
+ </View>
285
+ </View>
286
+
287
+ :<></>}
288
+ </View>
289
+ )
290
+ }
291
+
292
+ export default StrategyForm