@boneframework/native-components 1.0.35 → 1.0.37

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.
@@ -8,7 +8,7 @@ function ActivityIndicator({ visible = false , type="default", animationSource})
8
8
  const defaultStyles = useStyle();
9
9
 
10
10
  if (!animationSource) {
11
- animationSource = '../../../../assets/animations/loader.json'
11
+ animationSource = require('../../../../assets/animations/loader.json');
12
12
  }
13
13
 
14
14
  const styles = StyleSheet.create({
@@ -33,7 +33,7 @@ function Image({style, uri, onPress, handleError = error => console.error, sourc
33
33
  imageSource = source;
34
34
  }
35
35
 
36
- if ((null !== user.authToken.accessToken && protectedUri == true) || protectedUri == false) {
36
+ if ((null !== user?.authToken?.accessToken && protectedUri == true) || protectedUri == false) {
37
37
  return (
38
38
  <ExpoImage
39
39
  source={imageSource}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boneframework/native-components",
3
- "version": "1.0.35",
3
+ "version": "1.0.37",
4
4
  "description": "Expo Components for Bone Framework",
5
5
  "main": "src/Bone.ts",
6
6
  "scripts": {
@@ -1,41 +1,39 @@
1
- import {Image, ImageBackground, Keyboard, StyleSheet, View} from "react-native";
2
- import * as Linking from 'expo-linking';
1
+ import {ImageBackground, Keyboard, StyleSheet, View} from "react-native";
2
+ import {router, useGlobalSearchParams} from 'expo-router';
3
3
  import React, {useEffect, useState} from "react";
4
- import * as Yup from 'yup'
5
4
 
6
- import Button from '../components/Button';
7
- import CheckEmailScreen from '../screens/CheckEmailScreen';
8
- import Text from '../components/Text';
9
5
  import ActivityIndicator from "../components/ActivityIndicator";
10
- import Animation from "../components/Animation";
11
6
  import {ErrorMessage, Form, FormField, SubmitButton} from "../components/forms";
12
7
  import ResendActivationScreen from "../screens/ResendActivationlScreen";
13
8
  import SetPasswordScreen from "../screens/SetPasswordScreen";
14
9
  import useApi from "../hooks/useApi";
15
10
  import useAuth from "../hooks/useAuth";
16
- import useLinking from "../hooks/useLinking";
17
11
  import userApi from "../api/users";
18
12
 
19
13
  import settings from "../../../../config/settings";
20
14
  import routes from "../../../../config/routes";
21
- import colors from '../../../../config/colors';
22
15
 
23
- function ActivateUserScreen({navigation, route}) {
16
+ function ActivateUserScreen() {
17
+ const STATUS_BEGIN = 'start_validating';
24
18
  const STATUS_VALIDATE = 'validate_email_token';
25
19
  const STATUS_RESEND = 'resend_email_token';
26
20
  const STATUS_SET_PASSWORD = 'set_password';
21
+
27
22
  const activationApi = useApi(userApi.activateAccount);
28
23
  const resendActivationApi = useApi(userApi.resendactivationEmail);
29
24
  const validateEmailTokenApi = useApi(userApi.validateEmailToken);
30
- const [status, setStatus] = useState(STATUS_VALIDATE);
25
+
26
+ const [status, setStatus] = useState(STATUS_BEGIN);
31
27
  const [error, setError] = useState();
32
28
  const [tokenError, setTokenError] = useState();
29
+
33
30
  const {login} = useAuth();
34
- const url = Linking.useURL();
35
- const email = route.params.email;
36
- const token = route.params.token;
31
+ const params = useGlobalSearchParams();
32
+ const email = params.email;
33
+ const token = params.token;
37
34
 
38
35
  const validateEmailToken = async () => {
36
+ setStatus(STATUS_VALIDATE);
39
37
  const result = await validateEmailTokenApi.request(email, token);
40
38
 
41
39
  if (result.data.ok) {
@@ -53,6 +51,15 @@ function ActivateUserScreen({navigation, route}) {
53
51
  }
54
52
  }
55
53
 
54
+ const convertResponse = (data) => {
55
+ return {
56
+ accessToken: data.access_token,
57
+ expiresIn: data.expires_in,
58
+ refreshToken: data.refresh_token,
59
+ tokenType: data.token_type,
60
+ }
61
+ }
62
+
56
63
  const handleSubmit = async userInfo => {
57
64
  Keyboard.dismiss();
58
65
  try {
@@ -76,7 +83,7 @@ function ActivateUserScreen({navigation, route}) {
76
83
  return;
77
84
  }
78
85
 
79
- login({accessToken: result.data.access_token, refreshToken: result.data.refresh_token});
86
+ login(convertResponse(result.data)).then(router.navigate(routes.HOME));
80
87
  } catch (error) {
81
88
  setError(error);
82
89
  console.error(error);
@@ -88,13 +95,13 @@ function ActivateUserScreen({navigation, route}) {
88
95
  resendActivationApi
89
96
  .request(email)
90
97
  .then(setStatus(STATUS_VALIDATE))
91
- .then(navigation.goBack())
92
- .then(navigation.navigate(routes.USER_ACTIVATION_CHECK_EMAIL))
98
+ .then(router.back())
99
+ .then(router.navigate(routes.USER_ACTIVATION_CHECK_EMAIL))
93
100
  .catch(console.error);
94
101
  }
95
102
 
96
103
  useEffect(() => {
97
- if (status === STATUS_VALIDATE) {
104
+ if (status === STATUS_BEGIN) {
98
105
  validateEmailToken();
99
106
  }
100
107
  });