From 9b9e3d07d502ec8152786c34d179ff2b3670c492 Mon Sep 17 00:00:00 2001 From: zrwusa Date: Fri, 5 Nov 2021 18:09:03 +0800 Subject: [PATCH] circle dependencies issue solved, support bunny auth in UI --- package.json | 2 +- src/App.tsx | 23 +++--- src/components/AudioPlayer/AudioPlayer.tsx | 4 +- src/components/AudioPlayer/styles.tsx | 2 +- .../AudioRecorder/AudioRecorder.tsx | 2 +- src/components/AudioRecorder/styles.tsx | 2 +- src/components/Avatar/Avatar.tsx | 2 +- src/components/Avatar/styles.tsx | 2 +- src/components/BLToast/BLToast.tsx | 2 +- src/components/BunnyChat/Actions.tsx | 2 +- src/components/BunnyChat/Bubble.tsx | 2 +- src/components/BunnyChat/BunnyAvatar.tsx | 2 +- src/components/BunnyChat/BunnyChat.tsx | 2 +- src/components/BunnyChat/ChatAvatar.tsx | 2 +- src/components/BunnyChat/Composer.tsx | 2 +- src/components/BunnyChat/Day.tsx | 2 +- src/components/BunnyChat/InputToolbar.tsx | 2 +- src/components/BunnyChat/LoadEarlier.tsx | 2 +- src/components/BunnyChat/Message.tsx | 2 +- src/components/BunnyChat/MessageAudio.tsx | 2 +- src/components/BunnyChat/MessageContainer.tsx | 2 +- src/components/BunnyChat/MessageImage.tsx | 2 +- src/components/BunnyChat/MessageSticker.tsx | 2 +- src/components/BunnyChat/MessageText.tsx | 2 +- src/components/BunnyChat/MessageVideo.tsx | 2 +- src/components/BunnyChat/QuickReplies.tsx | 2 +- src/components/BunnyChat/Send.tsx | 2 +- src/components/BunnyChat/SystemMessage.tsx | 2 +- src/components/BunnyChat/Time.tsx | 2 +- src/components/BunnyChat/TypingIndicator.tsx | 2 +- src/components/CachedImage/CachedImage.tsx | 4 +- .../ColorValuesCard/ColorValuesCard.tsx | 5 +- src/components/CopyableText/CopyableText.tsx | 2 +- src/components/DemoCCClock/DemoCCClock.tsx | 4 +- src/components/DemoLazy/DemoLazy.tsx | 2 +- .../DemoLazyLoading/DemoLazyLoading.tsx | 2 +- .../DemoPureComponent/DemoPureComponent.tsx | 3 +- .../DemoRegularComponent.tsx | 3 +- src/components/DemoRequest/DemoRequest.tsx | 6 +- src/components/DemoSvg/DemoSvg.tsx | 3 +- src/components/DemoSvg/styles.ts | 2 +- src/components/Divider/Divider.tsx | 2 +- src/components/Divider/styles.tsx | 2 +- .../FirebasePhoneLogin/FirebasePhoneLogin.tsx | 16 ++-- .../FollowUpSearchBar/FollowUpSearchBar.tsx | 2 +- .../ForgotPassword/ForgotPassword.tsx | 15 ++-- .../GraduatePicker/GraduatePicker.tsx | 5 +- src/components/HeightPicker/HeightPicker.tsx | 5 +- .../ImageUploader/ImageUploader.tsx | 4 +- src/components/InlineJump/InlineJump.tsx | 4 +- .../InlineSelector/InlineSelector.tsx | 5 +- .../InterestPicker/InterestPicker.tsx | 5 +- .../LinearGradientIcon/LinearGradientIcon.tsx | 2 +- .../LinearGradientIcon.web.tsx | 2 +- src/components/LoginVector/LoginVector.tsx | 22 ++--- src/components/Masonry/Masonry.tsx | 2 +- src/components/NotSupport/NotSupport.tsx | 2 +- src/components/ReadMore/ReadMore.tsx | 2 +- .../RequestLoading/RequestLoading.tsx | 2 +- .../SocialMediaVideoCard.tsx | 2 +- src/components/SpousePicker/SpousePicker.tsx | 5 +- .../StickerPicker/StickerPicker.tsx | 2 +- src/components/StickerPicker/styles.tsx | 2 +- src/components/Sys/Sys.tsx | 4 +- src/components/Tab/Tab.tsx | 6 +- src/components/ThemePicker/ThemePicker.tsx | 2 +- src/components/ThemeSwitch/ThemeSwitch.tsx | 2 +- .../TreeNodePicker/TreeNodePicker.tsx | 5 +- src/components/UI/ImageProgressive.tsx | 2 +- src/components/UI/themed.tsx | 10 ++- .../UserAlbumEditor/UserAlbumEditor.tsx | 6 +- src/components/Video/Video.tsx | 2 +- .../VividAlgorithm/VividAlgorithm.tsx | 6 +- src/constants/constants.ts | 80 ++++--------------- src/containers/Card/Card.tsx | 3 +- src/containers/Col/styles.tsx | 2 +- src/containers/DraggableView/styles.tsx | 2 +- src/containers/InputCard/InputCard.tsx | 3 +- .../ModalFromBottom/ModalFromBottom.tsx | 2 +- .../ModalFromRight/ModalFromRight.tsx | 2 +- src/containers/Row/Row.tsx | 3 +- src/containers/Row/styles.ts | 2 +- src/helpers/auth-api.ts | 14 ++-- src/helpers/bunny-api.ts | 32 ++++---- src/helpers/helpers.ts | 62 ++++++++++---- src/helpers/nomics-api.ts | 40 +++++----- src/hooks/bunny-kit/useBunnyKit.tsx | 4 +- src/hooks/index.tsx | 3 - .../NavigatorTree/NavigatorTree.tsx | 6 +- src/navigation/NavigatorTree/styles.ts | 2 +- src/providers/auth-labor/AuthLaborContext.tsx | 67 +++++++++------- .../auth-labor/AuthLaborProvider.tsx | 2 +- .../i18n-labor/I18nLaborProvider.tsx | 2 +- src/providers/index.tsx | 5 -- .../request-labor/RequestProvider.tsx | 2 +- src/providers/request-labor/useRequest.tsx | 2 +- src/providers/size-labor/withSizeLabor.tsx | 2 - .../theme-labor/ThemeLaborProvider.tsx | 6 +- src/providers/theme-labor/theme.ts | 2 +- src/providers/theme-labor/victoryTheme.ts | 2 +- src/screens/Algorithm/Algorithm.tsx | 4 +- src/screens/Auth/Auth.tsx | 27 +++++-- src/screens/Auth/Login.tsx | 25 +++--- src/screens/Auth/SignUp.tsx | 22 ++--- src/screens/Auth/styles.ts | 3 + src/screens/ColorFinder/ColorFinder.tsx | 4 +- src/screens/DemoChat/ChatRoom/ChatRoom.tsx | 9 ++- src/screens/DemoChat/Home/ChatHome.tsx | 9 ++- src/screens/DemoCollection/DemoCollection.tsx | 8 +- .../DemoCryptoCurrency/Alert/Alert.tsx | 10 +-- src/screens/DemoCryptoCurrency/Home/Home.tsx | 12 +-- src/screens/DemoDating/Home/CardItem.tsx | 2 +- src/screens/DemoDating/Home/Home.tsx | 4 +- src/screens/DemoDating/Settings/Settings.tsx | 2 +- src/screens/DemoDrawer/Home/Home.tsx | 4 +- src/screens/DemoDrawer/Settings/Settings.tsx | 4 +- .../DemoFCReduxHook/DemoFCReduxHook.tsx | 4 +- .../Home/BodyPartCard/BodyPartCard.tsx | 2 +- .../BodyPartChartCard/BodyPartChartCard.tsx | 4 +- src/screens/DemoHealth/Home/Home.tsx | 4 +- src/screens/DemoHealth/Settings/Settings.tsx | 9 ++- src/screens/DemoMap/DemoMap.tsx | 10 +-- src/screens/DemoModal/Home/ModalHome.tsx | 4 +- .../NestedLv1Home/NestedLv1Home.tsx | 4 +- .../NestedLv2Home/NestedLv2Home.tsx | 4 +- .../NestedLv2Settings/NestedLv2Settings.tsx | 4 +- .../DemoNotification/DemoNotification.tsx | 4 +- .../DemoRNComponents/RNFlatList/FlatList.tsx | 2 +- .../DemoRNComponents/RNHome/RNHome.tsx | 4 +- .../RNKeyboardAvoiding/KeyboardAvoiding.tsx | 2 +- .../DemoRNComponents/RNSafeArea/SafeArea.tsx | 2 +- .../RNSectionList/SectionList.tsx | 2 +- .../RNVirtualizedList/RNVirtualizedList.tsx | 4 +- src/screens/DemoRoute/DemoRoute.tsx | 4 +- src/screens/DemoSaga/DemoSaga.tsx | 2 +- .../DemoSagaFirebase/DemoSagaFirebase.tsx | 4 +- src/screens/DemoSearch/DemoSearch.tsx | 6 +- src/screens/DemoShare/DemoShare.tsx | 12 +-- src/screens/DemoSocialMedia/Home/Home.tsx | 2 +- src/screens/DemoSocialMedia/Search/Search.tsx | 6 +- .../DemoSocialMedia/Settings/Settings.tsx | 4 +- src/screens/DemoSuspense/DemoSuspense.tsx | 4 +- src/screens/DemoTab/Home/Home.tsx | 4 +- src/screens/DemoTab/Settings/Settings.tsx | 4 +- src/screens/DemoTheme/DemoTheme.tsx | 4 +- src/screens/DemoThirdPart/DemoThirdPart.tsx | 4 +- src/screens/DemoThunkCC/DemoThunkCC.tsx | 4 +- src/screens/Home/Home.tsx | 14 ++-- src/screens/IconTools/IconTools.tsx | 4 +- src/screens/Playground/Playground.tsx | 5 +- src/screens/Profile/Profile.tsx | 6 +- src/screens/Settings/Item/Item.tsx | 3 +- src/screens/Settings/Settings.tsx | 4 +- src/store/actions/demo-map.ts | 14 ++-- src/store/actions/demo-thunk.ts | 14 ++-- src/store/actions/sys.ts | 34 ++++---- src/store/index.ts | 2 +- src/store/reducers/sys.ts | 2 +- src/store/sagas/sagas.ts | 40 +++++----- src/types/actions.ts | 69 +++++++++++++++- src/types/payloads.ts | 4 +- yarn.lock | 5 -- 162 files changed, 616 insertions(+), 514 deletions(-) delete mode 100644 src/hooks/index.tsx delete mode 100644 src/providers/index.tsx diff --git a/package.json b/package.json index 4eb80cc8..58df2de7 100644 --- a/package.json +++ b/package.json @@ -94,7 +94,7 @@ "react-native-picker-select": "^8.0.4", "react-native-reanimated": "^2.1.0", "react-native-responsive-screen": "^1.4.2", - "react-native-safe-area-context": "^3.2.0", + "react-native-safe-area-context": "3.2.0", "react-native-screens": "~3.0.0", "react-native-snap-carousel": "^3.9.1", "react-native-svg": "12.1.0", diff --git a/src/App.tsx b/src/App.tsx index f7626104..25a83648 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,20 +6,17 @@ import {AppearanceProvider} from 'react-native-appearance'; import {Theme as ThemeNavigation} from '@react-navigation/native'; import BunnyConstants from './constants/constants'; import {RootState} from './types'; -import {restoreIsReady, restoreNavInitialState, sysError} from './store/actions'; -import { - AuthLaborProvider, - I18nLaborProvider, - RequestProvider, - SizeLaborProvider, - ThemeLaborContext, - ThemeLaborProvider -} from './providers'; -import {Preparing} from './components'; +import {collectSysError, restoreIsReady, restoreNavInitialState} from './store/actions'; +import {ThemeLaborContext, ThemeLaborProvider} from './providers/theme-labor'; +import {Preparing} from './components/Preparing'; import {useTranslation} from 'react-i18next'; +import {RequestProvider} from './providers/request-labor'; import {loadAsync} from 'expo-font'; import icoMoonFont from './assets/fonts/icomoon/fonts/icomoon.ttf'; +import {SizeLaborProvider} from './providers/size-labor'; import NavigatorTree from './navigation/NavigatorTree'; +import {AuthLaborProvider} from './providers/auth-labor'; +import {I18nLaborProvider} from './providers/i18n-labor'; import RequestLoading from './components/RequestLoading'; import BLToast from './components/BLToast'; import Sys from './components/Sys'; @@ -42,7 +39,7 @@ function App() { try { await loadAsync({IcoMoon: icoMoonFont}); } catch (err: any) { - dispatch(sysError(err.toString())); + dispatch(collectSysError(err.toString())); } finally { try { if (Platform.OS !== 'web') { @@ -53,14 +50,14 @@ function App() { } } } catch (err: any) { - dispatch(sysError(err.toString())); + dispatch(collectSysError(err.toString())); } finally { dispatch(restoreIsReady({isReady: true})); } } }; bootstrapAsync() - .catch((err) => dispatch(sysError(err.toString()))); + .catch((err) => dispatch(collectSysError(err.toString()))); return () => clearTimeout(mockPreparingTimer); }, []); diff --git a/src/components/AudioPlayer/AudioPlayer.tsx b/src/components/AudioPlayer/AudioPlayer.tsx index ec292992..68f45d23 100644 --- a/src/components/AudioPlayer/AudioPlayer.tsx +++ b/src/components/AudioPlayer/AudioPlayer.tsx @@ -6,7 +6,7 @@ import {AVPlaybackSource, AVPlaybackStatus} from '../../../packages/expo-av/src/ import {Audio} from '../../../packages/expo-av/src'; import {ProgressBar} from 'react-native-paper'; import {minuted} from '../../utils'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export interface AudioPlayerProps { source: AVPlaybackSource, @@ -58,7 +58,7 @@ export function AudioPlayer(props: AudioPlayerProps) { soundRef.current = sound; soundRef.current.setOnPlaybackStatusUpdate(setStatus); onLoadEnd?.(); - } catch (e) { + } catch (e: any) { isDebug && console.log(e.toString()); setError(e.toString()); onError?.(e); diff --git a/src/components/AudioPlayer/styles.tsx b/src/components/AudioPlayer/styles.tsx index ded2b87f..90b04462 100644 --- a/src/components/AudioPlayer/styles.tsx +++ b/src/components/AudioPlayer/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/AudioRecorder/AudioRecorder.tsx b/src/components/AudioRecorder/AudioRecorder.tsx index 0bfb8d7d..a6121c20 100644 --- a/src/components/AudioRecorder/AudioRecorder.tsx +++ b/src/components/AudioRecorder/AudioRecorder.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import {useEffect, useState} from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {IcoMoon} from '../UI'; import {Platform, TouchableHighlight, Vibration} from 'react-native'; import {Audio} from '../../../packages/expo-av/src'; diff --git a/src/components/AudioRecorder/styles.tsx b/src/components/AudioRecorder/styles.tsx index 9a5a9c4a..b5291d99 100644 --- a/src/components/AudioRecorder/styles.tsx +++ b/src/components/AudioRecorder/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/Avatar/Avatar.tsx b/src/components/Avatar/Avatar.tsx index 6fde0793..573e64ed 100644 --- a/src/components/Avatar/Avatar.tsx +++ b/src/components/Avatar/Avatar.tsx @@ -3,7 +3,7 @@ import {Image, ImageSourcePropType, ImageStyle, ImageURISource, StyleProp} from import {getStyles} from './styles'; import {SizeKeys} from '../../types'; import {ImageUploader, ImageUploaderProps} from '../ImageUploader'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export interface AvatarProps { source: ImageSourcePropType, diff --git a/src/components/Avatar/styles.tsx b/src/components/Avatar/styles.tsx index 3990cf87..c6ad7286 100644 --- a/src/components/Avatar/styles.tsx +++ b/src/components/Avatar/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BLToast/BLToast.tsx b/src/components/BLToast/BLToast.tsx index fe5ce675..88c89646 100644 --- a/src/components/BLToast/BLToast.tsx +++ b/src/components/BLToast/BLToast.tsx @@ -5,7 +5,7 @@ import {getStyles} from './styles'; import {Snackbar} from 'react-native-paper'; import {Text, View} from '../UI'; import {setBLResult} from '../../store/actions'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; const BLToast = () => { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/components/BunnyChat/Actions.tsx b/src/components/BunnyChat/Actions.tsx index fc95df80..fc755727 100644 --- a/src/components/BunnyChat/Actions.tsx +++ b/src/components/BunnyChat/Actions.tsx @@ -1,6 +1,6 @@ import React, {ReactNode} from 'react'; import {StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewStyle,} from 'react-native'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {ActionSheetProps, connectActionSheet} from '../../../packages/react-native-action-sheet/src'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BunnyChat/Bubble.tsx b/src/components/BunnyChat/Bubble.tsx index f2161171..b4f60841 100644 --- a/src/components/BunnyChat/Bubble.tsx +++ b/src/components/BunnyChat/Bubble.tsx @@ -23,7 +23,7 @@ import Time, {TimeProps} from './Time'; import {isSameDay, isSameUser} from './utils'; import {IMessage, LeftRightStyle, PositionLeftOrRight, User,} from './types'; import MessageSticker, {MessageStickerProps} from './MessageSticker'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {ActionSheetProps, connectActionSheet} from '../../../packages/react-native-action-sheet/src'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BunnyChat/BunnyAvatar.tsx b/src/components/BunnyChat/BunnyAvatar.tsx index 11336e16..726c110e 100644 --- a/src/components/BunnyChat/BunnyAvatar.tsx +++ b/src/components/BunnyChat/BunnyAvatar.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {Image, ImageStyle, StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View,} from 'react-native'; import {User} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BunnyChat/BunnyChat.tsx b/src/components/BunnyChat/BunnyChat.tsx index 88ebac0f..1b69159c 100644 --- a/src/components/BunnyChat/BunnyChat.tsx +++ b/src/components/BunnyChat/BunnyChat.tsx @@ -36,7 +36,7 @@ import BunnyAvatar from './BunnyAvatar'; import {DATE_FORMAT, DEFAULT_PLACEHOLDER, MAX_COMPOSER_HEIGHT, MIN_COMPOSER_HEIGHT, TIME_FORMAT,} from './Constant'; import {IMessage,} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; dayjs.extend(localizedFormat); diff --git a/src/components/BunnyChat/ChatAvatar.tsx b/src/components/BunnyChat/ChatAvatar.tsx index 83714a9e..7be7304d 100644 --- a/src/components/BunnyChat/ChatAvatar.tsx +++ b/src/components/BunnyChat/ChatAvatar.tsx @@ -3,7 +3,7 @@ import {ImageStyle, StyleSheet, TextStyle, View, ViewStyle,} from 'react-native' import BunnyAvatar from './BunnyAvatar'; import {isSameDay, isSameUser} from './utils'; import {IMessage, LeftRightStyle, PositionLeftOrRight, User} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { diff --git a/src/components/BunnyChat/Composer.tsx b/src/components/BunnyChat/Composer.tsx index 9e703da4..e2fb41b4 100644 --- a/src/components/BunnyChat/Composer.tsx +++ b/src/components/BunnyChat/Composer.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {Platform, StyleSheet, TextInput, TextInputProps} from 'react-native'; import {DEFAULT_PLACEHOLDER, MIN_COMPOSER_HEIGHT} from './Constant'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { diff --git a/src/components/BunnyChat/Day.tsx b/src/components/BunnyChat/Day.tsx index 6bac6232..07b85611 100644 --- a/src/components/BunnyChat/Day.tsx +++ b/src/components/BunnyChat/Day.tsx @@ -5,7 +5,7 @@ import dayjs from 'dayjs'; import {isSameDay} from './utils'; import {DATE_FORMAT} from './Constant'; import {IMessage} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { diff --git a/src/components/BunnyChat/InputToolbar.tsx b/src/components/BunnyChat/InputToolbar.tsx index 3204eb4a..058c7a34 100644 --- a/src/components/BunnyChat/InputToolbar.tsx +++ b/src/components/BunnyChat/InputToolbar.tsx @@ -5,7 +5,7 @@ import Composer, {ComposerProps} from './Composer'; import Send, {SendProps} from './Send'; import Actions, {ActionsProps} from './Actions'; import {IMessage} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { diff --git a/src/components/BunnyChat/LoadEarlier.tsx b/src/components/BunnyChat/LoadEarlier.tsx index d74b801a..227260da 100644 --- a/src/components/BunnyChat/LoadEarlier.tsx +++ b/src/components/BunnyChat/LoadEarlier.tsx @@ -10,7 +10,7 @@ import { View, ViewStyle, } from 'react-native'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {ActivityIndicatorSize} from './types'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BunnyChat/Message.tsx b/src/components/BunnyChat/Message.tsx index 372d9ba0..69bda3ea 100644 --- a/src/components/BunnyChat/Message.tsx +++ b/src/components/BunnyChat/Message.tsx @@ -8,7 +8,7 @@ import Day, {DayProps} from './Day'; import {isSameUser} from './utils'; import {IMessage, LeftRightStyle, PositionLeftOrRight, User} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { diff --git a/src/components/BunnyChat/MessageAudio.tsx b/src/components/BunnyChat/MessageAudio.tsx index 02611aed..bc1b2c70 100644 --- a/src/components/BunnyChat/MessageAudio.tsx +++ b/src/components/BunnyChat/MessageAudio.tsx @@ -4,7 +4,7 @@ import {StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle} from 'react-nat import {IMessage, PositionLeftOrRight} from './types'; import {AudioPlayer, AudioPlayerProps} from '../AudioPlayer'; import {SizeLabor, ThemeLabor} from '../../types'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/MessageContainer.tsx b/src/components/BunnyChat/MessageContainer.tsx index ff2f63e3..4d63225f 100644 --- a/src/components/BunnyChat/MessageContainer.tsx +++ b/src/components/BunnyChat/MessageContainer.tsx @@ -20,7 +20,7 @@ import Message, {MessageProps} from './Message'; import {IMessage, PositionLeftOrRight, Reply, User} from './types'; import {warning} from './utils'; import TypingIndicator from './TypingIndicator'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { diff --git a/src/components/BunnyChat/MessageImage.tsx b/src/components/BunnyChat/MessageImage.tsx index 778fb9fe..cf2f9f72 100644 --- a/src/components/BunnyChat/MessageImage.tsx +++ b/src/components/BunnyChat/MessageImage.tsx @@ -3,7 +3,7 @@ import {Image, ImageProps, ImageStyle, StyleProp, StyleSheet, Text, View, ViewSt import {IMessage} from './types'; import LightBox from '../../../packages/react-native-lightbox'; import {SizeLabor, ThemeLabor} from '../../types'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/MessageSticker.tsx b/src/components/BunnyChat/MessageSticker.tsx index d9a8db4b..050f5662 100644 --- a/src/components/BunnyChat/MessageSticker.tsx +++ b/src/components/BunnyChat/MessageSticker.tsx @@ -3,7 +3,7 @@ import {Image, ImageProps, ImageStyle, StyleProp, StyleSheet, Text, View, ViewSt // TODO: support web import {IMessage} from './types'; import {SizeLabor, ThemeLabor} from '../../types'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/MessageText.tsx b/src/components/BunnyChat/MessageText.tsx index 0f1339cd..4d7179e8 100644 --- a/src/components/BunnyChat/MessageText.tsx +++ b/src/components/BunnyChat/MessageText.tsx @@ -3,7 +3,7 @@ import {Linking, StyleProp, StyleSheet, Text, TextProps, TextStyle, View, ViewSt import ParsedText from 'react-native-parsed-text'; import Communications from 'react-native-communications'; import {IMessage, LeftRightStyle, PositionLeftOrRight} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {ActionSheetProps, connectActionSheet} from '../../../packages/react-native-action-sheet/src'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BunnyChat/MessageVideo.tsx b/src/components/BunnyChat/MessageVideo.tsx index 7e05b82d..52f16f1a 100644 --- a/src/components/BunnyChat/MessageVideo.tsx +++ b/src/components/BunnyChat/MessageVideo.tsx @@ -4,7 +4,7 @@ import {StyleProp, StyleSheet, Text, View, ViewStyle} from 'react-native'; import {IMessage} from './types'; import {Video, VideoProps} from '../../../packages/expo-av/src'; import {SizeLabor, ThemeLabor} from '../../types'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/QuickReplies.tsx b/src/components/BunnyChat/QuickReplies.tsx index 0893443b..17967469 100644 --- a/src/components/BunnyChat/QuickReplies.tsx +++ b/src/components/BunnyChat/QuickReplies.tsx @@ -3,7 +3,7 @@ import {StyleProp, StyleSheet, Text, TouchableOpacity, View, ViewStyle,} from 'r import {IMessage, Reply} from './types'; import {warning} from './utils'; import {SizeLabor, ThemeLabor} from '../../types'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/Send.tsx b/src/components/BunnyChat/Send.tsx index fb6a5b71..89881265 100644 --- a/src/components/BunnyChat/Send.tsx +++ b/src/components/BunnyChat/Send.tsx @@ -11,7 +11,7 @@ import { } from 'react-native'; import {IMessage} from './types'; import {SizeLabor, ThemeLabor} from '../../types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/SystemMessage.tsx b/src/components/BunnyChat/SystemMessage.tsx index e3ab1cf7..2f20d0c7 100644 --- a/src/components/BunnyChat/SystemMessage.tsx +++ b/src/components/BunnyChat/SystemMessage.tsx @@ -2,7 +2,7 @@ import React, {Component} from 'react'; import {StyleProp, StyleSheet, Text, TextStyle, View, ViewStyle,} from 'react-native'; import {IMessage} from './types'; import {SizeLabor, ThemeLabor} from '../../types'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/BunnyChat/Time.tsx b/src/components/BunnyChat/Time.tsx index 247d31f4..ae09a0d7 100644 --- a/src/components/BunnyChat/Time.tsx +++ b/src/components/BunnyChat/Time.tsx @@ -3,7 +3,7 @@ import {StyleSheet, Text, TextStyle, View, ViewStyle} from 'react-native'; import dayjs from 'dayjs'; import {TIME_FORMAT} from './Constant'; import {IMessage, LeftRightStyle, PositionLeftOrRight} from './types'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/BunnyChat/TypingIndicator.tsx b/src/components/BunnyChat/TypingIndicator.tsx index 71846e4e..03a1471d 100644 --- a/src/components/BunnyChat/TypingIndicator.tsx +++ b/src/components/BunnyChat/TypingIndicator.tsx @@ -4,7 +4,7 @@ import {TypingAnimation} from 'react-native-typing-animation'; import {useUpdateLayoutEffect} from './hooks/useUpdateLayoutEffect'; import config from '../../config'; import {SizeLabor, ThemeLabor} from '../../types'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {wp} = sizeLabor.designsBasedOn.iphoneX; diff --git a/src/components/CachedImage/CachedImage.tsx b/src/components/CachedImage/CachedImage.tsx index 365d9891..08d3512f 100644 --- a/src/components/CachedImage/CachedImage.tsx +++ b/src/components/CachedImage/CachedImage.tsx @@ -54,8 +54,8 @@ export class CachedImage extends React.Component { }); - } catch (error) { - onError?.(error); + } catch (e: any) { + onError?.(e); } } } diff --git a/src/components/ColorValuesCard/ColorValuesCard.tsx b/src/components/ColorValuesCard/ColorValuesCard.tsx index 6292a1e7..72908bf8 100644 --- a/src/components/ColorValuesCard/ColorValuesCard.tsx +++ b/src/components/ColorValuesCard/ColorValuesCard.tsx @@ -3,8 +3,9 @@ import {Text, View} from '../UI'; import {CopyableText} from '../CopyableText'; import React from 'react'; import {getStyles} from './styles'; -import {Col, Row} from '../../containers'; -import {useBunnyKit} from '../../hooks'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export const ColorValuesCard = (props: { item: ColorDiffWithThemeColorsItem | ColorDiffWithPaletteItem | ColorInputItem }) => { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/components/CopyableText/CopyableText.tsx b/src/components/CopyableText/CopyableText.tsx index e0e9a462..6eee67e1 100644 --- a/src/components/CopyableText/CopyableText.tsx +++ b/src/components/CopyableText/CopyableText.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {Clipboard, TextProps, TouchableOpacity} from 'react-native'; import {collectBLResult} from '../../store/actions'; import {blSuccess} from '../../helpers'; -import {useThemeLabor} from '../../providers'; +import {useThemeLabor} from '../../providers/theme-labor'; import {Text} from '../UI'; import {useDispatch} from 'react-redux'; diff --git a/src/components/DemoCCClock/DemoCCClock.tsx b/src/components/DemoCCClock/DemoCCClock.tsx index 9f0a98a3..e77e591c 100644 --- a/src/components/DemoCCClock/DemoCCClock.tsx +++ b/src/components/DemoCCClock/DemoCCClock.tsx @@ -1,6 +1,6 @@ import React, {PureComponent} from 'react'; import {ButtonTO, InButtonText, Text, View} from '../UI'; -import {withSizeLabor, WithSizeLabor} from '../../providers/size-labor'; +import {WithSizeLabor, withSizeLabor} from '../../providers/size-labor'; interface Props extends WithSizeLabor { title: string, @@ -57,6 +57,4 @@ export class DemoCCClockInner extends PureComponent { } } -console.log('withSizeLabor', withSizeLabor); - export const DemoCCClock = withSizeLabor(DemoCCClockInner); diff --git a/src/components/DemoLazy/DemoLazy.tsx b/src/components/DemoLazy/DemoLazy.tsx index 46002684..7ec1f8fb 100644 --- a/src/components/DemoLazy/DemoLazy.tsx +++ b/src/components/DemoLazy/DemoLazy.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {Text, View} from '../UI'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; interface Props { title: string; diff --git a/src/components/DemoLazyLoading/DemoLazyLoading.tsx b/src/components/DemoLazyLoading/DemoLazyLoading.tsx index 91edd1a3..9c8374a1 100644 --- a/src/components/DemoLazyLoading/DemoLazyLoading.tsx +++ b/src/components/DemoLazyLoading/DemoLazyLoading.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {Text, View} from '../UI'; import {getStyles} from './styles'; import {ActivityIndicator} from 'react-native'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export function DemoLazyLoading() { const {sizeLabor, themeLabor, t, wp} = useBunnyKit(); diff --git a/src/components/DemoPureComponent/DemoPureComponent.tsx b/src/components/DemoPureComponent/DemoPureComponent.tsx index c43d11a4..c8070cc1 100644 --- a/src/components/DemoPureComponent/DemoPureComponent.tsx +++ b/src/components/DemoPureComponent/DemoPureComponent.tsx @@ -1,7 +1,8 @@ import React, {PureComponent} from 'react'; import {Text, View} from '../UI'; import {getStyles} from './styles'; -import {SizeLaborContext, ThemeLaborContext} from '../../providers'; +import {SizeLaborContext} from '../../providers/size-labor'; +import {ThemeLaborContext} from '../../providers/theme-labor'; interface Props { title?: string, diff --git a/src/components/DemoPureComponent/DemoRegularComponent.tsx b/src/components/DemoPureComponent/DemoRegularComponent.tsx index a1be69a5..c40ecc16 100644 --- a/src/components/DemoPureComponent/DemoRegularComponent.tsx +++ b/src/components/DemoPureComponent/DemoRegularComponent.tsx @@ -1,7 +1,8 @@ import React, {Component} from 'react'; import {Text, View} from '../UI'; import {getStyles} from './styles'; -import {SizeLaborContext, ThemeLaborContext} from '../../providers'; +import {SizeLaborContext} from '../../providers/size-labor'; +import {ThemeLaborContext} from '../../providers/theme-labor'; type Props = { title?: string, labelBeenRendered?: string, labelRenderedUnit?: string } diff --git a/src/components/DemoRequest/DemoRequest.tsx b/src/components/DemoRequest/DemoRequest.tsx index 86f3ace8..20f2058a 100644 --- a/src/components/DemoRequest/DemoRequest.tsx +++ b/src/components/DemoRequest/DemoRequest.tsx @@ -1,9 +1,9 @@ import React, {useState} from 'react'; import {ButtonTO, InButtonText, Text, View} from '../UI'; import {DemoEmployee} from '../../types'; -import {useRequest} from '../../providers'; +import {useRequest} from '../../providers/request-labor'; import {useDispatch} from 'react-redux'; -import {saveQuickAlertSettings, sysError} from '../../store/actions'; +import {collectSysError, saveQuickAlertSettings} from '../../store/actions'; import {bunnyAPI} from '../../helpers/bunny-api'; interface Props { @@ -68,7 +68,7 @@ function DemoRequest(props: Props) { // return {x: new Date(item), y: parseFloat(parseFloat(prices[index]).toFixed(2))} // }) } catch (err: any) { - dispatch(sysError(err.toString())); + dispatch(collectSysError(err.toString())); } }; diff --git a/src/components/DemoSvg/DemoSvg.tsx b/src/components/DemoSvg/DemoSvg.tsx index 4883a51e..36c5af5e 100644 --- a/src/components/DemoSvg/DemoSvg.tsx +++ b/src/components/DemoSvg/DemoSvg.tsx @@ -5,7 +5,8 @@ import Svg, {Circle, Rect, SvgUri} from 'react-native-svg'; import SVGR from './SVGR'; // import SvgLocalFileXML from "./SvgLocalFileXML" import {Platform} from 'react-native'; -import {useSizeLabor, useThemeLabor} from '../../providers'; +import {useThemeLabor} from '../../providers/theme-labor'; +import {useSizeLabor} from '../../providers/size-labor'; export const DemoSvg = () => { const sizeLabor = useSizeLabor(); diff --git a/src/components/DemoSvg/styles.ts b/src/components/DemoSvg/styles.ts index f9eaa42d..06725842 100644 --- a/src/components/DemoSvg/styles.ts +++ b/src/components/DemoSvg/styles.ts @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {SizeLabor, ThemeLabor} from '../../types'; +import {SizeLabor, ThemeLabor} from '../../types/styles'; export const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { const {ms, designsBasedOn} = sizeLabor; diff --git a/src/components/Divider/Divider.tsx b/src/components/Divider/Divider.tsx index c7b9705b..d2d45998 100644 --- a/src/components/Divider/Divider.tsx +++ b/src/components/Divider/Divider.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {StyleProp, View, ViewStyle} from 'react-native'; import {getStyles} from './styles'; import {SizeKeys} from '../../types'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export interface DividerProps { isVertical?: boolean, diff --git a/src/components/Divider/styles.tsx b/src/components/Divider/styles.tsx index 757a1951..db994821 100644 --- a/src/components/Divider/styles.tsx +++ b/src/components/Divider/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/FirebasePhoneLogin/FirebasePhoneLogin.tsx b/src/components/FirebasePhoneLogin/FirebasePhoneLogin.tsx index 3fe70371..b67434e0 100644 --- a/src/components/FirebasePhoneLogin/FirebasePhoneLogin.tsx +++ b/src/components/FirebasePhoneLogin/FirebasePhoneLogin.tsx @@ -1,19 +1,21 @@ import {ActivityIndicator, TextInput, View} from 'react-native'; import * as React from 'react'; -import {InputCard, Row} from '../../containers'; +import {InputCard} from '../../containers/InputCard'; import {InButtonText, LinearGradientButton, Text, TextInputIcon} from '../UI'; import {LinearGradientIcon} from '../LinearGradientIcon'; +import {Row} from '../../containers/Row'; import * as FirebaseRecaptcha from 'expo-firebase-recaptcha'; import {FIREBASE_CONFIG} from '../../firebase'; -import {shortenTFunctionKey, useAuthLabor} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getStyles} from './styles'; +import {useAuthLabor} from '../../providers/auth-labor'; import {RouteProp} from '@react-navigation/native'; import {AuthTopStackParam, RootStackParam} from '../../types'; import {StackNavigationProp} from '@react-navigation/stack'; import {useDispatch} from 'react-redux'; import {collectBLResult} from '../../store/actions'; import {navToReference} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type FirebasePhoneLoginRouteProp = RouteProp; type FirebasePhoneLoginNavigationProp = StackNavigationProp; @@ -57,8 +59,8 @@ export const FirebasePhoneLogin = ({route, navigation}: FirebasePhoneLoginProps) } else { dispatch(collectBLResult(result)); } - } catch ({message}) { - setVerifyError(message); + } catch (e: any) { + setVerifyError(e.message); setVerifyInProgress(false); } }; @@ -76,8 +78,8 @@ export const FirebasePhoneLogin = ({route, navigation}: FirebasePhoneLoginProps) } else { dispatch(collectBLResult(result)); } - } catch ({message}) { - setConfirmError(message); + } catch (e: any) { + setConfirmError(e.message); setConfirmInProgress(false); } }; diff --git a/src/components/FollowUpSearchBar/FollowUpSearchBar.tsx b/src/components/FollowUpSearchBar/FollowUpSearchBar.tsx index ef8af459..c8f0a58c 100644 --- a/src/components/FollowUpSearchBar/FollowUpSearchBar.tsx +++ b/src/components/FollowUpSearchBar/FollowUpSearchBar.tsx @@ -2,7 +2,7 @@ import React, {useEffect, useRef, useState} from 'react'; import {Animated, Keyboard, NativeSyntheticEvent, SafeAreaView, TextInputKeyPressEventData} from 'react-native'; import {getStyles} from './styles'; import {IcoMoon, Text, TextInput, TouchableOpacity, View} from '../UI'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; interface SearchComponentProps { scrollYValue: Animated.Value, diff --git a/src/components/ForgotPassword/ForgotPassword.tsx b/src/components/ForgotPassword/ForgotPassword.tsx index 38a02545..97108184 100644 --- a/src/components/ForgotPassword/ForgotPassword.tsx +++ b/src/components/ForgotPassword/ForgotPassword.tsx @@ -1,17 +1,20 @@ import {InButtonText, LinearGradientButton, Text, TextButton, TextInputIcon, View} from '../UI'; import * as React from 'react'; import {useState} from 'react'; -import {Col, InputCard, Row} from '../../containers'; -import {collectBLResult, sysError} from '../../store/actions'; -import {shortenTFunctionKey, useAuthLabor} from '../../providers'; +import {Row} from '../../containers/Row'; +import {collectBLResult, collectSysError} from '../../store/actions'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getStyles} from './styles'; +import {useAuthLabor} from '../../providers/auth-labor'; import {useDispatch} from 'react-redux'; import {RouteProp} from '@react-navigation/native'; import {AuthTopStackParam, RootStackParam} from '../../types'; import {StackNavigationProp} from '@react-navigation/stack'; +import {InputCard} from '../../containers/InputCard'; import {LinearGradientIcon} from '../LinearGradientIcon'; import {blError} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {Col} from '../../containers/Col'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type ForgotPasswordRouteProp = RouteProp | RouteProp; type ForgotPasswordNavigationProp = StackNavigationProp; @@ -66,8 +69,8 @@ export const ForgotPassword = ({route, navigation, onSent, onCancel, email}: For dispatch(collectBLResult(blError('Please enter email'))); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }; diff --git a/src/components/GraduatePicker/GraduatePicker.tsx b/src/components/GraduatePicker/GraduatePicker.tsx index 10bdb444..134fadc2 100644 --- a/src/components/GraduatePicker/GraduatePicker.tsx +++ b/src/components/GraduatePicker/GraduatePicker.tsx @@ -1,8 +1,9 @@ import {ButtonTO, IcoMoon, InButtonText, Text, TextButton, View} from '../UI'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import * as React from 'react'; import {useState} from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getSharedStyles} from '../../helpers'; import {getStyles} from './styles'; diff --git a/src/components/HeightPicker/HeightPicker.tsx b/src/components/HeightPicker/HeightPicker.tsx index 8d33e209..d3f4d55e 100644 --- a/src/components/HeightPicker/HeightPicker.tsx +++ b/src/components/HeightPicker/HeightPicker.tsx @@ -1,8 +1,9 @@ import {ButtonTO, IcoMoon, InButtonText, Text, TextButton, View} from '../UI'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import * as React from 'react'; import {useState} from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getSharedStyles} from '../../helpers'; import {getStyles} from './styles'; diff --git a/src/components/ImageUploader/ImageUploader.tsx b/src/components/ImageUploader/ImageUploader.tsx index b819b977..29786703 100644 --- a/src/components/ImageUploader/ImageUploader.tsx +++ b/src/components/ImageUploader/ImageUploader.tsx @@ -27,7 +27,7 @@ import Modal, {ModalProps} from 'react-native-modal'; import {Divider} from '../Divider'; import {CopyableText} from '../CopyableText'; import {IcoMoonKeys} from '../../types'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; // import ViewShot,{captureRef} from "react-native-view-shot"; export type UploadedResult = { uri: string } export type RenderPreview = (props: { imageSource: ImageURISource, toggleModal: () => void }) => React.ReactElement | null; @@ -209,7 +209,7 @@ export function ImageUploader(props: ImageUploaderProps) { setImage({uri: uploadUrl}); onValueChanged && onValueChanged({uri: uploadUrl}); } - } catch (e) { + } catch (e: any) { _errorHandle(e); } finally { setIsUploading(false); diff --git a/src/components/InlineJump/InlineJump.tsx b/src/components/InlineJump/InlineJump.tsx index a732695d..eadd75a9 100644 --- a/src/components/InlineJump/InlineJump.tsx +++ b/src/components/InlineJump/InlineJump.tsx @@ -1,13 +1,13 @@ import {useLinkTo} from '@react-navigation/native'; import {Col, getContainerStyles, Row} from '../../containers'; -import {useAuthLabor} from '../../providers'; +import {useAuthLabor} from '../../providers/auth-labor'; import {IcoMoon, Link, Text} from '../UI'; import {LinearGradientIcon} from '../LinearGradientIcon'; import {TouchableOpacity} from 'react-native'; import * as React from 'react'; import {IcoMoonKeys} from '../../types'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export interface LineToProps { iconName?: IcoMoonKeys, diff --git a/src/components/InlineSelector/InlineSelector.tsx b/src/components/InlineSelector/InlineSelector.tsx index adea1ea9..82b04d72 100644 --- a/src/components/InlineSelector/InlineSelector.tsx +++ b/src/components/InlineSelector/InlineSelector.tsx @@ -1,7 +1,8 @@ import {FlexAlignType, GestureResponderEvent, StyleProp, TextStyle, TouchableOpacity} from 'react-native'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getSharedStyles} from '../../helpers'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import {IcoMoon, Text} from '../UI'; import * as React from 'react'; diff --git a/src/components/InterestPicker/InterestPicker.tsx b/src/components/InterestPicker/InterestPicker.tsx index 62096cbf..160bfd86 100644 --- a/src/components/InterestPicker/InterestPicker.tsx +++ b/src/components/InterestPicker/InterestPicker.tsx @@ -1,8 +1,9 @@ import {ButtonTO, IcoMoon, InButtonText, Text, TextButton, View} from '../UI'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import * as React from 'react'; import {useEffect, useState} from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getSharedStyles} from '../../helpers'; import {getStyles} from './styles'; import Modal from 'react-native-modal'; diff --git a/src/components/LinearGradientIcon/LinearGradientIcon.tsx b/src/components/LinearGradientIcon/LinearGradientIcon.tsx index 45893457..3b3b3d16 100644 --- a/src/components/LinearGradientIcon/LinearGradientIcon.tsx +++ b/src/components/LinearGradientIcon/LinearGradientIcon.tsx @@ -5,7 +5,7 @@ import {LinearGradient, LinearGradientProps} from 'expo-linear-gradient'; import {getStyles} from './styles'; import {IcoMoonProps} from '../../types'; import {StyleProp, TextStyle} from 'react-native'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export type LinearGradientIconProps = IcoMoonProps & Omit & { colors?: string[], diff --git a/src/components/LinearGradientIcon/LinearGradientIcon.web.tsx b/src/components/LinearGradientIcon/LinearGradientIcon.web.tsx index c5f36c43..1c6b52c9 100644 --- a/src/components/LinearGradientIcon/LinearGradientIcon.web.tsx +++ b/src/components/LinearGradientIcon/LinearGradientIcon.web.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {getStyles} from './styles'; import {IcoMoon} from '../UI'; import {LinearGradientIconProps} from './LinearGradientIcon'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export function LinearGradientIcon(props: LinearGradientIconProps) { const {sizeLabor, themeLabor, wp} = useBunnyKit(); diff --git a/src/components/LoginVector/LoginVector.tsx b/src/components/LoginVector/LoginVector.tsx index 77bd7ebc..7ac01e2b 100644 --- a/src/components/LoginVector/LoginVector.tsx +++ b/src/components/LoginVector/LoginVector.tsx @@ -1,17 +1,19 @@ import {IcoMoon, Text, TextButton, View} from '../UI'; import * as React from 'react'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import {Divider} from '../Divider'; import {Keyboard, Platform} from 'react-native'; -import {collectBLResult, sysError} from '../../store/actions'; -import {shortenTFunctionKey, useAuthLabor} from '../../providers'; +import {collectBLResult, collectSysError} from '../../store/actions'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getStyles} from './styles'; +import {useAuthLabor} from '../../providers/auth-labor'; import {useDispatch} from 'react-redux'; import {RouteProp} from '@react-navigation/native'; import {AuthTopStackParam, RootStackParam} from '../../types'; import {StackNavigationProp} from '@react-navigation/stack'; import {navToReference} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type LoginVectorRouteProp = RouteProp | RouteProp; type LoginVectorNavigationProp = StackNavigationProp; @@ -48,8 +50,8 @@ export const LoginVector = ({route, navigation}: LoginVectorProps) => { try { await authFunctions.dummyLogin(); navToReference(route, navigation); - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }}> @@ -69,8 +71,8 @@ export const LoginVector = ({route, navigation}: LoginVectorProps) => { } else { dispatch(collectBLResult(result)); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }}> @@ -87,8 +89,8 @@ export const LoginVector = ({route, navigation}: LoginVectorProps) => { } else { dispatch(collectBLResult(result)); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }}> diff --git a/src/components/Masonry/Masonry.tsx b/src/components/Masonry/Masonry.tsx index 21364c04..26291ab3 100644 --- a/src/components/Masonry/Masonry.tsx +++ b/src/components/Masonry/Masonry.tsx @@ -4,7 +4,7 @@ import {ScaledImage} from '../ScalableImage/ScalableImage'; import {uuid4} from '@sentry/utils'; import {MasonryDatum, SocialMediaImageDatum} from '../../types'; import {getStyles} from './styles'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; export interface MasonryProps extends WithBunnyKit { diff --git a/src/components/NotSupport/NotSupport.tsx b/src/components/NotSupport/NotSupport.tsx index 26b1f24e..5847d6dc 100644 --- a/src/components/NotSupport/NotSupport.tsx +++ b/src/components/NotSupport/NotSupport.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {getStyles} from './styles'; import {Text, View} from 'react-native'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export interface NotSupportProps { text?: string | JSX.Element; diff --git a/src/components/ReadMore/ReadMore.tsx b/src/components/ReadMore/ReadMore.tsx index 0a3bd1d6..d238a51e 100644 --- a/src/components/ReadMore/ReadMore.tsx +++ b/src/components/ReadMore/ReadMore.tsx @@ -1,7 +1,7 @@ import React, {ReactNode} from 'react'; import {StyleProp, Text, TextStyle, View} from 'react-native'; import {getStyles} from './styles'; -import {withBunnyKit, WithBunnyKit} from '../../hooks'; +import {withBunnyKit, WithBunnyKit} from '../../hooks/bunny-kit'; interface ReadMoreProps extends WithBunnyKit { numberOfLines: number, diff --git a/src/components/RequestLoading/RequestLoading.tsx b/src/components/RequestLoading/RequestLoading.tsx index 0c70c0ab..95ae0aa2 100644 --- a/src/components/RequestLoading/RequestLoading.tsx +++ b/src/components/RequestLoading/RequestLoading.tsx @@ -4,7 +4,7 @@ import {useDispatch, useSelector} from 'react-redux'; import {RootState} from '../../types'; import {getStyles} from './styles'; import {ActivityIndicator} from 'react-native'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; const RequestLoading = () => { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/components/SocialMediaVideoCard/SocialMediaVideoCard.tsx b/src/components/SocialMediaVideoCard/SocialMediaVideoCard.tsx index 8502e80d..84a10d73 100644 --- a/src/components/SocialMediaVideoCard/SocialMediaVideoCard.tsx +++ b/src/components/SocialMediaVideoCard/SocialMediaVideoCard.tsx @@ -7,7 +7,7 @@ import {ShowVideo} from '../Video/Video'; import {ReadMore} from '../ReadMore'; import {SocialMediaMainDatum} from '../../types'; import {getStyles} from './styles'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; interface SocialMediaVideoCardProps extends WithBunnyKit { card: SocialMediaMainDatum; diff --git a/src/components/SpousePicker/SpousePicker.tsx b/src/components/SpousePicker/SpousePicker.tsx index 5fb5007f..9c5c6046 100644 --- a/src/components/SpousePicker/SpousePicker.tsx +++ b/src/components/SpousePicker/SpousePicker.tsx @@ -1,5 +1,6 @@ import {ButtonTO, IcoMoon, InButtonText, Text, TextButton, View} from '../UI'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import {Slider} from '../../../packages/react-native-range-slider-expo/src'; import {Divider} from '../Divider'; import {RadioButton} from 'react-native-paper'; @@ -8,7 +9,7 @@ import * as React from 'react'; import {useState} from 'react'; import _ from 'lodash'; import BunnyConstants from '../../constants/constants'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getSharedStyles} from '../../helpers'; import {getStyles} from './styles'; diff --git a/src/components/StickerPicker/StickerPicker.tsx b/src/components/StickerPicker/StickerPicker.tsx index 7d320c6b..204619ba 100644 --- a/src/components/StickerPicker/StickerPicker.tsx +++ b/src/components/StickerPicker/StickerPicker.tsx @@ -1,5 +1,5 @@ // TODO crash when large gif images loaded -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {ScrollView, TouchableOpacity, View} from 'react-native'; import React, {useEffect, useRef, useState} from 'react'; import {useKeyboardHeight} from '../../hooks/keyboard-height'; diff --git a/src/components/StickerPicker/styles.tsx b/src/components/StickerPicker/styles.tsx index 9b3e3f7b..9d9b9d17 100644 --- a/src/components/StickerPicker/styles.tsx +++ b/src/components/StickerPicker/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/components/Sys/Sys.tsx b/src/components/Sys/Sys.tsx index 592bef88..1e58aa45 100644 --- a/src/components/Sys/Sys.tsx +++ b/src/components/Sys/Sys.tsx @@ -4,8 +4,8 @@ import {useDispatch, useSelector} from 'react-redux'; import {RootState} from '../../types'; import {getStyles} from './styles'; import {sysClearErrors} from '../../store/actions'; -import {Row} from '../../containers'; -import {useBunnyKit} from '../../hooks'; +import {Row} from '../../containers/Row'; +import {useBunnyKit} from '../../hooks/bunny-kit'; interface Props { title?: string; diff --git a/src/components/Tab/Tab.tsx b/src/components/Tab/Tab.tsx index c900c202..a9e28389 100644 --- a/src/components/Tab/Tab.tsx +++ b/src/components/Tab/Tab.tsx @@ -1,10 +1,10 @@ -import {Row} from '../../containers'; +import {Row} from '../../containers/Row'; import {Text, View} from '../UI'; import * as React from 'react'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getSharedStyles} from '../../helpers'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export interface TabProps { diff --git a/src/components/ThemePicker/ThemePicker.tsx b/src/components/ThemePicker/ThemePicker.tsx index 859aa4e8..c630ddc3 100644 --- a/src/components/ThemePicker/ThemePicker.tsx +++ b/src/components/ThemePicker/ThemePicker.tsx @@ -1,4 +1,4 @@ -import {useThemeLabor} from '../../providers'; +import {useThemeLabor} from '../../providers/theme-labor'; import * as React from 'react'; import {EThemes} from '../../constants'; import {PickerSelect} from '../UI'; diff --git a/src/components/ThemeSwitch/ThemeSwitch.tsx b/src/components/ThemeSwitch/ThemeSwitch.tsx index c589859d..9da281ec 100644 --- a/src/components/ThemeSwitch/ThemeSwitch.tsx +++ b/src/components/ThemeSwitch/ThemeSwitch.tsx @@ -1,4 +1,4 @@ -import {useThemeLabor} from '../../providers'; +import {useThemeLabor} from '../../providers/theme-labor'; import {EThemes} from '../../constants'; import * as React from 'react'; import {SwitchP} from '../UI'; diff --git a/src/components/TreeNodePicker/TreeNodePicker.tsx b/src/components/TreeNodePicker/TreeNodePicker.tsx index a0688fb9..6eaa97a5 100644 --- a/src/components/TreeNodePicker/TreeNodePicker.tsx +++ b/src/components/TreeNodePicker/TreeNodePicker.tsx @@ -1,8 +1,9 @@ import {IcoMoon, Text, TextButton, View} from '../UI'; -import {Col, Row} from '../../containers'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; import * as React from 'react'; import {useEffect, useState} from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getSharedStyles} from '../../helpers'; import {getStyles} from './styles'; import {FlatList, KeyboardAvoidingView, SafeAreaView} from 'react-native'; diff --git a/src/components/UI/ImageProgressive.tsx b/src/components/UI/ImageProgressive.tsx index 90f7dadc..c024efaf 100644 --- a/src/components/UI/ImageProgressive.tsx +++ b/src/components/UI/ImageProgressive.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {Animated, ImageResizeMode, ImageSourcePropType, ImageStyle, StyleProp, View} from 'react-native'; import {getStyles} from './styles'; import config from '../../config'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; export interface ImageProgressiveProps extends WithBunnyKit { previewSource: ImageSourcePropType, diff --git a/src/components/UI/themed.tsx b/src/components/UI/themed.tsx index ae8f834e..ade40854 100644 --- a/src/components/UI/themed.tsx +++ b/src/components/UI/themed.tsx @@ -1,8 +1,9 @@ // import {Button as ButtonElement, ButtonProps as ButtonElementProps, Text as TextElement, TextProps as TextElementProps} from "react-native-elements"; -import {useSizeLabor, useThemeLabor} from '../../providers'; +import {useThemeLabor} from '../../providers/theme-labor'; import { Button as ButtonRN, ButtonProps, + ColorValue, Image as ImageRN, ImageProps, Platform, @@ -26,11 +27,12 @@ import React from 'react'; import {createIconSetFromIcoMoon, MaterialCommunityIcons} from '@expo/vector-icons'; import {IcoMoonProps, LinkProps, MaterialCommunityIconsProps} from '../../types'; import selection from '../../assets/fonts/icomoon/selection.json'; +import {useSizeLabor} from '../../providers/size-labor'; import {Switch as SwitchPaper} from 'react-native-paper'; import ReactNativePickerSelect, {PickerSelectProps as ReactNativePickerSelectProps} from 'react-native-picker-select'; import {getStyles} from './styles'; import {LinearGradient} from 'expo-linear-gradient'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export const IconFromIcoMoon = createIconSetFromIcoMoon(selection, 'IcoMoon', 'icomoon.ttf'); @@ -223,8 +225,8 @@ export const IcoMoon: React.FC }> const {colors, ms} = useBunnyKit(); - const mergedStyle = [{ - color: color || colors.text, + const mergedStyle: StyleProp = [{ + color: color as ColorValue || colors.text, fontSize: size || ms.fs.l, }, style]; return ( state.firestoreState.ordered.usersWithPhotos); const _imageUploaderError = (e: Error) => { - dispatch(sysError(e)); + dispatch(collectSysError(e)); }; const _removePhoto = async (position: string, source?: ImageURISource) => { diff --git a/src/components/Video/Video.tsx b/src/components/Video/Video.tsx index e34e8f5b..dd59afaa 100644 --- a/src/components/Video/Video.tsx +++ b/src/components/Video/Video.tsx @@ -3,7 +3,7 @@ import {createRef} from 'react'; import {AVPlaybackStatus, Video, VideoProps} from '../../../packages/expo-av/src'; import {Button, Text, View} from '../UI'; import {getStyles} from './styles'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; interface ShowVideoState { isPlaying: boolean, diff --git a/src/components/VividAlgorithm/VividAlgorithm.tsx b/src/components/VividAlgorithm/VividAlgorithm.tsx index 65e8f526..cf7b46ab 100644 --- a/src/components/VividAlgorithm/VividAlgorithm.tsx +++ b/src/components/VividAlgorithm/VividAlgorithm.tsx @@ -1,8 +1,9 @@ import * as React from 'react'; import {useEffect, useRef} from 'react'; import {Text, View} from '../UI'; -import {Card, Col, Row} from '../../containers'; -import {useBunnyKit} from '../../hooks'; +import {Row} from '../../containers/Row'; +import {Col} from '../../containers/Col'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getStyles} from './styles'; import { AbstractEdge, @@ -21,6 +22,7 @@ import { import {TreeNode} from '../../types'; import Svg, {Circle, Defs, G, Line, Marker, Path, Rect, Text as SVGText, TSpan} from 'react-native-svg'; import {ScrollView} from 'react-native'; +import {Card} from '../../containers'; export interface VividAlgorithmProps { data?: T, diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 0d5171cb..b955ada6 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -102,18 +102,18 @@ export const defaultValues = { } as Religion }; - export enum ESys { ERROR = 'ERROR', CLEAR_ERRORS = 'CLEAR_ERRORS', WARN = 'WARN', RESTORE_IS_READY = 'RESTORE_IS_READY', + REQUESTING = 'REQUEST', + REQUEST_SUCCESS = 'REQUEST_SUCCESS', + REQUEST_FAILED = 'REQUEST_FAILED', RESTORE_THEME = 'RESTORE_THEME', RESTORE_LANGUAGE = 'RESTORE_LANGUAGE', RESTORE_NAV_INITIAL_STATE = 'RESTORE_NAV_INITIAL_STATE', - REQUESTING = 'REQUEST', REQUEST_RECEIVED = 'REQUEST_RECEIVED', - REQUEST_FAILED = 'REQUEST_FAILED' } export enum EBL { @@ -137,11 +137,14 @@ export enum EDemoMap { RESTORE_REGION = 'RESTORE_REGION', } -export enum EBLMsg { +export enum EBizLogicMsg { NO_ACCESS_TOKEN_RESPONDED = 'No access_token responded', NO_AUTH_API_RESPONDED = 'No auth api responded', NO_USER_INFO_RESPONDED = 'No user info responded', NO_DATA_RESPONDED = 'No data responded', + EXAMPLE_SAGA_WRONG_DATA_STRUCTURE = 'Example saga wrong data structure', + LOGIN_WRONG_DATA_STRUCTURE = 'Login wrong data structure', + REGISTER_WRONG_DATA_STRUCTURE = 'Register wrong data structure', NO_ACCESS_TOKEN_OR_REFRESH_TOKEN_RESPONDED = 'No access token or refresh token responded', FIREBASE_EMAIL_LOGIN_NO_RESPONSE_OR_USER = 'Firebase email login no response or user', FIREBASE_EMAIL_SIGN_UP_NO_RESPONSE_OR_USER = 'Firebase email sign up no response or user', @@ -158,72 +161,21 @@ export enum EBLMsg { NOT_CONFORM_TO_API_RESPONSE_ROOT_STRUCTURE = 'Not conform to response root structure', NOT_CONFORM_TO_API_RESPONSE_BL_STRUCTURE = 'Not conform to response businessLogic structure', NOT_CONFORM_TO_API_RESPONSE_EXTRA_STRUCTURE = 'Not conform to response httpExtra structure', + NOT_CONFORM_TO_API_RESPONSE_SERVER_STRUCTURE = 'Not conform to response server structure', NO_NEARBY_FILMS = 'No nearby films', NO_DEMO_THUNK_DATA = 'No demo thunks response data', SAVE_QUICK_ALERT_SETTINGS_SUCCESS = 'Save quick alert settings success', CANCEL_ALL_ALERT_SETTINGS_SUCCESS = 'Cancel all alert settings success', GET_CURRENT_PRICE_SUCCESS = 'Get current price success', - GET_DEMO_SAGAS_SUCCESS = 'Get demo sagas success', + API_EXAMPLE_SAGA_SUCCESS = 'Get example saga success', + API_LOGIN_SUCCESS = 'Login success', + API_REGISTER_SUCCESS = 'Register success', + API_ME_SUCCESS = 'Get my user info success', + API_ME_WRONG_DATA_STRUCTURE = 'Get my user info wrong data structure', CANCELED_REQUEST = 'Canceled request', - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", - // XXX = "Xxx", + WRONG_DATA_STRUCTURE = 'Wrong data structure', + PSEUDO_BACKEND_SUCCESS = 'Pseudo backend success', + GET_DEMO_SAGAS_SUCCESS = 'Get demo sagas success', // XXX = "Xxx", } diff --git a/src/containers/Card/Card.tsx b/src/containers/Card/Card.tsx index 0e751c7d..50f3cd5f 100644 --- a/src/containers/Card/Card.tsx +++ b/src/containers/Card/Card.tsx @@ -1,6 +1,7 @@ import * as React from 'react'; import {StyleProp, View, ViewStyle} from 'react-native'; -import {useSizeLabor, useThemeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; +import {useThemeLabor} from '../../providers/theme-labor'; import {getStyles} from './styles'; import {Text} from '../../components/UI'; import {getContainerStyles} from '../styles'; diff --git a/src/containers/Col/styles.tsx b/src/containers/Col/styles.tsx index 7d80bdee..6040c36f 100644 --- a/src/containers/Col/styles.tsx +++ b/src/containers/Col/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/containers/DraggableView/styles.tsx b/src/containers/DraggableView/styles.tsx index 7d80bdee..6040c36f 100644 --- a/src/containers/DraggableView/styles.tsx +++ b/src/containers/DraggableView/styles.tsx @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/containers/InputCard/InputCard.tsx b/src/containers/InputCard/InputCard.tsx index 4ed00721..72d87edd 100644 --- a/src/containers/InputCard/InputCard.tsx +++ b/src/containers/InputCard/InputCard.tsx @@ -1,6 +1,7 @@ import {Text, View} from '../../components/UI'; import * as React from 'react'; -import {useSizeLabor, useThemeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; +import {useThemeLabor} from '../../providers/theme-labor'; import {getContainerStyles} from '../styles'; export interface InputCardProps { diff --git a/src/containers/ModalFromBottom/ModalFromBottom.tsx b/src/containers/ModalFromBottom/ModalFromBottom.tsx index d91a59f2..fe5fa27c 100644 --- a/src/containers/ModalFromBottom/ModalFromBottom.tsx +++ b/src/containers/ModalFromBottom/ModalFromBottom.tsx @@ -1,6 +1,6 @@ import Modal, {ModalProps} from 'react-native-modal'; import * as React from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getStyles} from './styles'; export interface ModalFromBottomProps { diff --git a/src/containers/ModalFromRight/ModalFromRight.tsx b/src/containers/ModalFromRight/ModalFromRight.tsx index 7f926025..ffaf5784 100644 --- a/src/containers/ModalFromRight/ModalFromRight.tsx +++ b/src/containers/ModalFromRight/ModalFromRight.tsx @@ -1,6 +1,6 @@ import Modal, {ModalProps} from 'react-native-modal'; import * as React from 'react'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {getStyles} from './styles'; export interface ModalFromRightProps { diff --git a/src/containers/Row/Row.tsx b/src/containers/Row/Row.tsx index 8c422652..27a992c7 100644 --- a/src/containers/Row/Row.tsx +++ b/src/containers/Row/Row.tsx @@ -1,7 +1,8 @@ import React from 'react'; import {FlexStyle, StyleProp, StyleSheet, View, ViewStyle} from 'react-native'; import {SizeKeys} from '../../types'; -import {useSizeLabor, useThemeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; +import {useThemeLabor} from '../../providers/theme-labor'; import {getStyles} from './styles'; export interface RowProps { diff --git a/src/containers/Row/styles.ts b/src/containers/Row/styles.ts index 7d80bdee..6040c36f 100644 --- a/src/containers/Row/styles.ts +++ b/src/containers/Row/styles.ts @@ -1,5 +1,5 @@ import {StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/helpers/auth-api.ts b/src/helpers/auth-api.ts index 6330cc99..0f8fa97c 100644 --- a/src/helpers/auth-api.ts +++ b/src/helpers/auth-api.ts @@ -35,23 +35,19 @@ apiAuth.interceptors.request.use( async error => { return Promise.reject(error); }); + apiAuth.interceptors.response.use( (response: AxiosResponse>) => { // status 200-300 - if (checkAuthAPIProtocol(response.data)) { - response.data = response.data.successData; - } else { - response.data = defaultAuthAPIResponseData; - } + checkAuthAPIProtocol(response.data); return response; }, async (error) => { const {response, request} = error; if (response) { // status 300-600 The request was made and the server responded with a status code that falls out of the range of 2xx - if (checkAuthAPIProtocol(response.data)) { - throw error; - } + checkAuthAPIProtocol(response.data); + return response; } else if (request) { // status 100-200 timeout The request was made but no response was received, `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in Node.js throw error; @@ -60,3 +56,5 @@ apiAuth.interceptors.response.use( throw error; } }); + +export default apiAuth; diff --git a/src/helpers/bunny-api.ts b/src/helpers/bunny-api.ts index 01cac87d..9e9cad53 100644 --- a/src/helpers/bunny-api.ts +++ b/src/helpers/bunny-api.ts @@ -1,5 +1,5 @@ import axios, {AxiosResponse} from 'axios'; -import {authLaborContext} from '../providers'; +import {authLaborContext} from '../providers/auth-labor'; import {BunnyAPIProtocolResponseData} from '../types'; import {checkBunnyAPIProtocol, getApiInstanceConfig} from './helpers'; @@ -27,12 +27,11 @@ export const defaultBunnyAPIResponseData = { }; export const bunnyAPI = axios.create(getApiInstanceConfig('bunny')); + bunnyAPI.interceptors.request.use( async (config) => { - const {accessToken} = await authLaborContext.authFunctions.getPersistenceAuth(); - // "Accept": "application/json", - // "Content-Type": "application/x-www-form-urlencoded" config.headers['Content-Type'] = 'application/json'; + const {accessToken} = await authLaborContext.authFunctions.getPersistenceAuth(); if (accessToken) { config.headers['Authorization'] = `Bearer ${accessToken}`; } @@ -44,26 +43,24 @@ bunnyAPI.interceptors.request.use( bunnyAPI.interceptors.response.use( (response: AxiosResponse>) => { - // status 200-300 - if (!checkBunnyAPIProtocol(response.data)) { - response.data = defaultBunnyAPIResponseData; - } - response.data = response.data.successData; + // status 200-299 + checkBunnyAPIProtocol(response.data); return response; }, async (error) => { const {response, request, config} = error; if (response) { - // status 300-600 The request was made and the server responded with a status code that falls out of the range of 2xx + // status 300-599 The request was made and the server responded with a status code that falls out of the range of 2xx const {status, data} = response; switch (status) { case 401: - const {businessLogic} = data; - const {errorCode} = businessLogic; - if (['BL_BUNNY_002', 'BL_BUNNY_003', 'BL_BUNNY_004', 'BL_BUNNY_005', 'BL_BUNNY_012'].includes(errorCode)) { + const {business_logic} = data; + const {error_code} = business_logic; + if (['01_001_B_002', '01_001_B_003', '01_001_B_004', '01_001_B_005', '01_001_B_012'].includes(error_code)) { const {authFunctions} = authLaborContext; const {bunnyRefreshAuth, logOut} = authFunctions; try { + const {success} = await bunnyRefreshAuth(); if (!success) { await logOut('API'); @@ -78,14 +75,15 @@ bunnyAPI.interceptors.response.use( } } break; + case 500: + throw error; default: break; } - if (checkBunnyAPIProtocol(response.data)) { - throw error; - } + checkBunnyAPIProtocol(response.data); + return response; } else if (request) { - // status 100-200 timeout The request was made but no response was received, `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in Node.js + // status 100-199 timeout The request was made but no response was received, `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in Node.js throw error; } else { // Something happened in setting up the request and triggered an error diff --git a/src/helpers/helpers.ts b/src/helpers/helpers.ts index c0705373..d58c64a4 100644 --- a/src/helpers/helpers.ts +++ b/src/helpers/helpers.ts @@ -14,7 +14,6 @@ import { } from '../types'; import glyphMaterialCommunityMap from '@expo/vector-icons/build/vendor/react-native-vector-icons/glyphmaps/MaterialCommunityIcons.json'; -import {EBLMsg} from '../constants'; import { AuthAPIError, BunnyAPIError, @@ -217,6 +216,34 @@ export const blSuccess = (data: TData, message?: string, shou }; }; +// export const checkCommonAPIProtocol = (data: any, PErrorClass: ErrorClass) => { +// let dataKeys; +// try { +// dataKeys = Object.keys(data); +// } catch (err: any) { +// throw new PErrorClass(err.message, err.stack); +// } +// const isDataKeysEqual = _.isEqual(dataKeys, ['timeSpent', 'successData', 'httpExtra', 'businessLogic']); +// if (!isDataKeysEqual) { +// throw new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_ROOT_STRUCTURE); +// } +// const {businessLogic, httpExtra} = data; +// const blKeys = Object.keys(businessLogic); +// const isBLKeysEqual = _.isEqual(blKeys, ['code', 'message', 'description', 'errorCode', 'errorMessage', 'errorDescription', 'errorStack']); +// if (!isBLKeysEqual) { +// throw new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_BL_STRUCTURE); +// } +// const httpExtraKeys = Object.keys(httpExtra); +// const isHttpExtraKeysEqual = _.isEqual(httpExtraKeys, ['code', 'message', 'description', 'errorCode', 'errorMessage', 'errorDescription', 'errorStack']); +// if (!isHttpExtraKeysEqual) { +// throw new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_EXTRA_STRUCTURE); +// } +// const {errorCode, errorMessage, errorStack} = businessLogic; +// if (errorCode) { +// throw new PErrorClass(errorMessage, errorCode, errorStack); +// } +// return true; +// }; export const checkCommonAPIProtocol = (data: any, PErrorClass: ErrorClass) => { let dataKeys; try { @@ -224,28 +251,35 @@ export const checkCommonAPIProtocol = (data: any, PErrorClass: ErrorClass) => { } catch (err: any) { throw new PErrorClass(err.message, err.stack); } - const isDataKeysEqual = _.isEqual(dataKeys, ['timeSpent', 'successData', 'httpExtra', 'businessLogic']); + const isDataKeysEqual = _.isEqual(dataKeys.sort(), ['time_spent', 'data', 'http_extra', 'business_logic', 'server_error'].sort()); if (!isDataKeysEqual) { - throw new PErrorClass(EBLMsg.NOT_CONFORM_TO_API_RESPONSE_ROOT_STRUCTURE); + // dispatch(collectSysError(new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_ROOT_STRUCTURE))); + return false; } - const {businessLogic, httpExtra} = data; - const blKeys = Object.keys(businessLogic); - const isBLKeysEqual = _.isEqual(blKeys, ['code', 'message', 'description', 'errorCode', 'errorMessage', 'errorDescription', 'errorStack']); + const {business_logic, http_extra, server_error} = data; + const blKeys = Object.keys(business_logic); + const isBLKeysEqual = _.isEqual(blKeys.sort(), ['code', 'message', 'description', 'error_code', 'error_message', 'error_description', 'error_stack'].sort()); if (!isBLKeysEqual) { - throw new PErrorClass(EBLMsg.NOT_CONFORM_TO_API_RESPONSE_BL_STRUCTURE); + // dispatch(collectSysError(new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_BL_STRUCTURE))); + return false; } - const httpExtraKeys = Object.keys(httpExtra); - const isHttpExtraKeysEqual = _.isEqual(httpExtraKeys, ['code', 'message', 'description', 'errorCode', 'errorMessage', 'errorDescription', 'errorStack']); + const httpExtraKeys = Object.keys(http_extra); + const isHttpExtraKeysEqual = _.isEqual(httpExtraKeys.sort(), ['code', 'message', 'description'].sort()); + if (!isHttpExtraKeysEqual) { - throw new PErrorClass(EBLMsg.NOT_CONFORM_TO_API_RESPONSE_EXTRA_STRUCTURE); + // dispatch(collectSysError(new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_EXTRA_STRUCTURE))); + return false; } - const {errorCode, errorMessage, errorStack} = businessLogic; - if (errorCode) { - throw new PErrorClass(errorMessage, errorCode, errorStack); + + const serverErrorKeys = Object.keys(server_error); + const isServerErrorKeysEqual = _.isEqual(serverErrorKeys.sort(), ['code', 'message', 'stack'].sort()); + + if (!isServerErrorKeysEqual) { + // dispatch(collectSysError(new PErrorClass(EBizLogicMsg.NOT_CONFORM_TO_API_RESPONSE_SERVER_STRUCTURE))); + return false; } return true; }; - export const checkAuthAPIProtocol = (data: any) => { return checkCommonAPIProtocol(data, AuthAPIError); }; diff --git a/src/helpers/nomics-api.ts b/src/helpers/nomics-api.ts index bcce7b33..f47f646f 100644 --- a/src/helpers/nomics-api.ts +++ b/src/helpers/nomics-api.ts @@ -1,8 +1,7 @@ import axios, {AxiosResponse} from 'axios'; -import {authLaborContext} from '../providers'; -import {checkNomicsAPIProtocol, getApiInstanceConfig} from './index'; -import {NomicsAPIProtocolResponseData} from '../types'; -import {bunnyAPI} from './bunny-api'; +import {authLaborContext} from '../providers/auth-labor'; +import {BunnyAPIProtocolResponseData} from '../types'; +import {checkBunnyAPIProtocol, getApiInstanceConfig} from './helpers'; export const defaultNomicsAPIResponseData = { 'httpExtra': { @@ -31,10 +30,8 @@ export const nomicsAPI = axios.create(getApiInstanceConfig('nomics')); nomicsAPI.interceptors.request.use( async (config) => { - const {accessToken} = await authLaborContext.authFunctions.getPersistenceAuth(); - // "Accept": "application/json", - // "Content-Type": "application/x-www-form-urlencoded" config.headers['Content-Type'] = 'application/json'; + const {accessToken} = await authLaborContext.authFunctions.getPersistenceAuth(); if (accessToken) { config.headers['Authorization'] = `Bearer ${accessToken}`; } @@ -45,34 +42,32 @@ nomicsAPI.interceptors.request.use( }); nomicsAPI.interceptors.response.use( - (response: AxiosResponse>) => { - // status 200-300 - if (!checkNomicsAPIProtocol(response.data)) { - response.data = defaultNomicsAPIResponseData; - } - response.data = response.data.successData; + (response: AxiosResponse>) => { + // status 200-299 + checkBunnyAPIProtocol(response.data); return response; }, async (error) => { const {response, request, config} = error; if (response) { - // status 300-600 The request was made and the server responded with a status code that falls out of the range of 2xx + // status 300-599 The request was made and the server responded with a status code that falls out of the range of 2xx const {status, data} = response; switch (status) { case 401: - const {businessLogic} = data; - const {errorCode} = businessLogic; - if (['BL_BUNNY_002', 'BL_BUNNY_003', 'BL_BUNNY_004', 'BL_BUNNY_005', 'BL_BUNNY_012'].includes(errorCode)) { + const {business_logic} = data; + const {error_code} = business_logic; + if (['01_001_B_002', '01_001_B_003', '01_001_B_004', '01_001_B_005', '01_001_B_012'].includes(error_code)) { const {authFunctions} = authLaborContext; const {bunnyRefreshAuth, logOut} = authFunctions; try { + const {success} = await bunnyRefreshAuth(); if (!success) { await logOut('API'); } else { const originalRequest = config; originalRequest._retry = true; - return bunnyAPI(originalRequest); + return nomicsAPI(originalRequest); } } catch (e) { await logOut('API'); @@ -80,14 +75,15 @@ nomicsAPI.interceptors.response.use( } } break; + case 500: + throw error; default: break; } - if (checkNomicsAPIProtocol(response.data)) { - throw error; - } + checkBunnyAPIProtocol(response.data); + return response; } else if (request) { - // status 100-200 timeout The request was made but no response was received, `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in Node.js + // status 100-199 timeout The request was made but no response was received, `error.request` is an instance of XMLHttpRequest in the browser and an instance of http.ClientRequest in Node.js throw error; } else { // Something happened in setting up the request and triggered an error diff --git a/src/hooks/bunny-kit/useBunnyKit.tsx b/src/hooks/bunny-kit/useBunnyKit.tsx index c794bd9d..aee51483 100644 --- a/src/hooks/bunny-kit/useBunnyKit.tsx +++ b/src/hooks/bunny-kit/useBunnyKit.tsx @@ -1,5 +1,7 @@ -import {useAuthLabor, useSizeLabor, useThemeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; +import {useThemeLabor} from '../../providers/theme-labor'; import {useTranslation} from 'react-i18next'; +import {useAuthLabor} from '../../providers/auth-labor'; import { AuthFunctions, AuthLaborContextType, diff --git a/src/hooks/index.tsx b/src/hooks/index.tsx deleted file mode 100644 index 28a26a6d..00000000 --- a/src/hooks/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export * from './keyboard-height'; -export * from './bunny-kit'; -export * from './is-mounted'; diff --git a/src/navigation/NavigatorTree/NavigatorTree.tsx b/src/navigation/NavigatorTree/NavigatorTree.tsx index 4a4acdc6..6edd077e 100644 --- a/src/navigation/NavigatorTree/NavigatorTree.tsx +++ b/src/navigation/NavigatorTree/NavigatorTree.tsx @@ -26,7 +26,7 @@ import {ChatHomeScreen} from '../../screens/DemoChat/Home'; import DemoShareScreen from '../../screens/DemoShare'; import {Image, Platform, TouchableOpacity, View} from 'react-native'; import DemoNotificationScreen from '../../screens/DemoNotification/DemoNotification'; -import {NotSupport} from '../../components'; +import {NotSupport} from '../../components/NotSupport'; import TabHomeScreen from '../../screens/DemoTab/Home'; import TabSettingsScreen from '../../screens/DemoTab/Settings'; import { @@ -55,7 +55,9 @@ import DemoThemeScreen from '../../screens/DemoTheme'; import {useTranslation} from 'react-i18next'; import {StackNavigationOptions} from '@react-navigation/stack'; import {IcoMoon} from '../../components/UI'; -import {useAuthLabor, useSizeLabor, useThemeLabor} from '../../providers'; +import {useAuthLabor} from '../../providers/auth-labor'; +import {useSizeLabor} from '../../providers/size-labor'; +import {useThemeLabor} from '../../providers/theme-labor'; import {getStyles} from './styles'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {DefaultNavigatorOptions} from '@react-navigation/core/src/types'; diff --git a/src/navigation/NavigatorTree/styles.ts b/src/navigation/NavigatorTree/styles.ts index 8d43e19d..637a6a27 100644 --- a/src/navigation/NavigatorTree/styles.ts +++ b/src/navigation/NavigatorTree/styles.ts @@ -1,5 +1,5 @@ import {Platform, StyleSheet} from 'react-native'; -import {useSizeLabor} from '../../providers'; +import {useSizeLabor} from '../../providers/size-labor'; import {getSharedStyles} from '../../helpers'; import {SizeLabor, ThemeLabor} from '../../types'; diff --git a/src/providers/auth-labor/AuthLaborContext.tsx b/src/providers/auth-labor/AuthLaborContext.tsx index b067daa0..66ffcc1a 100644 --- a/src/providers/auth-labor/AuthLaborContext.tsx +++ b/src/providers/auth-labor/AuthLaborContext.tsx @@ -13,7 +13,7 @@ import { User, } from '../../types'; import {apiAuth} from '../../helpers/auth-api'; -import BunnyConstants, {EBLMsg} from '../../constants/constants'; +import BunnyConstants, {EBizLogicMsg} from '../../constants/constants'; import {AxiosResponse} from 'axios'; import AsyncStorage from '@react-native-async-storage/async-storage'; import * as Google from 'expo-google-app-auth'; @@ -25,7 +25,7 @@ import { IOS_CLIENT_ID_FOR_EXPO } from '@env'; import _, {identity, pickBy} from 'lodash'; -import {blError, blSuccess} from '../../helpers'; +import {blError, blSuccess} from '../../helpers/helpers'; import {EventRegister} from 'react-native-event-listeners'; import {firebase} from '../../firebase/firebase'; import * as Facebook from 'expo-facebook'; @@ -37,15 +37,15 @@ import * as Facebook from 'expo-facebook'; const config: AuthContextConfig = { loginAPIMethod: 'PUT', - loginAPIPath: '/auth/login', + loginAPIPath: '/api/auth/login', signUpAPIMethod: 'POST', - signUpAPIPath: '/auth/register', + signUpAPIPath: '/api/auth/register', refreshAPIMethod: 'PUT', - refreshAPIPath: '/auth/refresh', - accessTokenValuePath: 'accessToken', - accessTokenExpValuePath: 'accessTokenExp', - refreshTokenValuePath: 'refreshToken', - refreshTokenExpValuePath: 'refreshTokenExp', + refreshAPIPath: '/api/auth/refresh', + accessTokenValuePath: 'access_token', + accessTokenExpValuePath: 'access_token_exp', + refreshTokenValuePath: 'refresh_token', + refreshTokenExpValuePath: 'refresh_token_exp', userValuePath: 'user', accessTokenPersistenceKey: BunnyConstants.ACCESS_TOKEN_PERSISTENCE_KEY, accessTokenExpPersistenceKey: BunnyConstants.ACCESS_TOKEN_EXP_PERSISTENCE_KEY, @@ -72,11 +72,16 @@ const persistenceAuth = async ({ accessTokenExp, refreshTokenExp }: PersistenceAuthParam) => { - accessToken && await AsyncStorage.setItem(accessTokenPersistenceKey, accessToken); - accessTokenExp && await AsyncStorage.setItem(accessTokenExpPersistenceKey, accessTokenExp); - refreshTokenExp && await AsyncStorage.setItem(refreshTokenExpPersistenceKey, refreshTokenExp); - refreshToken && await AsyncStorage.setItem(refreshTokenPersistenceKey, refreshToken); - user && await AsyncStorage.setItem(userPersistenceKey, JSON.stringify(user)); + try { + accessToken && await AsyncStorage.setItem(accessTokenPersistenceKey, accessToken); + accessTokenExp && await AsyncStorage.setItem(accessTokenExpPersistenceKey, accessTokenExp.toString()); + refreshTokenExp && await AsyncStorage.setItem(refreshTokenExpPersistenceKey, refreshTokenExp.toString()); + refreshToken && await AsyncStorage.setItem(refreshTokenPersistenceKey, refreshToken); + user && await AsyncStorage.setItem(userPersistenceKey, JSON.stringify(user)); + } catch (e: any) { + console.error(e); + } + }; const triggerLogin = async (result: BLResult) => { @@ -91,13 +96,13 @@ const triggerLogin = async (result: BLResult) => { const loginOrSignUp = async (res: any) => { let result: BLResult; if (!res) { - result = blError(EBLMsg.NO_AUTH_API_RESPONDED); + result = blError(EBizLogicMsg.NO_AUTH_API_RESPONDED); await triggerLogin(result); return result; } - const {data} = res; + const {data} = res.data; if (!data) { - result = blError(EBLMsg.NO_DATA_RESPONDED); + result = blError(EBizLogicMsg.NO_DATA_RESPONDED); await triggerLogin(result); return result; } @@ -108,12 +113,12 @@ const loginOrSignUp = async (res: any) => { const user = _.get(data, userValuePath); if (!(accessToken && refreshToken)) { - result = blError(EBLMsg.NO_ACCESS_TOKEN_OR_REFRESH_TOKEN_RESPONDED); + result = blError(EBizLogicMsg.NO_ACCESS_TOKEN_OR_REFRESH_TOKEN_RESPONDED); await triggerLogin(result); return result; } if (!user) { - result = blError(EBLMsg.NO_USER_INFO_RESPONDED); + result = blError(EBizLogicMsg.NO_USER_INFO_RESPONDED); await triggerLogin(result); return result; } @@ -143,20 +148,20 @@ const bunnyRefreshAuth = async (): Promise => { const res = await apiAuth.request({method: refreshAPIMethod, url: refreshAPIPath}); let result: BLResult; if (!res) { - result = blError(EBLMsg.NO_AUTH_API_RESPONDED); + result = blError(EBizLogicMsg.NO_AUTH_API_RESPONDED); EventRegister.emit('bunnyRefreshAuth', result); return result; } - const {data} = res; + const {data} = res.data; if (!data) { - result = blError(EBLMsg.NO_DATA_RESPONDED); + result = blError(EBizLogicMsg.NO_DATA_RESPONDED); EventRegister.emit('bunnyRefreshAuth', result); return result; } const accessToken = _.get(data, accessTokenValuePath); const accessTokenExp = _.get(data, accessTokenExpValuePath); if (!accessToken) { - result = blError(EBLMsg.NO_ACCESS_TOKEN_RESPONDED); + result = blError(EBizLogicMsg.NO_ACCESS_TOKEN_RESPONDED); EventRegister.emit('bunnyRefreshAuth', result); return result; } @@ -214,16 +219,16 @@ const googleLogin = async (isFirebase: boolean, isStoreUser: boolean = true) => }); let result: BLResult; if (!googleResponse) { - result = blError(EBLMsg.NO_GOOGLE_LOGIN_RESULT); + result = blError(EBizLogicMsg.NO_GOOGLE_LOGIN_RESULT); } switch (googleResponse.type) { case 'cancel': - result = blError(EBLMsg.GOOGLE_LOGIN_CANCELED); + result = blError(EBizLogicMsg.GOOGLE_LOGIN_CANCELED); break; case 'success': const {idToken, accessToken, refreshToken, user} = googleResponse; if (!accessToken || !refreshToken) { - result = blError(EBLMsg.GOOGLE_ACCESS_TOKEN_OR_REFRESH_TOKEN_NOT_EXISTS); + result = blError(EBizLogicMsg.GOOGLE_ACCESS_TOKEN_OR_REFRESH_TOKEN_NOT_EXISTS); } if (isFirebase) { await firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL); @@ -239,7 +244,7 @@ const googleLogin = async (isFirebase: boolean, isStoreUser: boolean = true) => } break; default: - result = blError(EBLMsg.GOOGLE_LOGIN_RESULT_TYPE_INVALID); + result = blError(EBizLogicMsg.GOOGLE_LOGIN_RESULT_TYPE_INVALID); break; } await triggerLogin(result); @@ -248,7 +253,7 @@ const googleLogin = async (isFirebase: boolean, isStoreUser: boolean = true) => const firebaseLoginResult = async (userCredential: firebase.auth.UserCredential, isStoreUser: boolean = true) => { if (!userCredential || !userCredential.user) { - return blError(EBLMsg.FIREBASE_INVALID_USER_CREDENTIAL); + return blError(EBizLogicMsg.FIREBASE_INVALID_USER_CREDENTIAL); } let idToken: string, user: firebase.User; const currentUser = firebase.auth().currentUser; @@ -269,7 +274,7 @@ const firebaseLoginResult = async (userCredential: firebase.auth.UserCredential, user: {firebaseUser: user, storedUser}, }); } else { - return blError(EBLMsg.FIREBASE_INVALID_CURRENT_USER); + return blError(EBizLogicMsg.FIREBASE_INVALID_CURRENT_USER); } }; @@ -284,7 +289,7 @@ const facebookLogin = async (isFirebase: boolean, isStoreUser: boolean = true) = const {type} = facebookResponse; switch (type) { case 'cancel': - result = blError(EBLMsg.FACEBOOK_LOGIN_CANCELED); + result = blError(EBizLogicMsg.FACEBOOK_LOGIN_CANCELED); break; case 'success': // @ts-ignore @@ -306,7 +311,7 @@ const facebookLogin = async (isFirebase: boolean, isStoreUser: boolean = true) = } break; default : - result = blError(EBLMsg.FACEBOOK_LOGIN_RESULT_TYPE_INVALID); + result = blError(EBizLogicMsg.FACEBOOK_LOGIN_RESULT_TYPE_INVALID); break; } await triggerLogin(result); diff --git a/src/providers/auth-labor/AuthLaborProvider.tsx b/src/providers/auth-labor/AuthLaborProvider.tsx index 67be6ec6..88b27993 100644 --- a/src/providers/auth-labor/AuthLaborProvider.tsx +++ b/src/providers/auth-labor/AuthLaborProvider.tsx @@ -3,7 +3,7 @@ import * as React from 'react'; import {useCallback, useEffect, useMemo, useState} from 'react'; import {AuthLaborProviderProps, AuthResult, BLResult} from '../../types'; import {AuthLaborContext, authLaborContext} from './AuthLaborContext'; -import {Preparing} from '../../components'; +import {Preparing} from '../../components/Preparing'; import {useTranslation} from 'react-i18next'; import {shortenTFunctionKey} from '../i18n-labor'; import {EventRegister} from 'react-native-event-listeners'; diff --git a/src/providers/i18n-labor/I18nLaborProvider.tsx b/src/providers/i18n-labor/I18nLaborProvider.tsx index 55d29d52..155a5625 100644 --- a/src/providers/i18n-labor/I18nLaborProvider.tsx +++ b/src/providers/i18n-labor/I18nLaborProvider.tsx @@ -7,7 +7,7 @@ import * as localization from 'expo-localization'; import {I18nLaborContext} from './I18nLaborContext'; import i18next from './i18next'; import {i18n as I18n} from 'i18next'; -import {Preparing} from '../../components'; +import {Preparing} from '../../components/Preparing'; import {useTranslation} from 'react-i18next'; import {shortenTFunctionKey} from './shorten-t-function-key'; diff --git a/src/providers/index.tsx b/src/providers/index.tsx deleted file mode 100644 index 9a5406fc..00000000 --- a/src/providers/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -export * from './auth-labor'; -export * from './i18n-labor'; -export * from './size-labor'; -export * from './theme-labor'; -export * from './request-labor'; diff --git a/src/providers/request-labor/RequestProvider.tsx b/src/providers/request-labor/RequestProvider.tsx index 2535466e..4eec0ccb 100644 --- a/src/providers/request-labor/RequestProvider.tsx +++ b/src/providers/request-labor/RequestProvider.tsx @@ -1,4 +1,4 @@ -import {bunnyAPI} from '../../helpers'; +import bunnyAPI from '../../helpers/bunny-api'; import React, {ReactNode} from 'react'; import {AxiosInstance} from 'axios'; import {RequestContext} from './RequestContext'; diff --git a/src/providers/request-labor/useRequest.tsx b/src/providers/request-labor/useRequest.tsx index 5f5fcd75..85e29109 100644 --- a/src/providers/request-labor/useRequest.tsx +++ b/src/providers/request-labor/useRequest.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import {bunnyAPI} from '../../helpers'; +import bunnyAPI from '../../helpers/bunny-api'; import {RequestContext} from './RequestContext'; export const useRequest = (): typeof bunnyAPI => React.useContext(RequestContext); diff --git a/src/providers/size-labor/withSizeLabor.tsx b/src/providers/size-labor/withSizeLabor.tsx index 29bc6a2d..770d2cdc 100644 --- a/src/providers/size-labor/withSizeLabor.tsx +++ b/src/providers/size-labor/withSizeLabor.tsx @@ -2,8 +2,6 @@ import {useSizeLabor} from './useSizeLabor'; import React from 'react'; import {SizeLabor} from '../../types'; -console.log('useSizeLabor', useSizeLabor); - export interface WithSizeLabor { sizeLabor: SizeLabor; } diff --git a/src/providers/theme-labor/ThemeLaborProvider.tsx b/src/providers/theme-labor/ThemeLaborProvider.tsx index c59e09e7..12bf0a78 100644 --- a/src/providers/theme-labor/ThemeLaborProvider.tsx +++ b/src/providers/theme-labor/ThemeLaborProvider.tsx @@ -5,10 +5,10 @@ import {ThemeName, ThemeProviderProps} from '../../types'; import {ThemeLaborContext} from './ThemeLaborContext'; import AsyncStorage from '@react-native-async-storage/async-storage'; import BunnyConstants, {EThemes} from '../../constants/constants'; -import {collectBLResult, sysError} from '../../store/actions'; +import {collectBLResult, collectSysError} from '../../store/actions'; import {useColorScheme} from 'react-native-appearance'; import {useDispatch} from 'react-redux'; -import {Preparing} from '../../components'; +import {Preparing} from '../../components/Preparing'; import {Provider as PaperProvider} from 'react-native-paper'; import {getThemes} from './theme'; import _ from 'lodash'; @@ -48,7 +48,7 @@ export const ThemeLaborProvider = (props: ThemeProviderProps): JSX.Element => { } await changeTheme(themeName); } catch (err: any) { - dispatch(sysError(err)); + dispatch(collectSysError(err)); } }; bootstrapAsync() diff --git a/src/providers/theme-labor/theme.ts b/src/providers/theme-labor/theme.ts index 82ea7765..391a2bca 100644 --- a/src/providers/theme-labor/theme.ts +++ b/src/providers/theme-labor/theme.ts @@ -3,7 +3,7 @@ import {JSONSerializable, Themes, ThemeWarehouse} from '../../types'; import color from 'color'; import {EThemes} from '../../constants'; import {isLeafParent, isSameStructure, pl} from '../../utils'; -import {getSizeLabor} from '../size-labor'; +import {getSizeLabor} from '../size-labor/sizeLabor'; import {getVictoryTheme} from './victoryTheme'; export const getThemeWareHouse = () => { diff --git a/src/providers/theme-labor/victoryTheme.ts b/src/providers/theme-labor/victoryTheme.ts index 7b03d7ce..74cdfc85 100644 --- a/src/providers/theme-labor/victoryTheme.ts +++ b/src/providers/theme-labor/victoryTheme.ts @@ -1,5 +1,5 @@ import {pl, reverseColor} from '../../utils'; -import {getSizeLabor} from '../size-labor'; +import {getSizeLabor} from '../size-labor/sizeLabor'; export const getVictoryTheme = () => { const {wp} = getSizeLabor().designsBasedOn.iphoneX; diff --git a/src/screens/Algorithm/Algorithm.tsx b/src/screens/Algorithm/Algorithm.tsx index ccae6469..6ed484be 100644 --- a/src/screens/Algorithm/Algorithm.tsx +++ b/src/screens/Algorithm/Algorithm.tsx @@ -2,8 +2,8 @@ import React, {useState} from 'react'; import {Text, TextButton, TextInput, View} from '../../components/UI'; import {getStyles} from './styles'; import {OrderType, TreeNode} from '../../types'; -import {Card} from '../../containers'; -import {useBunnyKit} from '../../hooks'; +import {Card} from '../../containers/Card'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import { BFS, binaryTreeInorderTraversal, diff --git a/src/screens/Auth/Auth.tsx b/src/screens/Auth/Auth.tsx index 6b27cba4..8720ab76 100644 --- a/src/screens/Auth/Auth.tsx +++ b/src/screens/Auth/Auth.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; -import {View} from '../../components/UI'; -import {getContainerStyles} from '../../containers'; +import {Text, View} from '../../components/UI'; +import {getContainerStyles, Row} from '../../containers'; import {RouteProp} from '@react-navigation/native'; import {RootStackParam} from '../../types'; import {StackNavigationProp} from '@react-navigation/stack'; @@ -10,7 +10,8 @@ import {getStyles} from './styles'; import {LoginScreen} from './Login'; import {SignUpScreen} from './SignUp'; import {useTranslation} from 'react-i18next'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; +import {Checkbox} from 'react-native-paper'; type ProfileRouteProp = RouteProp; type ProfileNavigationProp = StackNavigationProp; @@ -32,6 +33,9 @@ export const AuthScreen = ({route, navigation}: Auth1Props) => { const containerStyles = getContainerStyles(sizeLabor, themeLabor); const styles = getStyles(sizeLabor, themeLabor); const {t} = useTranslation(); + + const [isBunnyAuth, setIsBunnyAuth] = React.useState(false); + return ( @@ -64,9 +68,22 @@ export const AuthScreen = ({route, navigation}: Auth1Props) => { }, }} > - - + + {props => } + + + {props => } + + + Bunny Auth + { + setIsBunnyAuth(!isBunnyAuth); + }} + /> + diff --git a/src/screens/Auth/Login.tsx b/src/screens/Auth/Login.tsx index 65ef2268..cb705803 100644 --- a/src/screens/Auth/Login.tsx +++ b/src/screens/Auth/Login.tsx @@ -2,21 +2,22 @@ import {InButtonText, LinearGradientButton, Text, TextInputIcon, View} from '../ import * as React from 'react'; import {useState} from 'react'; import {useDispatch} from 'react-redux'; -import {shortenTFunctionKey, useAuthLabor} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles, InputCard, Row} from '../../containers'; +import {useAuthLabor} from '../../providers/auth-labor'; import {RouteProp} from '@react-navigation/native'; import {AuthTopStackParam, RootStackParam} from '../../types'; import {StackNavigationProp} from '@react-navigation/stack'; import {LinearGradientIcon} from '../../components/LinearGradientIcon'; import {Keyboard, ScrollView, TouchableOpacity} from 'react-native'; -import {collectBLResult, sysError} from '../../store/actions'; +import {collectBLResult, collectSysError} from '../../store/actions'; import {getStyles} from './styles'; import {LoginVector} from '../../components/LoginVector'; import {FirebasePhoneLogin} from '../../components/FirebasePhoneLogin'; -import {Tab} from '../../components'; +import {Tab} from '../../components/Tab'; import {ForgotPassword} from '../../components/ForgotPassword'; import {navToReference} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type LoginRouteProp = RouteProp; type LoginNavigationProp = StackNavigationProp; @@ -24,9 +25,10 @@ type LoginNavigationProp = StackNavigationProp; export interface LoginProps { route: LoginRouteProp; navigation: LoginNavigationProp; + isBunnyAuth: boolean; } -export function LoginScreen({route, navigation}: LoginProps) { +export function LoginScreen({route, navigation, isBunnyAuth}: LoginProps) { const {sizeLabor, themeLabor, wp, t, ms} = useBunnyKit(); const st = shortenTFunctionKey(t, 'screens.Auth'); const containerStyles = getContainerStyles(sizeLabor, themeLabor); @@ -49,28 +51,29 @@ export function LoginScreen({route, navigation}: LoginProps) { } else { dispatch(collectBLResult(result)); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }; const bunnyLogin = async () => { Keyboard.dismiss(); try { - const result = await authFunctions.bunnyLogin({email, password}); + const result = await authFunctions.bunnyLogin({username: email, password}); if (result.success) { navToReference(route, navigation); } else { dispatch(collectBLResult(result)); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }; const handleLogin = async () => { - await firebaseEmailLogin(); + isBunnyAuth ? await bunnyLogin() : await firebaseEmailLogin(); }; + return { diff --git a/src/screens/Auth/SignUp.tsx b/src/screens/Auth/SignUp.tsx index f16e3a2a..97afe8be 100644 --- a/src/screens/Auth/SignUp.tsx +++ b/src/screens/Auth/SignUp.tsx @@ -2,18 +2,19 @@ import {InButtonText, LinearGradientButton, TextInputIcon, View} from '../../com import * as React from 'react'; import {useState} from 'react'; import {useDispatch} from 'react-redux'; -import {shortenTFunctionKey, useAuthLabor} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles, InputCard, Row} from '../../containers'; +import {useAuthLabor} from '../../providers/auth-labor'; import {RouteProp} from '@react-navigation/native'; import {AuthTopStackParam, RootStackParam} from '../../types'; import {StackNavigationProp} from '@react-navigation/stack'; import {LinearGradientIcon} from '../../components/LinearGradientIcon'; import {Keyboard} from 'react-native'; -import {collectBLResult, sysError} from '../../store/actions'; +import {collectBLResult, collectSysError} from '../../store/actions'; import {LoginVector} from '../../components/LoginVector'; import {getSharedStyles, navToReference} from '../../helpers'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type SignUpRouteProp = RouteProp; type SignUpNavigationProp = StackNavigationProp; @@ -21,9 +22,10 @@ type SignUpNavigationProp = StackNavigationProp; export interface SignUpProps { route: SignUpRouteProp; navigation: SignUpNavigationProp; + isBunnyAuth: boolean; } -export function SignUpScreen({route, navigation}: SignUpProps) { +export function SignUpScreen({route, navigation, isBunnyAuth}: SignUpProps) { const {sizeLabor, themeLabor, colors, wp, theme, t, ms} = useBunnyKit(); const dispatch = useDispatch(); const st = shortenTFunctionKey(t, 'screens.Auth'); @@ -44,27 +46,27 @@ export function SignUpScreen({route, navigation}: SignUpProps) { } else { dispatch(collectBLResult(result)); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }; const bunnySignUp = async () => { Keyboard.dismiss(); try { - const result = await authFunctions.bunnySignUp({email: username, password: password}); + const result = await authFunctions.bunnySignUp({username: username, password: password}); if (result.success) { navToReference(route, navigation); } else { dispatch(collectBLResult(result)); } - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }; const handleSignUp = async () => { - await firebaseEmailSignUp(); + isBunnyAuth ? await bunnySignUp() : await firebaseEmailSignUp(); }; return diff --git a/src/screens/Auth/styles.ts b/src/screens/Auth/styles.ts index c426998d..e1d57f6e 100644 --- a/src/screens/Auth/styles.ts +++ b/src/screens/Auth/styles.ts @@ -42,6 +42,9 @@ export const getStyles = (sizeLabor: SizeLabor, themeLabor: ThemeLabor) => { width: wp(100), ...shadowAround }, + authService: { + justifyContent: 'flex-end' + } }); }; diff --git a/src/screens/ColorFinder/ColorFinder.tsx b/src/screens/ColorFinder/ColorFinder.tsx index 3ea48121..2e597d51 100644 --- a/src/screens/ColorFinder/ColorFinder.tsx +++ b/src/screens/ColorFinder/ColorFinder.tsx @@ -19,9 +19,9 @@ import {useDispatch} from 'react-redux'; import {ColorTranslator} from 'colortranslator'; import {CopyableText} from '../../components/CopyableText'; import {ColorValuesCard} from '../../components/ColorValuesCard'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {Tab} from '../../components'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export type UglyColorType = 'Beautiful' | 'RGB' | 'Hex' | 'HSL'; diff --git a/src/screens/DemoChat/ChatRoom/ChatRoom.tsx b/src/screens/DemoChat/ChatRoom/ChatRoom.tsx index f2776738..4d9f1b10 100644 --- a/src/screens/DemoChat/ChatRoom/ChatRoom.tsx +++ b/src/screens/DemoChat/ChatRoom/ChatRoom.tsx @@ -1,5 +1,5 @@ import React, {useCallback, useEffect, useMemo, useState} from 'react'; -import {AudioRecorder, BunnyChat, ImageUploader, Preparing, StickerPicker} from '../../../components'; +import {BunnyChat} from '../../../components/BunnyChat'; import {RouteProp} from '@react-navigation/native'; import {DemoChatStackParam, IMMessage, IMMessageType, RootState} from '../../../types'; import {StackNavigationProp} from '@react-navigation/stack'; @@ -7,10 +7,11 @@ import {useDispatch, useSelector} from 'react-redux'; import {isLoaded, useFirestore, useFirestoreConnect} from 'react-redux-firebase'; import {firestoreTimestampToDate, uuidV4} from '../../../utils'; import {Keyboard, SafeAreaView, TouchableOpacity} from 'react-native'; +import {AudioRecorder, ImageUploader, Preparing, StickerPicker} from '../../../components'; import {IcoMoon} from '../../../components/UI'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../../hooks'; -import {sysError} from '../../../store/actions'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; +import {collectSysError} from '../../../store/actions'; type ChatRoomRouteProp = RouteProp; type ChatRoomNavigationProp = StackNavigationProp; @@ -188,7 +189,7 @@ export function ChatRoomScreen({route, navigation}: ChatRoomProps) { }} onMessageLoadError={(e, currentMessage) => { - dispatch(sysError(e)); + dispatch(collectSysError(e)); }} // actionSheet={() => { // return { diff --git a/src/screens/DemoChat/Home/ChatHome.tsx b/src/screens/DemoChat/Home/ChatHome.tsx index bb819fae..0ef1cc5c 100644 --- a/src/screens/DemoChat/Home/ChatHome.tsx +++ b/src/screens/DemoChat/Home/ChatHome.tsx @@ -5,14 +5,17 @@ import {RouteProp} from '@react-navigation/native'; import {Conversation, DemoChatStackParam, RootStackParam, RootState} from '../../../types'; import {StackNavigationProp} from '@react-navigation/stack'; import {useSelector} from 'react-redux'; -import {Col, Row} from '../../../containers'; +import {Row} from '../../../containers/Row'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../../hooks'; +import {Col} from '../../../containers'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; import {isLoaded, useFirebaseConnect, useFirestore, useFirestoreConnect} from 'react-redux-firebase'; import {FirestoreReducer} from 'redux-firestore'; -import {Avatar, Divider, InlineJump, Preparing} from '../../../components'; +import {Avatar} from '../../../components/Avatar'; import dayJS from 'dayjs'; import isToday from 'dayjs/plugin/isToday'; +import {Divider, InlineJump} from '../../../components'; +import {Preparing} from '../../../components/Preparing'; import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {firestoreTimestampToDate} from '../../../utils'; diff --git a/src/screens/DemoCollection/DemoCollection.tsx b/src/screens/DemoCollection/DemoCollection.tsx index 56d664af..4f27d444 100644 --- a/src/screens/DemoCollection/DemoCollection.tsx +++ b/src/screens/DemoCollection/DemoCollection.tsx @@ -1,13 +1,15 @@ import React from 'react'; import DemoFCCard from '../../components/DemoFCCard'; -import {DemoCCClock, DemoPureComponent, DemoRegularComponent, DemoSvg} from '../../components'; import DemoRequest from '../../components/DemoRequest'; import {TextInput, View} from '../../components/UI'; -import {shortenTFunctionKey} from '../../providers'; +import {DemoSvg} from '../../components/DemoSvg'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {ScrollView} from 'react-native'; import {getContainerStyles, Row} from '../../containers'; +import {DemoPureComponent, DemoRegularComponent} from '../../components/DemoPureComponent'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; +import {DemoCCClock} from '../../components'; function DemoCollectionScreen() { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/screens/DemoCryptoCurrency/Alert/Alert.tsx b/src/screens/DemoCryptoCurrency/Alert/Alert.tsx index 5fe44f08..7516c471 100644 --- a/src/screens/DemoCryptoCurrency/Alert/Alert.tsx +++ b/src/screens/DemoCryptoCurrency/Alert/Alert.tsx @@ -4,16 +4,16 @@ import {Platform, View} from 'react-native'; import {RouteProp} from '@react-navigation/native'; import {DemoCryptoCurrencyTabStackParam, RootStackParam, RootState} from '../../../types'; import {ButtonTO, InButtonText, PickerSelectChevronRight, Text} from '../../../components/UI'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {Col, getContainerStyles, Row} from '../../../containers'; import * as Notifications from 'expo-notifications'; import {defaultNotification, registerForPushNotificationsAsync} from '../../../utils/expo-notification'; -import {cancelAlertSettings, getCurrentPrice, saveQuickAlertSettings, sysError} from '../../../store/actions'; +import {cancelAlertSettings, collectSysError, getCurrentPrice, saveQuickAlertSettings} from '../../../store/actions'; import {useDispatch, useSelector} from 'react-redux'; import {getStyles} from './styles'; import {getSharedStyles} from '../../../helpers'; import {StackNavigationProp} from '@react-navigation/stack'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type CryptoCurrencyAlertRouteProp = RouteProp; type CryptoCurrencyAlertNavigationProp = StackNavigationProp; @@ -78,8 +78,8 @@ export default function CryptoCurrencyAlertScreen({route, navigation}: CryptoCur try { dispatch(getCurrentPrice()); - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } notificationReceivedListener = Notifications diff --git a/src/screens/DemoCryptoCurrency/Home/Home.tsx b/src/screens/DemoCryptoCurrency/Home/Home.tsx index 4eb6bf78..5a959148 100644 --- a/src/screens/DemoCryptoCurrency/Home/Home.tsx +++ b/src/screens/DemoCryptoCurrency/Home/Home.tsx @@ -3,7 +3,7 @@ import {useEffect, useState} from 'react'; import {Text, View} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {DemoCryptoCurrencyTabStackParam, RootStackParam, RootState} from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import { VictoryAxis, @@ -17,12 +17,12 @@ import {getStyles} from './styles'; import {addDays} from '../../../utils'; import {useDispatch, useSelector} from 'react-redux'; import axios, {CancelTokenSource} from 'axios'; -import {collectBLResult, getCurrentPrice, sysError} from '../../../store/actions'; +import {collectBLResult, collectSysError, getCurrentPrice} from '../../../store/actions'; import {blError, getSharedStyles} from '../../../helpers'; import {ScrollView} from 'react-native'; import {StackNavigationProp} from '@react-navigation/stack'; import {Tab} from '../../../components'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type CryptoCurrencyHomeRouteProp = RouteProp; type CryptoCurrencyHomeNavigationProp = StackNavigationProp; @@ -87,15 +87,15 @@ function CryptoCurrencyHomeScreen() { return {x: new Date(item), y: parseFloat(parseFloat(prices[index]).toFixed(2))}; }); setBtcData(btcDataMapped); - } catch (e) { + } catch (e: any) { dispatch(collectBLResult(blError(e.message, false))); } }; useEffect(() => { try { dispatch(getCurrentPrice()); - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } getHistoricalPrices(type, dateRange).then(); return () => { diff --git a/src/screens/DemoDating/Home/CardItem.tsx b/src/screens/DemoDating/Home/CardItem.tsx index 3aa8959c..b7681736 100644 --- a/src/screens/DemoDating/Home/CardItem.tsx +++ b/src/screens/DemoDating/Home/CardItem.tsx @@ -3,7 +3,7 @@ import {Image, View} from 'react-native'; import {Col, getContainerStyles, Row} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; import {IcoMoon} from '../../../components/UI'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; export interface CardItemProps { description?: string; diff --git a/src/screens/DemoDating/Home/Home.tsx b/src/screens/DemoDating/Home/Home.tsx index 4bdc0545..48f22491 100644 --- a/src/screens/DemoDating/Home/Home.tsx +++ b/src/screens/DemoDating/Home/Home.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import {useRef} from 'react'; import {View} from '../../../components/UI'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {Row} from '../../../containers'; import CardStack, {Card as StackSwiperCard} from 'react-native-card-stack-swiper'; import data from './data'; import CardItem from './CardItem'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; export function DatingHomeScreen() { const {sizeLabor, themeLabor, theme, colors, wp, t, ms} = useBunnyKit(); diff --git a/src/screens/DemoDating/Settings/Settings.tsx b/src/screens/DemoDating/Settings/Settings.tsx index 765a80d9..1ad2b16c 100644 --- a/src/screens/DemoDating/Settings/Settings.tsx +++ b/src/screens/DemoDating/Settings/Settings.tsx @@ -16,7 +16,7 @@ import {Col, getContainerStyles, ModalFromBottom, ModalFromRight, Row} from '../ import {BottomTabNavigationProp} from '@react-navigation/bottom-tabs'; import {getSharedStyles} from '../../../helpers'; import {ScrollView} from 'react-native'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; import { Divider, Graduate, diff --git a/src/screens/DemoDrawer/Home/Home.tsx b/src/screens/DemoDrawer/Home/Home.tsx index 961f5320..b334445a 100644 --- a/src/screens/DemoDrawer/Home/Home.tsx +++ b/src/screens/DemoDrawer/Home/Home.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; import {Text, View} from '../../../components/UI'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function DrawerHomeScreen() { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/screens/DemoDrawer/Settings/Settings.tsx b/src/screens/DemoDrawer/Settings/Settings.tsx index 54610c9a..f3dff9dd 100644 --- a/src/screens/DemoDrawer/Settings/Settings.tsx +++ b/src/screens/DemoDrawer/Settings/Settings.tsx @@ -2,11 +2,11 @@ import * as React from 'react'; import {Text, View} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {DemoDrawerStackParam, RootStackParam} from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import {StackNavigationProp} from '@react-navigation/stack'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type DrawerSettingsRouteProp = RouteProp; type DrawerSettingsNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoFCReduxHook/DemoFCReduxHook.tsx b/src/screens/DemoFCReduxHook/DemoFCReduxHook.tsx index 96c1a982..a0e50094 100644 --- a/src/screens/DemoFCReduxHook/DemoFCReduxHook.tsx +++ b/src/screens/DemoFCReduxHook/DemoFCReduxHook.tsx @@ -2,11 +2,11 @@ import React from 'react'; import {useDispatch, useSelector} from 'react-redux'; import {demoHello} from '../../store/actions'; import {Button, Text, View} from '../../components/UI'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; import {RootState} from '../../types'; import {getSharedStyles} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; function DemoFCReduxHookScreen() { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/screens/DemoHealth/Home/BodyPartCard/BodyPartCard.tsx b/src/screens/DemoHealth/Home/BodyPartCard/BodyPartCard.tsx index 114b647b..62a4af8c 100644 --- a/src/screens/DemoHealth/Home/BodyPartCard/BodyPartCard.tsx +++ b/src/screens/DemoHealth/Home/BodyPartCard/BodyPartCard.tsx @@ -4,7 +4,7 @@ import {getStyles} from './styles'; import {Text} from '../../../../components/UI'; import {Col, Row} from '../../../../containers'; import {LinearGradientIcon} from '../../../../components/LinearGradientIcon'; -import {useBunnyKit} from '../../../../hooks'; +import {useBunnyKit} from '../../../../hooks/bunny-kit'; export interface BodyPartCardProps { title?: string, diff --git a/src/screens/DemoHealth/Home/BodyPartChartCard/BodyPartChartCard.tsx b/src/screens/DemoHealth/Home/BodyPartChartCard/BodyPartChartCard.tsx index e3096960..da30237b 100644 --- a/src/screens/DemoHealth/Home/BodyPartChartCard/BodyPartChartCard.tsx +++ b/src/screens/DemoHealth/Home/BodyPartChartCard/BodyPartChartCard.tsx @@ -3,7 +3,7 @@ import {View} from 'react-native'; import {getStyles} from './styles'; import {Text} from '../../../../components/UI'; import {Col, Row} from '../../../../containers'; -import {Divider} from '../../../../components'; +import {Divider} from '../../../../components/Divider'; import {MonthKey} from '../../../../types'; import { VictoryAxis, @@ -13,7 +13,7 @@ import { VictoryTooltip, VictoryVoronoiContainer } from '../../../../components/Victory/Victory'; -import {useBunnyKit} from '../../../../hooks'; +import {useBunnyKit} from '../../../../hooks/bunny-kit'; export interface BodyPartCardProps { title?: string, diff --git a/src/screens/DemoHealth/Home/Home.tsx b/src/screens/DemoHealth/Home/Home.tsx index 5afc86b3..75776d85 100644 --- a/src/screens/DemoHealth/Home/Home.tsx +++ b/src/screens/DemoHealth/Home/Home.tsx @@ -2,8 +2,10 @@ import * as React from 'react'; import {useState} from 'react'; import {PickerSelect, Text, View} from '../../../components/UI'; import {useTranslation} from 'react-i18next'; -import {shortenTFunctionKey, useSizeLabor, useThemeLabor} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {Col, getContainerStyles, Row} from '../../../containers'; +import {useSizeLabor} from '../../../providers/size-labor'; +import {useThemeLabor} from '../../../providers/theme-labor'; import {Avatar} from '../../../components'; import {E_MONTH} from '../../../constants'; import {MonthKey} from '../../../types'; diff --git a/src/screens/DemoHealth/Settings/Settings.tsx b/src/screens/DemoHealth/Settings/Settings.tsx index 599f50f1..f07cd341 100644 --- a/src/screens/DemoHealth/Settings/Settings.tsx +++ b/src/screens/DemoHealth/Settings/Settings.tsx @@ -3,14 +3,15 @@ import {useState} from 'react'; import {IcoMoon, PickerSelect, SwitchP, Text, View} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {DemoHealthTabStackParam, RootStackParam} from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; -import {Card, Col, getContainerStyles, Row} from '../../../containers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; +import {Card, getContainerStyles, Row} from '../../../containers'; import {StackNavigationProp} from '@react-navigation/stack'; -import {Divider} from '../../../components'; +import {Divider} from '../../../components/Divider'; import {LinearGradientIcon} from '../../../components/LinearGradientIcon'; import {getStyles} from './styles'; +import {Col} from '../../../containers/Col'; import {SafeAreaView, ScrollView, TouchableOpacity} from 'react-native'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type HealthSettingsRouteProp = RouteProp; type HealthSettingsNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoMap/DemoMap.tsx b/src/screens/DemoMap/DemoMap.tsx index d040529f..85969572 100644 --- a/src/screens/DemoMap/DemoMap.tsx +++ b/src/screens/DemoMap/DemoMap.tsx @@ -5,14 +5,14 @@ import * as Location from 'expo-location'; import {ThunkDispatch} from 'redux-thunk'; import {DemoMapState, GetNearbyFilmsReqParams, NearbyFilm, Region, RootState} from '../../types'; import {Action} from 'redux'; -import {getNearbyFilms, restoreRegion, sysError} from '../../store/actions'; +import {collectSysError, getNearbyFilms, restoreRegion} from '../../store/actions'; import {connect} from 'react-redux'; import MapView, {PROVIDER_DEFAULT} from 'react-native-maps'; import BunnyConstants from '../../constants/constants'; import getStyles, {getCardSize} from './styles'; import {getContainerStyles} from '../../containers'; import config from '../../config'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; const {Marker} = MapView as any; // react-native-maps under typescript bug trick @@ -21,7 +21,7 @@ const mapStateToProps = (rootState: RootState) => ({...rootState.demoMapState}); const mapDispatchToProps = (dispatch: ThunkDispatch) => ({ getNearbyFilms: async (reqParams: GetNearbyFilmsReqParams) => dispatch(getNearbyFilms(reqParams)), restoreRegion: (region: Region) => dispatch(restoreRegion(region)), - sysError: (err: Error) => dispatch(sysError(err)) + collectSysError: (err: Error) => dispatch(collectSysError(err)) }); export interface DemoMapProps extends ReturnType, @@ -55,8 +55,8 @@ class DemoMapScreen extends Component { longitude: location.coords.longitude, ...BunnyConstants.latLngDeltaGrace }); - } catch (e) { - this.props.sysError(e); + } catch (e: any) { + this.props.collectSysError(e); } } diff --git a/src/screens/DemoModal/Home/ModalHome.tsx b/src/screens/DemoModal/Home/ModalHome.tsx index 6c79bef2..75961fd3 100644 --- a/src/screens/DemoModal/Home/ModalHome.tsx +++ b/src/screens/DemoModal/Home/ModalHome.tsx @@ -2,12 +2,12 @@ import * as React from 'react'; import {View} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {ScrollView} from 'react-native'; import {DemoModalStackParam} from '../../../types'; import {getContainerStyles} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type ModalHomeRouteProp = RouteProp; type ModalHomeNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoNestedLv0/NestedLv1Home/NestedLv1Home.tsx b/src/screens/DemoNestedLv0/NestedLv1Home/NestedLv1Home.tsx index 5ae21b21..6b78d824 100644 --- a/src/screens/DemoNestedLv0/NestedLv1Home/NestedLv1Home.tsx +++ b/src/screens/DemoNestedLv0/NestedLv1Home/NestedLv1Home.tsx @@ -3,10 +3,10 @@ import {ButtonTO, InButtonText, View} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {DemoNestedLv1StackParam} from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type NestedLv1HomeRouteProp = RouteProp; type NestedLv1HomeNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Home/NestedLv2Home.tsx b/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Home/NestedLv2Home.tsx index de56f2f5..9a40932b 100644 --- a/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Home/NestedLv2Home.tsx +++ b/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Home/NestedLv2Home.tsx @@ -3,10 +3,10 @@ import {ButtonTO, InButtonText, View} from '../../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {DemoNestedLv2StackParam} from '../../../../types'; -import {shortenTFunctionKey} from '../../../../providers'; +import {shortenTFunctionKey} from '../../../../providers/i18n-labor'; import {getContainerStyles} from '../../../../containers'; import {getSharedStyles} from '../../../../helpers'; -import {useBunnyKit} from '../../../../hooks'; +import {useBunnyKit} from '../../../../hooks/bunny-kit'; type NestedLv2HomeRouteProp = RouteProp; type NestedLv2HomeNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Settings/NestedLv2Settings.tsx b/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Settings/NestedLv2Settings.tsx index 9fa17957..6a7ad04d 100644 --- a/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Settings/NestedLv2Settings.tsx +++ b/src/screens/DemoNestedLv0/NestedLv1Settings/NestedLv2Settings/NestedLv2Settings.tsx @@ -3,10 +3,10 @@ import {ButtonTO, InButtonText, View} from '../../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {DemoNestedLv2StackParam} from '../../../../types'; -import {shortenTFunctionKey} from '../../../../providers'; +import {shortenTFunctionKey} from '../../../../providers/i18n-labor'; import {getContainerStyles} from '../../../../containers'; import {getSharedStyles} from '../../../../helpers'; -import {useBunnyKit} from '../../../../hooks'; +import {useBunnyKit} from '../../../../hooks/bunny-kit'; type NestedLv2SettingsRouteProp = RouteProp; type NestedLv2SettingsNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoNotification/DemoNotification.tsx b/src/screens/DemoNotification/DemoNotification.tsx index 52d2c81b..d9340cea 100644 --- a/src/screens/DemoNotification/DemoNotification.tsx +++ b/src/screens/DemoNotification/DemoNotification.tsx @@ -7,8 +7,8 @@ import { registerForPushNotificationsAsync, schedulePushNotification } from '../../utils/expo-notification'; -import {shortenTFunctionKey} from '../../providers'; -import {useBunnyKit} from '../../hooks'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export default function DemoNotificationScreen() { diff --git a/src/screens/DemoRNComponents/RNFlatList/FlatList.tsx b/src/screens/DemoRNComponents/RNFlatList/FlatList.tsx index b73ab50e..0f9d7571 100644 --- a/src/screens/DemoRNComponents/RNFlatList/FlatList.tsx +++ b/src/screens/DemoRNComponents/RNFlatList/FlatList.tsx @@ -2,7 +2,7 @@ import React from 'react'; import {FlatList, SafeAreaView, Text, View} from 'react-native'; import {getStyles} from './styles'; import {getContainerStyles} from '../../../containers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function RNFlatListScreen() { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/screens/DemoRNComponents/RNHome/RNHome.tsx b/src/screens/DemoRNComponents/RNHome/RNHome.tsx index 60546eb3..ba0a419e 100644 --- a/src/screens/DemoRNComponents/RNHome/RNHome.tsx +++ b/src/screens/DemoRNComponents/RNHome/RNHome.tsx @@ -14,10 +14,10 @@ import { View } from 'react-native'; import {Button, Pressable, Text, TextInput, TouchableOpacity} from '../../../components/UI'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles, Row} from '../../../containers'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function RNHome() { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/screens/DemoRNComponents/RNKeyboardAvoiding/KeyboardAvoiding.tsx b/src/screens/DemoRNComponents/RNKeyboardAvoiding/KeyboardAvoiding.tsx index a5270644..36288783 100644 --- a/src/screens/DemoRNComponents/RNKeyboardAvoiding/KeyboardAvoiding.tsx +++ b/src/screens/DemoRNComponents/RNKeyboardAvoiding/KeyboardAvoiding.tsx @@ -3,7 +3,7 @@ import {Keyboard, KeyboardAvoidingView, Platform, TouchableWithoutFeedback, View import {Button, Text, TextInput} from '../../../components/UI'; import {getStyles} from './styles'; import {getContainerStyles} from '../../../containers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function RNKeyboardAvoidingScreen() { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/screens/DemoRNComponents/RNSafeArea/SafeArea.tsx b/src/screens/DemoRNComponents/RNSafeArea/SafeArea.tsx index 0d02dd9e..6e77c522 100644 --- a/src/screens/DemoRNComponents/RNSafeArea/SafeArea.tsx +++ b/src/screens/DemoRNComponents/RNSafeArea/SafeArea.tsx @@ -3,7 +3,7 @@ import {SafeAreaView} from 'react-native'; import {Text} from '../../../components/UI'; import {getContainerStyles} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function RNFlatListScreen() { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/screens/DemoRNComponents/RNSectionList/SectionList.tsx b/src/screens/DemoRNComponents/RNSectionList/SectionList.tsx index eb8248e1..5b69b557 100644 --- a/src/screens/DemoRNComponents/RNSectionList/SectionList.tsx +++ b/src/screens/DemoRNComponents/RNSectionList/SectionList.tsx @@ -3,7 +3,7 @@ import {SafeAreaView, SectionList, View} from 'react-native'; import {Text} from '../../../components/UI'; import {getStyles} from './styles'; import {getContainerStyles} from '../../../containers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function SectionListScreen() { const {sizeLabor, themeLabor, colors} = useBunnyKit(); diff --git a/src/screens/DemoRNComponents/RNVirtualizedList/RNVirtualizedList.tsx b/src/screens/DemoRNComponents/RNVirtualizedList/RNVirtualizedList.tsx index 38c324e5..469ef99e 100644 --- a/src/screens/DemoRNComponents/RNVirtualizedList/RNVirtualizedList.tsx +++ b/src/screens/DemoRNComponents/RNVirtualizedList/RNVirtualizedList.tsx @@ -2,9 +2,9 @@ import React from 'react'; import {SafeAreaView, View, VirtualizedList} from 'react-native'; import {Text} from '../../../components/UI'; import {getStyles} from './styles'; -import {useThemeLabor} from '../../../providers'; +import {useThemeLabor} from '../../../providers/theme-labor'; import {getContainerStyles} from '../../../containers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type VirtualizedListItem = { id: string; diff --git a/src/screens/DemoRoute/DemoRoute.tsx b/src/screens/DemoRoute/DemoRoute.tsx index f28e6466..ec866111 100644 --- a/src/screens/DemoRoute/DemoRoute.tsx +++ b/src/screens/DemoRoute/DemoRoute.tsx @@ -4,10 +4,10 @@ import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {RootStackParam} from '../../types'; import {getStyles} from './styles'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; import {getSharedStyles} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type ProfileRouteProp = RouteProp; type ProfileNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoSaga/DemoSaga.tsx b/src/screens/DemoSaga/DemoSaga.tsx index 8336a930..f4ff70d5 100644 --- a/src/screens/DemoSaga/DemoSaga.tsx +++ b/src/screens/DemoSaga/DemoSaga.tsx @@ -5,7 +5,7 @@ import {getDemoSagas} from '../../store/actions'; import {RootState} from '../../types'; import {getSharedStyles} from '../../helpers'; import {getContainerStyles} from '../../containers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; function DemoSagaScreen() { diff --git a/src/screens/DemoSagaFirebase/DemoSagaFirebase.tsx b/src/screens/DemoSagaFirebase/DemoSagaFirebase.tsx index 5cc40b5a..23499ba6 100644 --- a/src/screens/DemoSagaFirebase/DemoSagaFirebase.tsx +++ b/src/screens/DemoSagaFirebase/DemoSagaFirebase.tsx @@ -9,8 +9,8 @@ import {useFirebaseConnect} from 'react-redux-firebase'; import {getStyles} from './styles'; import {randomText} from '../../utils'; import {FlatList} from 'react-native'; -import {shortenTFunctionKey} from '../../providers'; -import {useBunnyKit} from '../../hooks'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export function DemoSagaFirebaseScreen() { diff --git a/src/screens/DemoSearch/DemoSearch.tsx b/src/screens/DemoSearch/DemoSearch.tsx index d4c70b9c..24882b67 100644 --- a/src/screens/DemoSearch/DemoSearch.tsx +++ b/src/screens/DemoSearch/DemoSearch.tsx @@ -3,7 +3,7 @@ import {useEffect, useState} from 'react'; import {Text, View} from '../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {DemoSearchDummyDatum, RootStackParam} from '../../types'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; import {Animated, SafeAreaView} from 'react-native'; import {randomText, wait} from '../../utils'; @@ -13,7 +13,7 @@ import {collectBLResult} from '../../store/actions'; import {blError} from '../../helpers'; import {StackNavigationProp} from '@react-navigation/stack'; import config from '../../config'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type DemoSearchRouteProp = RouteProp; @@ -68,7 +68,7 @@ export function DemoSearchScreen({route, navigation}: DemoSearchProps) { try { const searchResult = await mockSearch(searchText); setData(searchResult); - } catch (e) { + } catch (e: any) { collectBLResult(blError(e)); } }} diff --git a/src/screens/DemoShare/DemoShare.tsx b/src/screens/DemoShare/DemoShare.tsx index 3e810866..a81ba2c4 100644 --- a/src/screens/DemoShare/DemoShare.tsx +++ b/src/screens/DemoShare/DemoShare.tsx @@ -3,13 +3,15 @@ import * as React from 'react'; import {Share} from 'react-native'; import {ButtonTO, Image, InButtonText, Text, TouchableOpacity, View} from '../../components/UI'; import {useDispatch} from 'react-redux'; -import {sysError} from '../../store/actions'; +import {collectSysError} from '../../store/actions'; import * as ImagePicker from 'expo-image-picker'; import * as Sharing from 'expo-sharing'; -import {shortenTFunctionKey, useSizeLabor, useThemeLabor} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; +import {useSizeLabor} from '../../providers/size-labor'; +import {useThemeLabor} from '../../providers/theme-labor'; import {getSharedStyles} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export type SelectedImage = { localUri: string @@ -33,8 +35,8 @@ function DemoShareScreen() { } else if (result.action === Share.dismissedAction) { // dismissed } - } catch (error) { - dispatch(sysError(error.toString())); + } catch (e: any) { + dispatch(collectSysError(e.toString())); } }; diff --git a/src/screens/DemoSocialMedia/Home/Home.tsx b/src/screens/DemoSocialMedia/Home/Home.tsx index a98887a4..f7876cdb 100644 --- a/src/screens/DemoSocialMedia/Home/Home.tsx +++ b/src/screens/DemoSocialMedia/Home/Home.tsx @@ -6,7 +6,7 @@ import {RootState, SocialMediaMainDatum} from '../../../types'; import {SocialMediaVideoCard} from '../../../components/SocialMediaVideoCard'; import {isLoaded, useFirebase, useFirestoreConnect} from 'react-redux-firebase'; import {useSelector} from 'react-redux'; -import {Preparing} from '../../../components'; +import {Preparing} from '../../../components/Preparing'; export function SocialMediaHomeScreen() { const firebase = useFirebase(); diff --git a/src/screens/DemoSocialMedia/Search/Search.tsx b/src/screens/DemoSocialMedia/Search/Search.tsx index 401ca44f..b33c9b82 100644 --- a/src/screens/DemoSocialMedia/Search/Search.tsx +++ b/src/screens/DemoSocialMedia/Search/Search.tsx @@ -8,7 +8,7 @@ import { RootState, SocialMediaImageDatum } from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import {getStyles} from './styles'; import {Animated, Platform, SafeAreaView} from 'react-native'; @@ -19,8 +19,8 @@ import {StackNavigationProp} from '@react-navigation/stack'; import {useSelector} from 'react-redux'; import {isLoaded, useFirebase, useFirestoreConnect} from 'react-redux-firebase'; import config from '../../../config'; -import {Preparing} from '../../../components'; -import {useBunnyKit} from '../../../hooks'; +import {Preparing} from '../../../components/Preparing'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type SocialMediaSearchRouteProp = RouteProp; type SocialMediaSearchNavigationProp = StackNavigationProp; diff --git a/src/screens/DemoSocialMedia/Settings/Settings.tsx b/src/screens/DemoSocialMedia/Settings/Settings.tsx index ac6fd5cd..2ea84e02 100644 --- a/src/screens/DemoSocialMedia/Settings/Settings.tsx +++ b/src/screens/DemoSocialMedia/Settings/Settings.tsx @@ -2,12 +2,12 @@ import * as React from 'react'; import {Text} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {DemoSocialMediaTabStackParam, RootStackParam} from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {Card, getContainerStyles} from '../../../containers'; import {SafeAreaView} from 'react-native'; import {getStyles} from './styles'; import {StackNavigationProp} from '@react-navigation/stack'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type SocialMediaSettingsRouteProp = RouteProp; diff --git a/src/screens/DemoSuspense/DemoSuspense.tsx b/src/screens/DemoSuspense/DemoSuspense.tsx index 0fa1e335..b348db4d 100644 --- a/src/screens/DemoSuspense/DemoSuspense.tsx +++ b/src/screens/DemoSuspense/DemoSuspense.tsx @@ -1,9 +1,9 @@ import React from 'react'; import {Text, View} from '../../components/UI'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; import {getSharedStyles} from '../../helpers'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; import {wait} from '../../utils'; const DemoLazy100 = React.lazy(async () => { diff --git a/src/screens/DemoTab/Home/Home.tsx b/src/screens/DemoTab/Home/Home.tsx index 028f3c76..932f2523 100644 --- a/src/screens/DemoTab/Home/Home.tsx +++ b/src/screens/DemoTab/Home/Home.tsx @@ -1,9 +1,9 @@ import * as React from 'react'; import {Text, View} from '../../../components/UI'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; function TabHomeScreen() { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/screens/DemoTab/Settings/Settings.tsx b/src/screens/DemoTab/Settings/Settings.tsx index 781f2c66..13a9aa6d 100644 --- a/src/screens/DemoTab/Settings/Settings.tsx +++ b/src/screens/DemoTab/Settings/Settings.tsx @@ -2,11 +2,11 @@ import * as React from 'react'; import {Text, View} from '../../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {DemoTabStackParam} from '../../../types'; -import {shortenTFunctionKey} from '../../../providers'; +import {shortenTFunctionKey} from '../../../providers/i18n-labor'; import {getContainerStyles} from '../../../containers'; import {BottomTabNavigationProp} from '@react-navigation/bottom-tabs'; import {getSharedStyles} from '../../../helpers'; -import {useBunnyKit} from '../../../hooks'; +import {useBunnyKit} from '../../../hooks/bunny-kit'; type TabSettingsRouteProp = RouteProp; type TabSettingsNavigationProp = BottomTabNavigationProp; diff --git a/src/screens/DemoTheme/DemoTheme.tsx b/src/screens/DemoTheme/DemoTheme.tsx index 7c0df38b..e1fe5ea7 100644 --- a/src/screens/DemoTheme/DemoTheme.tsx +++ b/src/screens/DemoTheme/DemoTheme.tsx @@ -1,14 +1,14 @@ import React from 'react'; import {ScrollView} from 'react-native'; import {Button, ButtonTO, InButtonText, LinearGradientButton, Text, View} from '../../components/UI'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getStyles} from './styles'; import BunnyConstants from '../../constants/constants'; import {Card, getContainerStyles, Row} from '../../containers'; import {getSharedStyles} from '../../helpers'; // import {LinearGradient} from "expo-linear-gradient"; import Svg, {Defs, Ellipse, RadialGradient, Rect, Stop,} from 'react-native-svg'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; const DemoThemeScreen = () => { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/screens/DemoThirdPart/DemoThirdPart.tsx b/src/screens/DemoThirdPart/DemoThirdPart.tsx index d09a6988..be4598fd 100644 --- a/src/screens/DemoThirdPart/DemoThirdPart.tsx +++ b/src/screens/DemoThirdPart/DemoThirdPart.tsx @@ -2,11 +2,11 @@ import React, {useState} from 'react'; import {Avatar, Button, List} from 'react-native-paper'; import RNPickerSelect from 'react-native-picker-select'; import {IconMC, View} from '../../components/UI'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {Card, getContainerStyles, Row} from '../../containers'; import {uuidV4} from '../../utils'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; interface Props { title?: string; diff --git a/src/screens/DemoThunkCC/DemoThunkCC.tsx b/src/screens/DemoThunkCC/DemoThunkCC.tsx index 3b424105..ac9e63f5 100644 --- a/src/screens/DemoThunkCC/DemoThunkCC.tsx +++ b/src/screens/DemoThunkCC/DemoThunkCC.tsx @@ -5,10 +5,10 @@ import {demoThunk} from '../../store/actions'; import {DemoThunkPayload, DemoThunkState, RootState} from '../../types'; import {ThunkDispatch} from 'redux-thunk'; import {Action} from 'redux'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; import {getSharedStyles} from '../../helpers'; -import {WithBunnyKit, withBunnyKit} from '../../hooks'; +import {WithBunnyKit, withBunnyKit} from '../../hooks/bunny-kit'; const mapStateToProps = (rootState: RootState) => ({...rootState.demoThunkState}); const mapDispatchToProps = (dispatch: ThunkDispatch) => ({ diff --git a/src/screens/Home/Home.tsx b/src/screens/Home/Home.tsx index 327f845e..1d10bebf 100644 --- a/src/screens/Home/Home.tsx +++ b/src/screens/Home/Home.tsx @@ -3,13 +3,15 @@ import {ScrollView, View} from 'react-native'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {RootStackParam} from '../../types'; -import {shortenTFunctionKey, useAuthLabor} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {Card, getContainerStyles} from '../../containers'; +import {useAuthLabor} from '../../providers/auth-labor'; import {useDispatch} from 'react-redux'; -import {sysError} from '../../store/actions'; -import {Divider, InlineJump} from '../../components'; +import {collectSysError} from '../../store/actions'; +import {Divider} from '../../components/Divider'; import {getStyles} from './styles'; -import {useBunnyKit} from '../../hooks'; +import {InlineJump} from '../../components/InlineJump'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type HomeRouteProp = RouteProp; type HomeNavigationProp = StackNavigationProp; @@ -164,8 +166,8 @@ function HomeScreen({navigation}: HomeScreenProps) { { try { await authFunctions.logOut('MANUAL'); - } catch (e) { - dispatch(sysError(e)); + } catch (e: any) { + dispatch(collectSysError(e)); } }} iconSize={wp(20)}/> diff --git a/src/screens/IconTools/IconTools.tsx b/src/screens/IconTools/IconTools.tsx index c49dfedb..8ce8798d 100644 --- a/src/screens/IconTools/IconTools.tsx +++ b/src/screens/IconTools/IconTools.tsx @@ -4,10 +4,10 @@ import {ScrollView} from 'react-native'; import {getStyles} from './styles'; import {Card, Row} from '../../containers'; import {useDispatch} from 'react-redux'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {glyphIcoMoonMap} from '../../helpers'; import {CopyableText} from '../../components/CopyableText'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export function IconToolsScreen() { diff --git a/src/screens/Playground/Playground.tsx b/src/screens/Playground/Playground.tsx index c39d4b95..08beed33 100644 --- a/src/screens/Playground/Playground.tsx +++ b/src/screens/Playground/Playground.tsx @@ -5,10 +5,11 @@ import {getStyles} from './styles'; import {useFirestoreConnect} from 'react-redux-firebase'; import {useSelector} from 'react-redux'; import {RootState} from '../../types'; -import {Card, DraggableView} from '../../containers'; +import {DraggableView} from '../../containers/DraggableView'; import {randomDate, uuidV4} from '../../utils'; import {ProgressBar} from 'react-native-paper'; -import {useBunnyKit} from '../../hooks'; +import {Card} from '../../containers/Card'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export function PlaygroundScreen() { const {sizeLabor, themeLabor} = useBunnyKit(); diff --git a/src/screens/Profile/Profile.tsx b/src/screens/Profile/Profile.tsx index e070a358..df5f4ec8 100644 --- a/src/screens/Profile/Profile.tsx +++ b/src/screens/Profile/Profile.tsx @@ -4,16 +4,16 @@ import {ButtonTO, InButtonText, Text, View} from '../../components/UI'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {RootStackParam, RootState} from '../../types'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {ImageURISource, SafeAreaView, ScrollView} from 'react-native'; import {getStyles} from './styles'; import ImageProgressive from '../../components/UI/ImageProgressive'; import {Col, getContainerStyles, Row} from '../../containers'; import {getSharedStyles} from '../../helpers'; -import {Avatar} from '../../components'; +import {Avatar} from '../../components/Avatar'; import {useFirestore} from 'react-redux-firebase'; import {useSelector} from 'react-redux'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; type ProfileRouteProp = RouteProp; type ProfileNavigationProp = StackNavigationProp; diff --git a/src/screens/Settings/Item/Item.tsx b/src/screens/Settings/Item/Item.tsx index 49f87f4f..de3423bb 100644 --- a/src/screens/Settings/Item/Item.tsx +++ b/src/screens/Settings/Item/Item.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; import {getStyles} from './styles'; import {SwitchPaperProps, Text, View} from '../../../components/UI'; -import {useSizeLabor, useThemeLabor} from '../../../providers'; +import {useSizeLabor} from '../../../providers/size-labor'; +import {useThemeLabor} from '../../../providers/theme-labor'; import {PickerSelectProps} from 'react-native-picker-select'; import {Col} from '../../../containers'; import {getSharedStyles} from '../../../helpers'; diff --git a/src/screens/Settings/Settings.tsx b/src/screens/Settings/Settings.tsx index b8ea82a3..17844373 100644 --- a/src/screens/Settings/Settings.tsx +++ b/src/screens/Settings/Settings.tsx @@ -1,11 +1,11 @@ import * as React from 'react'; import SettingsItem from './Item'; import {View} from '../../components/UI'; -import {shortenTFunctionKey} from '../../providers'; +import {shortenTFunctionKey} from '../../providers/i18n-labor'; import {getContainerStyles} from '../../containers'; import {ThemePicker} from '../../components/ThemePicker'; import {LanguagePicker} from '../../components/LanguagePicker'; -import {useBunnyKit} from '../../hooks'; +import {useBunnyKit} from '../../hooks/bunny-kit'; export default function SettingsScreen() { const {sizeLabor, themeLabor, t} = useBunnyKit(); diff --git a/src/store/actions/demo-map.ts b/src/store/actions/demo-map.ts index 695f51df..9b6b8ff6 100644 --- a/src/store/actions/demo-map.ts +++ b/src/store/actions/demo-map.ts @@ -1,6 +1,6 @@ import {Action, ActionCreator, Dispatch} from 'redux'; import {ThunkAction} from 'redux-thunk'; -import {EBLMsg, EDemoMap} from '../../constants'; +import {EBizLogicMsg, EDemoMap} from '../../constants'; import { CollectBLResultAction, DemoMapState, @@ -10,13 +10,13 @@ import { RequestConfig, RequestFailedAction, RequestingAction, - RequestReceivedAction, + RequestSuccessAction, RestoreNearbyFilmsAction, RestoreRegionAction, SysErrorAction } from '../../types'; import {bunnyAPI} from '../../helpers/bunny-api'; -import {requestFailed, requesting, requestReceived, sysError} from './sys'; +import {collectSysError, requestFailed, requesting, requestSuccess} from './sys'; import {collectBLResult} from './bl-result'; import {blError} from '../../helpers'; @@ -28,7 +28,7 @@ export const restoreNearbyFilms: (payload: NearbyFilm[]) => RestoreNearbyFilmsAc }; export const getNearbyFilms: ActionCreator, DemoMapState, void, RestoreNearbyFilmsAction>> = (reqParams: GetNearbyFilmsReqParams) => { - return async (dispatch: Dispatch): Promise => { + return async (dispatch: Dispatch): Promise => { let result; const config: RequestConfig = {method: 'GET', url: '/nearby-films', params: reqParams}; try { @@ -36,13 +36,13 @@ export const getNearbyFilms: ActionCreator, DemoMapS const res = await bunnyAPI.request(config); if (res.data) { result = dispatch(restoreNearbyFilms(res.data)); - result = dispatch(requestReceived(config)); + result = dispatch(requestSuccess(config)); } else { - result = dispatch(collectBLResult(blError(EBLMsg.NO_NEARBY_FILMS))); + result = dispatch(collectBLResult(blError(EBizLogicMsg.NO_NEARBY_FILMS))); } return result; } catch (e: any) { - result = dispatch(sysError(e)); + result = dispatch(collectSysError(e)); result = dispatch(requestFailed(config)); return result; } diff --git a/src/store/actions/demo-thunk.ts b/src/store/actions/demo-thunk.ts index ed41763a..e3618433 100644 --- a/src/store/actions/demo-thunk.ts +++ b/src/store/actions/demo-thunk.ts @@ -8,13 +8,13 @@ import { RequestConfig, RequestFailedAction, RequestingAction, - RequestReceivedAction, + RequestSuccessAction, SysErrorAction } from '../../types'; -import {EBLMsg, EDemoThunk} from '../../constants'; +import {EBizLogicMsg, EDemoThunk} from '../../constants'; import {Action, ActionCreator, Dispatch} from 'redux'; import {ThunkAction} from 'redux-thunk'; -import {requestFailed, requesting, requestReceived, sysError} from './sys'; +import {collectSysError, requestFailed, requesting, requestSuccess} from './sys'; import {collectBLResult} from './bl-result'; import {blError} from '../../helpers'; @@ -26,7 +26,7 @@ export const demoThunkSuccess: (payload: DemoThunkSuccessPayload) => DemoThunkSu }; export const demoThunk: ActionCreator, DemoThunkState, void, DemoThunkSuccessAction>> = (reqParams: DemoThunkPayload) => { - return async (dispatch: Dispatch): Promise => { + return async (dispatch: Dispatch): Promise => { let result; const config: RequestConfig = {url: '/demo-thunks', method: 'POST', data: reqParams}; try { @@ -34,13 +34,13 @@ export const demoThunk: ActionCreator, DemoThunkStat const res = await bunnyAPI.request(config); if (res.data) { result = dispatch(demoThunkSuccess(res.data)); - result = dispatch(requestReceived(config)); + result = dispatch(requestSuccess(config)); } else { - result = dispatch(collectBLResult(blError(EBLMsg.NO_DEMO_THUNK_DATA))); + result = dispatch(collectBLResult(blError(EBizLogicMsg.NO_DEMO_THUNK_DATA))); } return result; } catch (e: any) { - result = dispatch(sysError(e)); + result = dispatch(collectSysError(e)); result = dispatch(requestFailed(config)); return result; } diff --git a/src/store/actions/sys.ts b/src/store/actions/sys.ts index 74a18410..a721934e 100644 --- a/src/store/actions/sys.ts +++ b/src/store/actions/sys.ts @@ -1,8 +1,9 @@ +import {ESys} from '../../constants'; import { RequestConfig, RequestFailedAction, RequestingAction, - RequestReceivedAction, + RequestSuccessAction, RestoreIsReadyAction, RestoreIsReadyPayload, RestoreNavInitialStateAction, @@ -13,9 +14,9 @@ import { SysWarnAction, SysWarnPayload } from '../../types'; -import {ESys} from '../../constants'; -export const sysError: (payload: Error) => SysErrorAction = (payload) => { + +export const collectSysError: (payload: Error) => SysErrorAction = (payload) => { return { type: ESys.ERROR, payload @@ -30,6 +31,7 @@ export const sysClearErrors: (payload: SysClearErrorPayload) => SysClearErrorsAc }; }; + export const sysWarn: (payload: SysWarnPayload) => SysWarnAction = (payload) => { return { type: ESys.WARN, @@ -37,12 +39,6 @@ export const sysWarn: (payload: SysWarnPayload) => SysWarnAction = (payload) => }; }; -export const restoreNavInitialState: (payload: RestoreNavInitialStatePayload) => RestoreNavInitialStateAction = (payload) => { - return { - type: ESys.RESTORE_NAV_INITIAL_STATE, - payload - }; -}; export const restoreIsReady: (payload: RestoreIsReadyPayload) => RestoreIsReadyAction = (payload) => { return { @@ -51,6 +47,14 @@ export const restoreIsReady: (payload: RestoreIsReadyPayload) => RestoreIsReadyA }; }; + +export const requestFailed: (payload: RequestConfig) => RequestFailedAction = (payload) => { + return { + type: ESys.REQUEST_FAILED, + payload + }; +}; + export const requesting: (payload: RequestConfig) => RequestingAction = (payload) => { return { type: ESys.REQUESTING, @@ -58,16 +62,18 @@ export const requesting: (payload: RequestConfig) => RequestingAction = (payload }; }; -export const requestReceived: (payload: RequestConfig) => RequestReceivedAction = (payload) => { + +export const requestSuccess: (payload: RequestConfig) => RequestSuccessAction = (payload) => { return { - type: ESys.REQUEST_RECEIVED, + type: ESys.REQUEST_SUCCESS, payload, }; }; -export const requestFailed: (payload: RequestConfig) => RequestFailedAction = (payload) => { + +export const restoreNavInitialState = (payload: RestoreNavInitialStatePayload): RestoreNavInitialStateAction => { return { - type: ESys.REQUEST_FAILED, + type: ESys.RESTORE_NAV_INITIAL_STATE, payload }; }; @@ -79,5 +85,5 @@ export type SysActions = | RestoreNavInitialStateAction | SysClearErrorsAction | RequestingAction - | RequestReceivedAction + | RequestSuccessAction | RequestFailedAction; diff --git a/src/store/index.ts b/src/store/index.ts index 60394a9c..19209b67 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -35,7 +35,7 @@ const sagaMiddleware = createSagaMiddleware(); // just delete the demos you not prefer,or just use them all // const store = createStore(rootReducer, applyMiddleware(thunkMiddleware)); // const store = createStore(rootReducer, applyMiddleware(sagaMiddleware)); -const store = createStore(rootReducer, applyMiddleware(thunkMiddleware, sagaMiddleware)); +export const store = createStore(rootReducer, applyMiddleware(thunkMiddleware, sagaMiddleware)); sagaMiddleware.run(sagasGenerator); // sagaMiddleware.run(saveQuickAlertSettingsSaga); diff --git a/src/store/reducers/sys.ts b/src/store/reducers/sys.ts index 4ea3fc49..82a1805d 100644 --- a/src/store/reducers/sys.ts +++ b/src/store/reducers/sys.ts @@ -67,7 +67,7 @@ export function sysStateReducer(prevState: SysState = initialState, {type, paylo return { ...prevState, }; - case ESys.REQUEST_RECEIVED: + case ESys.REQUEST_SUCCESS: const receivedPayload = payload as RequestReceivedPayload; _.remove(prevState.requestStatuses, item => (item.url === receivedPayload.url && item.method === receivedPayload.method && item.params === receivedPayload.params)); // prevState.requestStatuses.map(item=>{ diff --git a/src/store/sagas/sagas.ts b/src/store/sagas/sagas.ts index 46f87488..e81f5bcb 100644 --- a/src/store/sagas/sagas.ts +++ b/src/store/sagas/sagas.ts @@ -2,15 +2,15 @@ import {call, put, takeEvery} from 'redux-saga/effects'; import {bunnyAPI} from '../../helpers/bunny-api'; import { collectBLResult, + collectSysError, getDemoSagas, receiveGetCurrentPrice, receiveGetDemoSagas, requestFailed, requesting, - requestReceived, - sysError + requestSuccess } from '../actions'; -import {EBLMsg, EDemoCryptoCurrency, EDemoSaga, EDemoSagaFirebase} from '../../constants'; +import {EBizLogicMsg, EDemoCryptoCurrency, EDemoSaga, EDemoSagaFirebase} from '../../constants'; import { CancelAlertSettingsAction, RequestConfig, @@ -23,17 +23,17 @@ import {firebase} from '../../firebase'; export const sagasGenerator = function* () { yield takeEvery(EDemoSaga.GET_DEMO_SAGAS, function* (action: ReturnType) { const {payload} = action; - const url = '/demo-sagas'; + const url = '/api/example-saga-items'; const method = 'GET'; const config: RequestConfig = {url, method, params: payload}; try { yield put(requesting(config)); - const {data} = yield call(() => bunnyAPI.request(config)); - yield put(collectBLResult(blSuccess(data, EBLMsg.GET_DEMO_SAGAS_SUCCESS, false))); - yield put(receiveGetDemoSagas(data)); - yield put(requestReceived(config)); + const {data: {data}} = yield call(() => bunnyAPI.request(config)); + yield put(collectBLResult(blSuccess(data, EBizLogicMsg.GET_DEMO_SAGAS_SUCCESS, false))); + yield put(receiveGetDemoSagas(data.items)); + yield put(requestSuccess(config)); } catch (e: any) { - yield put(sysError(e)); + yield put(collectSysError(e)); yield put(requestFailed(config)); } }); @@ -46,10 +46,10 @@ export const sagasGenerator = function* () { try { yield put(requesting(config)); const {data} = yield call(() => bunnyAPI.request(config)); - yield put(collectBLResult(blSuccess(data, EBLMsg.SAVE_QUICK_ALERT_SETTINGS_SUCCESS))); - yield put(requestReceived(config)); + yield put(collectBLResult(blSuccess(data, EBizLogicMsg.SAVE_QUICK_ALERT_SETTINGS_SUCCESS))); + yield put(requestSuccess(config)); } catch (e: any) { - yield put(sysError(e)); + yield put(collectSysError(e)); yield put(requestFailed(config)); } }); @@ -62,10 +62,10 @@ export const sagasGenerator = function* () { try { yield put(requesting(config)); const {data} = yield call(() => bunnyAPI.request(config)); - yield put(collectBLResult(blSuccess(data, EBLMsg.CANCEL_ALL_ALERT_SETTINGS_SUCCESS))); - yield put(requestReceived(config)); + yield put(collectBLResult(blSuccess(data, EBizLogicMsg.CANCEL_ALL_ALERT_SETTINGS_SUCCESS))); + yield put(requestSuccess(config)); } catch (e: any) { - yield put(sysError(e)); + yield put(collectSysError(e)); yield put(requestFailed(config)); } }); @@ -78,10 +78,10 @@ export const sagasGenerator = function* () { yield put(requesting(config)); const {data} = yield call(() => bunnyAPI.request(config)); yield put(receiveGetCurrentPrice({currentPrice: data})); - yield put(collectBLResult(blSuccess(data, EBLMsg.GET_CURRENT_PRICE_SUCCESS, false))); - yield put(requestReceived(config)); + yield put(collectBLResult(blSuccess(data, EBizLogicMsg.GET_CURRENT_PRICE_SUCCESS, false))); + yield put(requestSuccess(config)); } catch (e: any) { - yield put(sysError(e)); + yield put(collectSysError(e)); yield put(requestFailed(config)); } }); @@ -97,9 +97,9 @@ export const sagasGenerator = function* () { const res = yield call(() => { return firebase.database().ref(url).push(payload); }); - yield put(requestReceived(config)); + yield put(requestSuccess(config)); } catch (e: any) { - yield put(sysError(e)); + yield put(collectSysError(e)); yield put(requestFailed(config)); } }); diff --git a/src/types/actions.ts b/src/types/actions.ts index 0084c520..679b5e12 100644 --- a/src/types/actions.ts +++ b/src/types/actions.ts @@ -27,6 +27,7 @@ import { } from './payloads'; import {DemoSaga, NearbyFilm, Region} from './models'; import {BLResult} from './bl'; +import {Method} from 'axios'; export interface DemoHelloAction { type: EDemoHello.DEMO_HELLO; @@ -83,8 +84,8 @@ export interface RequestingAction { payload: RequestConfig; } -export interface RequestReceivedAction { - type: ESys.REQUEST_RECEIVED; +export interface RequestSuccessAction { + type: ESys.REQUEST_SUCCESS; payload: RequestConfig; } @@ -142,3 +143,67 @@ export interface ReceiveGetCurrentPriceAction { type: EDemoCryptoCurrency.RECEIVE_CURRENT_PRICE, payload: ReceiveGetCurrentPricePayload } + + +export interface SysClearErrorsAction { + type: ESys.CLEAR_ERRORS; + payload: SysClearErrorPayload; +} + + +export interface SysWarnAction { + type: ESys.WARN; + payload: SysWarnPayload; +} + +export interface RestoreIsReadyAction { + type: ESys.RESTORE_IS_READY; + payload: RestoreIsReadyPayload; +} + +export interface RequestingAction { + type: ESys.REQUESTING; + payload: RequestConfig; +} + +export interface RequestSuccessAction { + type: ESys.REQUEST_SUCCESS; + payload: RequestConfig; +} + +export interface RequestFailedAction { + type: ESys.REQUEST_FAILED; + payload: RequestConfig; +} + +export interface RequestFailedPayload { + method: Method; + url: string; + params?: any; +} + +export interface RequestingAction { + type: ESys.REQUESTING; + payload: RequestConfig; +} + +export interface SysErrorAction { + type: ESys.ERROR; + payload: Error; +} + +export interface RequestFailedAction { + type: ESys.REQUEST_FAILED; + payload: RequestConfig; +} + +export interface RequestSuccessAction { + type: ESys.REQUEST_SUCCESS; + payload: RequestConfig; +} + +export interface RequestReceivedPayload { + method: Method; + url: string; + params?: any; +} diff --git a/src/types/payloads.ts b/src/types/payloads.ts index 8072dfeb..5e9cc0af 100644 --- a/src/types/payloads.ts +++ b/src/types/payloads.ts @@ -6,12 +6,12 @@ import {BLResult} from './bl'; import {SagaTodo} from './states'; export interface LoginParams { - email: string; + username: string; password: string; } export interface SignUpParams { - email: string; + username: string; password: string; } diff --git a/yarn.lock b/yarn.lock index 711cec36..eddcdd97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11587,11 +11587,6 @@ react-native-safe-area-context@3.2.0: resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.2.0.tgz#06113c6b208f982d68ab5c3cebd199ca93db6941" integrity sha512-k2Nty4PwSnrg9HwrYeeE+EYqViYJoOFwEy9LxL5RIRfoqxAq/uQXNGwpUg2/u4gnKpBbEPa9eRh15KKMe/VHkA== -react-native-safe-area-context@^3.2.0: - version "3.3.2" - resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-3.3.2.tgz#9549a2ce580f2374edb05e49d661258d1b8bcaed" - integrity sha512-yOwiiPJ1rk+/nfK13eafbpW6sKW0jOnsRem2C1LPJjM3tfTof6hlvV5eWHATye3XOpu2cJ7N+HdkUvUDGwFD2Q== - react-native-screens@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-3.0.0.tgz#ee4c2d69abf7411603868b57214feec5e8f637fa"