@developer_tribe/react-native-comnyx 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/App.js +59 -0
- package/lib/commonjs/App.js.map +1 -0
- package/lib/commonjs/__dev__.js +29 -0
- package/lib/commonjs/__dev__.js.map +1 -0
- package/lib/commonjs/api/api.js +22 -0
- package/lib/commonjs/api/api.js.map +1 -0
- package/lib/commonjs/api/conversations.js +37 -0
- package/lib/commonjs/api/conversations.js.map +1 -0
- package/lib/commonjs/api/customers.js +15 -0
- package/lib/commonjs/api/customers.js.map +1 -0
- package/lib/commonjs/api/index.js +33 -0
- package/lib/commonjs/api/index.js.map +1 -0
- package/lib/commonjs/api/messages.js +27 -0
- package/lib/commonjs/api/messages.js.map +1 -0
- package/lib/commonjs/assets/clock.png +0 -0
- package/lib/commonjs/assets/double-check.png +0 -0
- package/lib/commonjs/assets/down.png +0 -0
- package/lib/commonjs/assets/send.png +0 -0
- package/lib/commonjs/components/AppText.js +38 -0
- package/lib/commonjs/components/AppText.js.map +1 -0
- package/lib/commonjs/components/ChatList.js +268 -0
- package/lib/commonjs/components/ChatList.js.map +1 -0
- package/lib/commonjs/components/CustomerForm.js +213 -0
- package/lib/commonjs/components/CustomerForm.js.map +1 -0
- package/lib/commonjs/components/EmptyList.js +40 -0
- package/lib/commonjs/components/EmptyList.js.map +1 -0
- package/lib/commonjs/components/InitFailed.js +51 -0
- package/lib/commonjs/components/InitFailed.js.map +1 -0
- package/lib/commonjs/components/MessageInput.js +119 -0
- package/lib/commonjs/components/MessageInput.js.map +1 -0
- package/lib/commonjs/components/MessageItem.js +117 -0
- package/lib/commonjs/components/MessageItem.js.map +1 -0
- package/lib/commonjs/constants/translations.js +219 -0
- package/lib/commonjs/constants/translations.js.map +1 -0
- package/lib/commonjs/data/fake/conversations.js +95 -0
- package/lib/commonjs/data/fake/conversations.js.map +1 -0
- package/lib/commonjs/data/fake/customers.js +24 -0
- package/lib/commonjs/data/fake/customers.js.map +1 -0
- package/lib/commonjs/data/fake/messages.js +67 -0
- package/lib/commonjs/data/fake/messages.js.map +1 -0
- package/lib/commonjs/hooks/useLocalize.js +20 -0
- package/lib/commonjs/hooks/useLocalize.js.map +1 -0
- package/lib/commonjs/hooks/usePolling.js +50 -0
- package/lib/commonjs/hooks/usePolling.js.map +1 -0
- package/lib/commonjs/hooks/useThemeColors.js +17 -0
- package/lib/commonjs/hooks/useThemeColors.js.map +1 -0
- package/lib/commonjs/index.js +15 -6
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/register.js +21 -0
- package/lib/commonjs/register.js.map +1 -0
- package/lib/commonjs/store.js +79 -0
- package/lib/commonjs/store.js.map +1 -0
- package/lib/commonjs/types/ApiOptions.js +2 -0
- package/lib/commonjs/types/ApiOptions.js.map +1 -0
- package/lib/commonjs/types/Conversation.js +2 -0
- package/lib/commonjs/types/Conversation.js.map +1 -0
- package/lib/commonjs/types/Customer.js +2 -0
- package/lib/commonjs/types/Customer.js.map +1 -0
- package/lib/commonjs/types/Language.js +2 -0
- package/lib/commonjs/types/Language.js.map +1 -0
- package/lib/commonjs/types/LocalizationKeys.js +2 -0
- package/lib/commonjs/types/LocalizationKeys.js.map +1 -0
- package/lib/commonjs/types/MessageResponse.js +2 -0
- package/lib/commonjs/types/MessageResponse.js.map +1 -0
- package/lib/commonjs/types/Theme.js +29 -0
- package/lib/commonjs/types/Theme.js.map +1 -0
- package/lib/commonjs/utils/date.js +17 -0
- package/lib/commonjs/utils/date.js.map +1 -0
- package/lib/module/App.js +55 -0
- package/lib/module/App.js.map +1 -0
- package/lib/module/__dev__.js +29 -0
- package/lib/module/__dev__.js.map +1 -0
- package/lib/module/api/api.js +17 -0
- package/lib/module/api/api.js.map +1 -0
- package/lib/module/api/conversations.js +32 -0
- package/lib/module/api/conversations.js.map +1 -0
- package/lib/module/api/customers.js +11 -0
- package/lib/module/api/customers.js.map +1 -0
- package/lib/module/api/index.js +6 -0
- package/lib/module/api/index.js.map +1 -0
- package/lib/module/api/messages.js +23 -0
- package/lib/module/api/messages.js.map +1 -0
- package/lib/module/assets/clock.png +0 -0
- package/lib/module/assets/double-check.png +0 -0
- package/lib/module/assets/down.png +0 -0
- package/lib/module/assets/send.png +0 -0
- package/lib/module/components/AppText.js +34 -0
- package/lib/module/components/AppText.js.map +1 -0
- package/lib/module/components/ChatList.js +265 -0
- package/lib/module/components/ChatList.js.map +1 -0
- package/lib/module/components/CustomerForm.js +209 -0
- package/lib/module/components/CustomerForm.js.map +1 -0
- package/lib/module/components/EmptyList.js +36 -0
- package/lib/module/components/EmptyList.js.map +1 -0
- package/lib/module/components/InitFailed.js +47 -0
- package/lib/module/components/InitFailed.js.map +1 -0
- package/lib/module/components/MessageInput.js +115 -0
- package/lib/module/components/MessageInput.js.map +1 -0
- package/lib/module/components/MessageItem.js +114 -0
- package/lib/module/components/MessageItem.js.map +1 -0
- package/lib/module/constants/translations.js +215 -0
- package/lib/module/constants/translations.js.map +1 -0
- package/lib/module/data/fake/conversations.js +88 -0
- package/lib/module/data/fake/conversations.js.map +1 -0
- package/lib/module/data/fake/customers.js +20 -0
- package/lib/module/data/fake/customers.js.map +1 -0
- package/lib/module/data/fake/messages.js +63 -0
- package/lib/module/data/fake/messages.js.map +1 -0
- package/lib/module/hooks/useLocalize.js +16 -0
- package/lib/module/hooks/useLocalize.js.map +1 -0
- package/lib/module/hooks/usePolling.js +46 -0
- package/lib/module/hooks/usePolling.js.map +1 -0
- package/lib/module/hooks/useThemeColors.js +13 -0
- package/lib/module/hooks/useThemeColors.js.map +1 -0
- package/lib/module/index.js +3 -4
- package/lib/module/index.js.map +1 -1
- package/lib/module/register.js +17 -0
- package/lib/module/register.js.map +1 -0
- package/lib/module/store.js +74 -0
- package/lib/module/store.js.map +1 -0
- package/lib/module/types/ApiOptions.js +2 -0
- package/lib/module/types/ApiOptions.js.map +1 -0
- package/lib/module/types/Conversation.js +2 -0
- package/lib/module/types/Conversation.js.map +1 -0
- package/lib/module/types/Customer.js +2 -0
- package/lib/module/types/Customer.js.map +1 -0
- package/lib/module/types/Language.js +2 -0
- package/lib/module/types/Language.js.map +1 -0
- package/lib/module/types/LocalizationKeys.js +2 -0
- package/lib/module/types/LocalizationKeys.js.map +1 -0
- package/lib/module/types/MessageResponse.js +2 -0
- package/lib/module/types/MessageResponse.js.map +1 -0
- package/lib/module/types/Theme.js +25 -0
- package/lib/module/types/Theme.js.map +1 -0
- package/lib/module/utils/date.js +12 -0
- package/lib/module/utils/date.js.map +1 -0
- package/lib/typescript/commonjs/src/App.d.ts +9 -0
- package/lib/typescript/commonjs/src/App.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/__dev__.d.ts +2 -0
- package/lib/typescript/commonjs/src/__dev__.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/api/api.d.ts +4 -0
- package/lib/typescript/commonjs/src/api/api.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/api/conversations.d.ts +7 -0
- package/lib/typescript/commonjs/src/api/conversations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/api/customers.d.ts +4 -0
- package/lib/typescript/commonjs/src/api/customers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/api/index.d.ts +4 -0
- package/lib/typescript/commonjs/src/api/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/api/messages.d.ts +4 -0
- package/lib/typescript/commonjs/src/api/messages.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/AppText.d.ts +10 -0
- package/lib/typescript/commonjs/src/components/AppText.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/ChatList.d.ts +2 -0
- package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/CustomerForm.d.ts +2 -0
- package/lib/typescript/commonjs/src/components/CustomerForm.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/EmptyList.d.ts +2 -0
- package/lib/typescript/commonjs/src/components/EmptyList.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/InitFailed.d.ts +6 -0
- package/lib/typescript/commonjs/src/components/InitFailed.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/MessageInput.d.ts +4 -0
- package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/components/MessageItem.d.ts +5 -0
- package/lib/typescript/commonjs/src/components/MessageItem.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/constants/translations.d.ts +4 -0
- package/lib/typescript/commonjs/src/constants/translations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/data/fake/conversations.d.ts +5 -0
- package/lib/typescript/commonjs/src/data/fake/conversations.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/data/fake/customers.d.ts +3 -0
- package/lib/typescript/commonjs/src/data/fake/customers.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/data/fake/messages.d.ts +3 -0
- package/lib/typescript/commonjs/src/data/fake/messages.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useLocalize.d.ts +3 -0
- package/lib/typescript/commonjs/src/hooks/useLocalize.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/usePolling.d.ts +2 -0
- package/lib/typescript/commonjs/src/hooks/usePolling.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useThemeColors.d.ts +3 -0
- package/lib/typescript/commonjs/src/hooks/useThemeColors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/register.d.ts +5 -0
- package/lib/typescript/commonjs/src/register.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/store.d.ts +35 -0
- package/lib/typescript/commonjs/src/store.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/ApiOptions.d.ts +4 -0
- package/lib/typescript/commonjs/src/types/ApiOptions.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/Conversation.d.ts +26 -0
- package/lib/typescript/commonjs/src/types/Conversation.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/Customer.d.ts +30 -0
- package/lib/typescript/commonjs/src/types/Customer.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/Language.d.ts +2 -0
- package/lib/typescript/commonjs/src/types/Language.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/LocalizationKeys.d.ts +22 -0
- package/lib/typescript/commonjs/src/types/LocalizationKeys.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/MessageResponse.d.ts +59 -0
- package/lib/typescript/commonjs/src/types/MessageResponse.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types/Theme.d.ts +18 -0
- package/lib/typescript/commonjs/src/types/Theme.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/utils/date.d.ts +7 -0
- package/lib/typescript/commonjs/src/utils/date.d.ts.map +1 -0
- package/lib/typescript/module/src/App.d.ts +9 -0
- package/lib/typescript/module/src/App.d.ts.map +1 -0
- package/lib/typescript/module/src/__dev__.d.ts +2 -0
- package/lib/typescript/module/src/__dev__.d.ts.map +1 -0
- package/lib/typescript/module/src/api/api.d.ts +4 -0
- package/lib/typescript/module/src/api/api.d.ts.map +1 -0
- package/lib/typescript/module/src/api/conversations.d.ts +7 -0
- package/lib/typescript/module/src/api/conversations.d.ts.map +1 -0
- package/lib/typescript/module/src/api/customers.d.ts +4 -0
- package/lib/typescript/module/src/api/customers.d.ts.map +1 -0
- package/lib/typescript/module/src/api/index.d.ts +4 -0
- package/lib/typescript/module/src/api/index.d.ts.map +1 -0
- package/lib/typescript/module/src/api/messages.d.ts +4 -0
- package/lib/typescript/module/src/api/messages.d.ts.map +1 -0
- package/lib/typescript/module/src/components/AppText.d.ts +10 -0
- package/lib/typescript/module/src/components/AppText.d.ts.map +1 -0
- package/lib/typescript/module/src/components/ChatList.d.ts +2 -0
- package/lib/typescript/module/src/components/ChatList.d.ts.map +1 -0
- package/lib/typescript/module/src/components/CustomerForm.d.ts +2 -0
- package/lib/typescript/module/src/components/CustomerForm.d.ts.map +1 -0
- package/lib/typescript/module/src/components/EmptyList.d.ts +2 -0
- package/lib/typescript/module/src/components/EmptyList.d.ts.map +1 -0
- package/lib/typescript/module/src/components/InitFailed.d.ts +6 -0
- package/lib/typescript/module/src/components/InitFailed.d.ts.map +1 -0
- package/lib/typescript/module/src/components/MessageInput.d.ts +4 -0
- package/lib/typescript/module/src/components/MessageInput.d.ts.map +1 -0
- package/lib/typescript/module/src/components/MessageItem.d.ts +5 -0
- package/lib/typescript/module/src/components/MessageItem.d.ts.map +1 -0
- package/lib/typescript/module/src/constants/translations.d.ts +4 -0
- package/lib/typescript/module/src/constants/translations.d.ts.map +1 -0
- package/lib/typescript/module/src/data/fake/conversations.d.ts +5 -0
- package/lib/typescript/module/src/data/fake/conversations.d.ts.map +1 -0
- package/lib/typescript/module/src/data/fake/customers.d.ts +3 -0
- package/lib/typescript/module/src/data/fake/customers.d.ts.map +1 -0
- package/lib/typescript/module/src/data/fake/messages.d.ts +3 -0
- package/lib/typescript/module/src/data/fake/messages.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useLocalize.d.ts +3 -0
- package/lib/typescript/module/src/hooks/useLocalize.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/usePolling.d.ts +2 -0
- package/lib/typescript/module/src/hooks/usePolling.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useThemeColors.d.ts +3 -0
- package/lib/typescript/module/src/hooks/useThemeColors.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/register.d.ts +5 -0
- package/lib/typescript/module/src/register.d.ts.map +1 -0
- package/lib/typescript/module/src/store.d.ts +35 -0
- package/lib/typescript/module/src/store.d.ts.map +1 -0
- package/lib/typescript/module/src/types/ApiOptions.d.ts +4 -0
- package/lib/typescript/module/src/types/ApiOptions.d.ts.map +1 -0
- package/lib/typescript/module/src/types/Conversation.d.ts +26 -0
- package/lib/typescript/module/src/types/Conversation.d.ts.map +1 -0
- package/lib/typescript/module/src/types/Customer.d.ts +30 -0
- package/lib/typescript/module/src/types/Customer.d.ts.map +1 -0
- package/lib/typescript/module/src/types/Language.d.ts +2 -0
- package/lib/typescript/module/src/types/Language.d.ts.map +1 -0
- package/lib/typescript/module/src/types/LocalizationKeys.d.ts +22 -0
- package/lib/typescript/module/src/types/LocalizationKeys.d.ts.map +1 -0
- package/lib/typescript/module/src/types/MessageResponse.d.ts +59 -0
- package/lib/typescript/module/src/types/MessageResponse.d.ts.map +1 -0
- package/lib/typescript/module/src/types/Theme.d.ts +18 -0
- package/lib/typescript/module/src/types/Theme.d.ts.map +1 -0
- package/lib/typescript/module/src/utils/date.d.ts +7 -0
- package/lib/typescript/module/src/utils/date.d.ts.map +1 -0
- package/package.json +10 -2
- package/src/App.tsx +59 -0
- package/src/__dev__.ts +22 -0
- package/src/api/api.ts +16 -0
- package/src/api/conversations.ts +53 -0
- package/src/api/customers.ts +16 -0
- package/src/api/index.ts +6 -0
- package/src/api/messages.ts +33 -0
- package/src/assets/clock.png +0 -0
- package/src/assets/double-check.png +0 -0
- package/src/assets/down.png +0 -0
- package/src/assets/send.png +0 -0
- package/src/components/AppText.tsx +43 -0
- package/src/components/ChatList.tsx +305 -0
- package/src/components/CustomerForm.tsx +203 -0
- package/src/components/EmptyList.tsx +32 -0
- package/src/components/InitFailed.tsx +46 -0
- package/src/components/MessageInput.tsx +133 -0
- package/src/components/MessageItem.tsx +141 -0
- package/src/constants/translations.ts +232 -0
- package/src/data/fake/conversations.ts +558 -0
- package/src/data/fake/customers.ts +19 -0
- package/src/data/fake/messages.ts +64 -0
- package/src/hooks/useLocalize.ts +18 -0
- package/src/hooks/usePolling.ts +46 -0
- package/src/hooks/useThemeColors.ts +10 -0
- package/src/index.tsx +4 -5
- package/src/register.ts +17 -0
- package/src/store.ts +85 -0
- package/src/types/ApiOptions.ts +4 -0
- package/src/types/Conversation.ts +29 -0
- package/src/types/Customer.ts +31 -0
- package/src/types/Language.ts +11 -0
- package/src/types/LocalizationKeys.ts +21 -0
- package/src/types/MessageResponse.ts +58 -0
- package/src/types/Theme.ts +40 -0
- package/src/utils/date.ts +11 -0
- package/.editorconfig +0 -15
- package/.gitattributes +0 -3
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -68
- package/.github/ISSUE_TEMPLATE/config.yml +0 -8
- package/.github/actions/setup/action.yml +0 -36
- package/.github/workflows/ci.yml +0 -165
- package/.gitignore +0 -86
- package/.idea/.gitignore +0 -8
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/comnyx-rn.iml +0 -12
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -71
- package/.nvmrc +0 -1
- package/.watchmanconfig +0 -1
- package/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
- package/.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs +0 -28
- package/.yarn/releases/yarn-3.6.1.cjs +0 -874
- package/.yarnrc.yml +0 -10
- package/CODE_OF_CONDUCT.md +0 -133
- package/CONTRIBUTING.md +0 -130
- package/babel.config.js +0 -3
- package/example/.bundle/config +0 -2
- package/example/.watchmanconfig +0 -1
- package/example/Gemfile +0 -10
- package/example/README.md +0 -97
- package/example/android/app/build.gradle +0 -133
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +0 -10
- package/example/android/app/src/debug/AndroidManifest.xml +0 -9
- package/example/android/app/src/main/AndroidManifest.xml +0 -26
- package/example/android/app/src/main/java/comnyx/example/MainActivity.kt +0 -22
- package/example/android/app/src/main/java/comnyx/example/MainApplication.kt +0 -44
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -37
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +0 -3
- package/example/android/app/src/main/res/values/styles.xml +0 -9
- package/example/android/build.gradle +0 -21
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/example/android/gradle.properties +0 -39
- package/example/android/gradlew +0 -251
- package/example/android/gradlew.bat +0 -94
- package/example/android/settings.gradle +0 -6
- package/example/app.json +0 -4
- package/example/babel.config.js +0 -12
- package/example/index.js +0 -5
- package/example/ios/.xcode.env +0 -11
- package/example/ios/ComnyxExample/AppDelegate.swift +0 -30
- package/example/ios/ComnyxExample/Images.xcassets/AppIcon.appiconset/Contents.json +0 -53
- package/example/ios/ComnyxExample/Images.xcassets/Contents.json +0 -6
- package/example/ios/ComnyxExample/Info.plist +0 -52
- package/example/ios/ComnyxExample/LaunchScreen.storyboard +0 -47
- package/example/ios/ComnyxExample/PrivacyInfo.xcprivacy +0 -37
- package/example/ios/ComnyxExample.xcodeproj/project.pbxproj +0 -505
- package/example/ios/ComnyxExample.xcodeproj/xcshareddata/xcschemes/ComnyxExample.xcscheme +0 -88
- package/example/ios/Podfile +0 -43
- package/example/jest.config.js +0 -3
- package/example/metro.config.js +0 -18
- package/example/package.json +0 -31
- package/example/react-native.config.js +0 -21
- package/example/src/App.tsx +0 -20
- package/lefthook.yml +0 -14
- package/lib/typescript/commonjs/src/__tests__/index.test.d.ts +0 -1
- package/lib/typescript/commonjs/src/__tests__/index.test.d.ts.map +0 -1
- package/lib/typescript/module/src/__tests__/index.test.d.ts +0 -1
- package/lib/typescript/module/src/__tests__/index.test.d.ts.map +0 -1
- package/src/__tests__/index.test.tsx +0 -1
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -30
- package/turbo.json +0 -36
- package/yarn.lock +0 -9251
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useAppStore } from '../store';
|
|
3
|
+
import {
|
|
4
|
+
FlatList,
|
|
5
|
+
View,
|
|
6
|
+
useWindowDimensions,
|
|
7
|
+
ActivityIndicator,
|
|
8
|
+
Image,
|
|
9
|
+
TouchableOpacity,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { getCustomerConversation } from '../api';
|
|
12
|
+
import type { AppConversationMessage } from '../types/Conversation';
|
|
13
|
+
import { StyleSheet } from 'react-native';
|
|
14
|
+
import { MessageItem } from './MessageItem';
|
|
15
|
+
import { MessageInput } from './MessageInput';
|
|
16
|
+
import { useThemeColors } from '../hooks/useThemeColors';
|
|
17
|
+
import { AppText } from './AppText';
|
|
18
|
+
import { InitFailed } from './InitFailed';
|
|
19
|
+
import { EmptyList } from './EmptyList';
|
|
20
|
+
|
|
21
|
+
function LoadingItem() {
|
|
22
|
+
const themeColors = useThemeColors();
|
|
23
|
+
return (
|
|
24
|
+
<View
|
|
25
|
+
style={[styles.loadingItem, { backgroundColor: themeColors.background }]}
|
|
26
|
+
>
|
|
27
|
+
<ActivityIndicator size="large" color={themeColors.primary} />
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function ChatList() {
|
|
33
|
+
const themeColors = useThemeColors();
|
|
34
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
35
|
+
const MESSAGE_MIN_HEIGHT = 60;
|
|
36
|
+
const FLATLIST_PADDING = 20;
|
|
37
|
+
const MESSAGES_PER_PAGE = Math.ceil(
|
|
38
|
+
(windowHeight - FLATLIST_PADDING) / MESSAGE_MIN_HEIGHT
|
|
39
|
+
);
|
|
40
|
+
const [loading, setLoading] = useState(true);
|
|
41
|
+
const { customer, data, setData } = useAppStore((s) => ({
|
|
42
|
+
customer: s.customer,
|
|
43
|
+
data: s.data,
|
|
44
|
+
setData: s.setData,
|
|
45
|
+
}));
|
|
46
|
+
const ref = useRef<FlatList<AppConversationMessage>>(null);
|
|
47
|
+
const [page, setPage] = useState(1);
|
|
48
|
+
const nextPageStatus = useRef<'fail' | 'loading' | 'empty'>();
|
|
49
|
+
const [nexPageFailed, setNexPageFailed] = useState(false);
|
|
50
|
+
const [initFailed, setInitFailed] = useState(false);
|
|
51
|
+
const [isScrollingUp, setIsScrollingUp] = useState(false);
|
|
52
|
+
const listChangedRef = useRef(false);
|
|
53
|
+
|
|
54
|
+
const nextPage = useCallback(() => {
|
|
55
|
+
if (nextPageStatus.current) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
nextPageStatus.current = 'loading';
|
|
59
|
+
if (customer?.external_id) {
|
|
60
|
+
const newPage = page + 1;
|
|
61
|
+
setPage(newPage);
|
|
62
|
+
const firstMessage = useAppStore.getState().firstMessage;
|
|
63
|
+
getCustomerConversation(
|
|
64
|
+
customer?.external_id,
|
|
65
|
+
firstMessage?.created_at,
|
|
66
|
+
newPage,
|
|
67
|
+
{
|
|
68
|
+
fake: useAppStore.getState().fake,
|
|
69
|
+
per_page: MESSAGES_PER_PAGE,
|
|
70
|
+
}
|
|
71
|
+
)
|
|
72
|
+
.then((newData) => {
|
|
73
|
+
listChangedRef.current = true;
|
|
74
|
+
setData((prevData) => {
|
|
75
|
+
const newMessages = newData.page.data;
|
|
76
|
+
const existingIds = new Set(prevData?.map((msg) => msg.id));
|
|
77
|
+
const uniqueNewMessages = newMessages.filter(
|
|
78
|
+
(msg) => !existingIds.has(msg.id)
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const processedMessages = uniqueNewMessages.map((u) => ({
|
|
82
|
+
...u,
|
|
83
|
+
created_at: new Date(u.created_at),
|
|
84
|
+
approved: true,
|
|
85
|
+
}));
|
|
86
|
+
if (processedMessages.length === 0) {
|
|
87
|
+
nextPageStatus.current = 'empty';
|
|
88
|
+
} else {
|
|
89
|
+
nextPageStatus.current = undefined;
|
|
90
|
+
}
|
|
91
|
+
return [...(prevData ?? []), ...processedMessages];
|
|
92
|
+
});
|
|
93
|
+
})
|
|
94
|
+
.catch((_) => {
|
|
95
|
+
nextPageStatus.current = 'fail';
|
|
96
|
+
setNexPageFailed(true);
|
|
97
|
+
})
|
|
98
|
+
.finally(() => {
|
|
99
|
+
setLoading(false);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}, [MESSAGES_PER_PAGE, customer?.external_id, page, setData]);
|
|
103
|
+
|
|
104
|
+
const renderItem = useCallback(
|
|
105
|
+
({ item }: { item: AppConversationMessage }) => <MessageItem item={item} />,
|
|
106
|
+
[]
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
const handleScroll = useCallback(
|
|
110
|
+
(event: any) => {
|
|
111
|
+
const currentScrollY = event.nativeEvent.contentOffset.y;
|
|
112
|
+
const contentHeight = event.nativeEvent.contentSize.height;
|
|
113
|
+
const scrollViewHeight = event.nativeEvent.layoutMeasurement.height;
|
|
114
|
+
setIsScrollingUp(currentScrollY < 100);
|
|
115
|
+
|
|
116
|
+
if (currentScrollY >= contentHeight - scrollViewHeight - 200) {
|
|
117
|
+
nextPage();
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
[nextPage]
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const scrollToBottom = useCallback(
|
|
124
|
+
(animated: boolean) => {
|
|
125
|
+
if (ref.current && data?.length) {
|
|
126
|
+
ref.current.scrollToOffset({
|
|
127
|
+
offset: 0,
|
|
128
|
+
animated,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
[data]
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (customer?.external_id && !initFailed) {
|
|
137
|
+
getCustomerConversation(customer?.external_id, new Date(), 1, {
|
|
138
|
+
fake: useAppStore.getState().fake,
|
|
139
|
+
per_page: MESSAGES_PER_PAGE,
|
|
140
|
+
})
|
|
141
|
+
.then((newData) => {
|
|
142
|
+
setData((prevData) => {
|
|
143
|
+
const newMessages = newData.page.data;
|
|
144
|
+
const existingIds = new Set(prevData?.map((msg) => msg.id));
|
|
145
|
+
const uniqueNewMessages = newMessages.filter(
|
|
146
|
+
(msg) => !existingIds.has(msg.id)
|
|
147
|
+
);
|
|
148
|
+
const processedMessages = uniqueNewMessages.map((u) => ({
|
|
149
|
+
...u,
|
|
150
|
+
created_at: new Date(u.created_at),
|
|
151
|
+
approved: true,
|
|
152
|
+
}));
|
|
153
|
+
useAppStore.setState({
|
|
154
|
+
firstMessage: processedMessages[0],
|
|
155
|
+
});
|
|
156
|
+
if (processedMessages.length === 0) {
|
|
157
|
+
setLoading(false);
|
|
158
|
+
}
|
|
159
|
+
return processedMessages;
|
|
160
|
+
});
|
|
161
|
+
scrollToBottom(false);
|
|
162
|
+
})
|
|
163
|
+
.catch((e) => {
|
|
164
|
+
setInitFailed(true);
|
|
165
|
+
console.error(e);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}, [
|
|
169
|
+
MESSAGES_PER_PAGE,
|
|
170
|
+
customer?.external_id,
|
|
171
|
+
initFailed,
|
|
172
|
+
scrollToBottom,
|
|
173
|
+
setData,
|
|
174
|
+
]);
|
|
175
|
+
|
|
176
|
+
if (nexPageFailed) {
|
|
177
|
+
return (
|
|
178
|
+
<View
|
|
179
|
+
style={[
|
|
180
|
+
styles.retryContainer,
|
|
181
|
+
{ backgroundColor: themeColors.background },
|
|
182
|
+
]}
|
|
183
|
+
>
|
|
184
|
+
<TouchableOpacity
|
|
185
|
+
style={[styles.retryButton, { backgroundColor: themeColors.primary }]}
|
|
186
|
+
onPress={() => {
|
|
187
|
+
setNexPageFailed(false);
|
|
188
|
+
nextPageStatus.current = undefined;
|
|
189
|
+
nextPage();
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
<AppText
|
|
193
|
+
localization="chat.load.error"
|
|
194
|
+
style={[styles.retryText, { color: themeColors.background }]}
|
|
195
|
+
/>
|
|
196
|
+
</TouchableOpacity>
|
|
197
|
+
</View>
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (initFailed) {
|
|
202
|
+
return <InitFailed setInitFailed={setInitFailed} />;
|
|
203
|
+
}
|
|
204
|
+
return (
|
|
205
|
+
<View
|
|
206
|
+
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
207
|
+
>
|
|
208
|
+
<FlatList
|
|
209
|
+
ref={ref}
|
|
210
|
+
data={data}
|
|
211
|
+
inverted
|
|
212
|
+
renderItem={renderItem}
|
|
213
|
+
contentContainerStyle={[
|
|
214
|
+
styles.contentContainer,
|
|
215
|
+
{ backgroundColor: themeColors.background },
|
|
216
|
+
]}
|
|
217
|
+
style={styles.list}
|
|
218
|
+
ListEmptyComponent={
|
|
219
|
+
!loading && (!data || data.length === 0) ? <EmptyList /> : null
|
|
220
|
+
}
|
|
221
|
+
ListFooterComponent={loading ? <LoadingItem /> : null}
|
|
222
|
+
keyExtractor={(item) => item.id + '-' + item.created_at}
|
|
223
|
+
removeClippedSubviews={true}
|
|
224
|
+
maxToRenderPerBatch={10}
|
|
225
|
+
windowSize={21}
|
|
226
|
+
initialNumToRender={MESSAGES_PER_PAGE}
|
|
227
|
+
getItemLayout={(_, index) => ({
|
|
228
|
+
length: MESSAGE_MIN_HEIGHT + 10,
|
|
229
|
+
offset: (MESSAGE_MIN_HEIGHT + 10) * index,
|
|
230
|
+
index,
|
|
231
|
+
})}
|
|
232
|
+
onScroll={handleScroll}
|
|
233
|
+
scrollEventThrottle={16}
|
|
234
|
+
/>
|
|
235
|
+
{isScrollingUp && (
|
|
236
|
+
<TouchableOpacity
|
|
237
|
+
style={[
|
|
238
|
+
styles.scrollDownButton,
|
|
239
|
+
{ backgroundColor: themeColors.background },
|
|
240
|
+
]}
|
|
241
|
+
onPress={() => scrollToBottom(true)}
|
|
242
|
+
>
|
|
243
|
+
<Image
|
|
244
|
+
source={require('../assets/down.png')}
|
|
245
|
+
style={[styles.scrollUpIcon, { tintColor: themeColors.text }]}
|
|
246
|
+
/>
|
|
247
|
+
</TouchableOpacity>
|
|
248
|
+
)}
|
|
249
|
+
<MessageInput scrollToBottom={scrollToBottom} />
|
|
250
|
+
</View>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const styles = StyleSheet.create({
|
|
255
|
+
container: {
|
|
256
|
+
flex: 1,
|
|
257
|
+
},
|
|
258
|
+
list: {
|
|
259
|
+
flex: 1,
|
|
260
|
+
},
|
|
261
|
+
contentContainer: {
|
|
262
|
+
paddingVertical: 10,
|
|
263
|
+
paddingHorizontal: 10,
|
|
264
|
+
},
|
|
265
|
+
loadingItem: {
|
|
266
|
+
height: 200,
|
|
267
|
+
alignItems: 'center',
|
|
268
|
+
justifyContent: 'center',
|
|
269
|
+
},
|
|
270
|
+
scrollDownButton: {
|
|
271
|
+
position: 'absolute',
|
|
272
|
+
right: 20,
|
|
273
|
+
bottom: '15%',
|
|
274
|
+
borderRadius: 25,
|
|
275
|
+
padding: 10,
|
|
276
|
+
shadowColor: '#000',
|
|
277
|
+
shadowOffset: {
|
|
278
|
+
width: 0,
|
|
279
|
+
height: 2,
|
|
280
|
+
},
|
|
281
|
+
shadowOpacity: 0.25,
|
|
282
|
+
shadowRadius: 3.84,
|
|
283
|
+
elevation: 5,
|
|
284
|
+
},
|
|
285
|
+
scrollUpIcon: {
|
|
286
|
+
width: 24,
|
|
287
|
+
height: 24,
|
|
288
|
+
},
|
|
289
|
+
retryContainer: {
|
|
290
|
+
flex: 1,
|
|
291
|
+
alignItems: 'center',
|
|
292
|
+
justifyContent: 'center',
|
|
293
|
+
padding: 20,
|
|
294
|
+
},
|
|
295
|
+
retryButton: {
|
|
296
|
+
padding: 15,
|
|
297
|
+
borderRadius: 8,
|
|
298
|
+
alignItems: 'center',
|
|
299
|
+
justifyContent: 'center',
|
|
300
|
+
},
|
|
301
|
+
retryText: {
|
|
302
|
+
fontSize: 16,
|
|
303
|
+
fontWeight: '500',
|
|
304
|
+
},
|
|
305
|
+
});
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { View, TextInput, StyleSheet, TouchableOpacity } from 'react-native';
|
|
2
|
+
import { useForm, Controller } from 'react-hook-form';
|
|
3
|
+
import { useAppStore } from '../store';
|
|
4
|
+
import { createCustomer } from '../api';
|
|
5
|
+
import { AppText } from './AppText';
|
|
6
|
+
import { useLocalize } from '../hooks/useLocalize';
|
|
7
|
+
import { useThemeColors } from '../hooks/useThemeColors';
|
|
8
|
+
|
|
9
|
+
interface CustomerFormData {
|
|
10
|
+
name: string;
|
|
11
|
+
country: string;
|
|
12
|
+
email: string;
|
|
13
|
+
phone: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function CustomerForm() {
|
|
17
|
+
const {
|
|
18
|
+
control,
|
|
19
|
+
handleSubmit,
|
|
20
|
+
formState: { errors },
|
|
21
|
+
} = useForm<CustomerFormData>();
|
|
22
|
+
const themeColors = useThemeColors();
|
|
23
|
+
const localize = useLocalize();
|
|
24
|
+
|
|
25
|
+
const inputStyle = {
|
|
26
|
+
...styles.input,
|
|
27
|
+
color: themeColors.text,
|
|
28
|
+
borderColor: themeColors.border,
|
|
29
|
+
backgroundColor: themeColors.background,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const onSubmit = async (data: CustomerFormData) => {
|
|
33
|
+
try {
|
|
34
|
+
const customer = await createCustomer(
|
|
35
|
+
{
|
|
36
|
+
...data,
|
|
37
|
+
language: 'en',
|
|
38
|
+
externalId: useAppStore.getState().externalId || '',
|
|
39
|
+
ipAddress: '192.168.1.1',
|
|
40
|
+
customParameters: [],
|
|
41
|
+
},
|
|
42
|
+
{ fake: useAppStore.getState().fake }
|
|
43
|
+
);
|
|
44
|
+
if (customer !== undefined) {
|
|
45
|
+
useAppStore.getState().initForm(customer);
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.error('Error creating customer:', error);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View
|
|
54
|
+
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
55
|
+
>
|
|
56
|
+
<View style={styles.headerContainer}>
|
|
57
|
+
<AppText
|
|
58
|
+
localization="customer.form.title"
|
|
59
|
+
style={[styles.headerText, { color: themeColors.text }]}
|
|
60
|
+
/>
|
|
61
|
+
<AppText
|
|
62
|
+
localization="customer.form.instructions"
|
|
63
|
+
style={[styles.headerText, { color: themeColors.text }]}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
<Controller
|
|
67
|
+
control={control}
|
|
68
|
+
rules={{ required: true }}
|
|
69
|
+
render={({ field: { onChange, value } }) => (
|
|
70
|
+
<TextInput
|
|
71
|
+
style={inputStyle}
|
|
72
|
+
placeholder={localize('customer.form.placeholder.name')}
|
|
73
|
+
placeholderTextColor="#6C757D"
|
|
74
|
+
value={value}
|
|
75
|
+
onChangeText={onChange}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
name="name"
|
|
79
|
+
/>
|
|
80
|
+
{errors.name && (
|
|
81
|
+
<AppText
|
|
82
|
+
localization="customer.form.error"
|
|
83
|
+
style={[styles.error, { color: themeColors.error }]}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
|
+
|
|
87
|
+
<Controller
|
|
88
|
+
control={control}
|
|
89
|
+
rules={{ required: true }}
|
|
90
|
+
render={({ field: { onChange, value } }) => (
|
|
91
|
+
<TextInput
|
|
92
|
+
style={inputStyle}
|
|
93
|
+
placeholder={localize('customer.form.placeholder.country')}
|
|
94
|
+
placeholderTextColor="#6C757D"
|
|
95
|
+
value={value}
|
|
96
|
+
onChangeText={onChange}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
name="country"
|
|
100
|
+
/>
|
|
101
|
+
{errors.country && (
|
|
102
|
+
<AppText
|
|
103
|
+
localization="customer.form.error.country"
|
|
104
|
+
style={[styles.error, { color: themeColors.error }]}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
|
|
108
|
+
<Controller
|
|
109
|
+
control={control}
|
|
110
|
+
rules={{ required: true, pattern: /^\S+@\S+$/i }}
|
|
111
|
+
render={({ field: { onChange, value } }) => (
|
|
112
|
+
<TextInput
|
|
113
|
+
style={inputStyle}
|
|
114
|
+
placeholder={localize('customer.form.placeholder.email')}
|
|
115
|
+
placeholderTextColor="#6C757D"
|
|
116
|
+
value={value}
|
|
117
|
+
onChangeText={onChange}
|
|
118
|
+
keyboardType="email-address"
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
name="email"
|
|
122
|
+
/>
|
|
123
|
+
{errors.email && (
|
|
124
|
+
<AppText
|
|
125
|
+
localization="customer.form.error.email"
|
|
126
|
+
style={[styles.error, { color: themeColors.error }]}
|
|
127
|
+
/>
|
|
128
|
+
)}
|
|
129
|
+
|
|
130
|
+
<Controller
|
|
131
|
+
control={control}
|
|
132
|
+
rules={{ required: true }}
|
|
133
|
+
render={({ field: { onChange, value } }) => (
|
|
134
|
+
<TextInput
|
|
135
|
+
style={inputStyle}
|
|
136
|
+
placeholder={localize('customer.form.placeholder.phone')}
|
|
137
|
+
placeholderTextColor="#6C757D"
|
|
138
|
+
value={value}
|
|
139
|
+
onChangeText={onChange}
|
|
140
|
+
keyboardType="phone-pad"
|
|
141
|
+
/>
|
|
142
|
+
)}
|
|
143
|
+
name="phone"
|
|
144
|
+
/>
|
|
145
|
+
{errors.phone && (
|
|
146
|
+
<AppText
|
|
147
|
+
localization="customer.form.error.phone"
|
|
148
|
+
style={[styles.error, { color: themeColors.error }]}
|
|
149
|
+
/>
|
|
150
|
+
)}
|
|
151
|
+
<TouchableOpacity
|
|
152
|
+
style={[styles.button, { backgroundColor: themeColors.primary }]}
|
|
153
|
+
onPress={handleSubmit(onSubmit)}
|
|
154
|
+
>
|
|
155
|
+
<AppText
|
|
156
|
+
localization="customer.form.submit"
|
|
157
|
+
style={styles.buttonText}
|
|
158
|
+
/>
|
|
159
|
+
</TouchableOpacity>
|
|
160
|
+
</View>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const styles = StyleSheet.create({
|
|
165
|
+
container: {
|
|
166
|
+
padding: 24,
|
|
167
|
+
flex: 1,
|
|
168
|
+
justifyContent: 'center',
|
|
169
|
+
},
|
|
170
|
+
headerContainer: {
|
|
171
|
+
marginBottom: 24,
|
|
172
|
+
},
|
|
173
|
+
headerText: {
|
|
174
|
+
fontSize: 15,
|
|
175
|
+
fontWeight: '600',
|
|
176
|
+
textAlign: 'center',
|
|
177
|
+
},
|
|
178
|
+
input: {
|
|
179
|
+
height: 56,
|
|
180
|
+
borderWidth: 1,
|
|
181
|
+
borderRadius: 12,
|
|
182
|
+
paddingHorizontal: 16,
|
|
183
|
+
fontSize: 16,
|
|
184
|
+
backgroundColor: 'white',
|
|
185
|
+
marginBottom: 16,
|
|
186
|
+
},
|
|
187
|
+
button: {
|
|
188
|
+
padding: 16,
|
|
189
|
+
borderRadius: 12,
|
|
190
|
+
alignItems: 'center',
|
|
191
|
+
marginTop: 24,
|
|
192
|
+
},
|
|
193
|
+
buttonText: {
|
|
194
|
+
color: 'white',
|
|
195
|
+
fontSize: 16,
|
|
196
|
+
fontWeight: '600',
|
|
197
|
+
},
|
|
198
|
+
error: {
|
|
199
|
+
fontSize: 14,
|
|
200
|
+
marginLeft: 16,
|
|
201
|
+
top: -16,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { View, StyleSheet } from 'react-native';
|
|
2
|
+
import { useThemeColors } from '../hooks/useThemeColors';
|
|
3
|
+
import { AppText } from './AppText';
|
|
4
|
+
|
|
5
|
+
export function EmptyList() {
|
|
6
|
+
const themeColors = useThemeColors();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<View
|
|
10
|
+
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
11
|
+
>
|
|
12
|
+
<AppText
|
|
13
|
+
localization="chat.empty"
|
|
14
|
+
style={[styles.text, { color: themeColors.text }]}
|
|
15
|
+
/>
|
|
16
|
+
</View>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
container: {
|
|
22
|
+
flex: 1,
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
justifyContent: 'center',
|
|
25
|
+
padding: 20,
|
|
26
|
+
transform: [{ rotate: '180deg' }], //TODO: inverted list
|
|
27
|
+
},
|
|
28
|
+
text: {
|
|
29
|
+
fontSize: 16,
|
|
30
|
+
textAlign: 'center',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TouchableOpacity, View, StyleSheet } from 'react-native';
|
|
2
|
+
import { useThemeColors } from '../hooks/useThemeColors';
|
|
3
|
+
import { AppText } from './AppText';
|
|
4
|
+
|
|
5
|
+
interface InitFailedProps {
|
|
6
|
+
setInitFailed: (value: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function InitFailed({ setInitFailed }: InitFailedProps) {
|
|
10
|
+
const themeColors = useThemeColors();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<View
|
|
14
|
+
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
15
|
+
>
|
|
16
|
+
<TouchableOpacity
|
|
17
|
+
style={[styles.retryButton, { backgroundColor: themeColors.primary }]}
|
|
18
|
+
onPress={() => setInitFailed(false)}
|
|
19
|
+
>
|
|
20
|
+
<AppText
|
|
21
|
+
localization="chat.init.error"
|
|
22
|
+
style={[styles.retryText, { color: themeColors.background }]}
|
|
23
|
+
/>
|
|
24
|
+
</TouchableOpacity>
|
|
25
|
+
</View>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const styles = StyleSheet.create({
|
|
30
|
+
container: {
|
|
31
|
+
flex: 1,
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
justifyContent: 'center',
|
|
34
|
+
padding: 20,
|
|
35
|
+
},
|
|
36
|
+
retryButton: {
|
|
37
|
+
padding: 15,
|
|
38
|
+
borderRadius: 8,
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
},
|
|
42
|
+
retryText: {
|
|
43
|
+
fontSize: 16,
|
|
44
|
+
fontWeight: '500',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StyleSheet,
|
|
3
|
+
TextInput,
|
|
4
|
+
View,
|
|
5
|
+
Image,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { useAppStore } from '../store';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
import { sendCustomerMessage } from '../api';
|
|
11
|
+
import { useThemeColors } from '../hooks/useThemeColors';
|
|
12
|
+
|
|
13
|
+
const sendDark = require('../assets/send.png');
|
|
14
|
+
|
|
15
|
+
export function MessageInput({
|
|
16
|
+
scrollToBottom,
|
|
17
|
+
}: {
|
|
18
|
+
scrollToBottom: (animated: boolean) => void;
|
|
19
|
+
}) {
|
|
20
|
+
const [value, setValue] = useState('');
|
|
21
|
+
const customer = useAppStore((s) => s.customer!);
|
|
22
|
+
const themeColors = useThemeColors();
|
|
23
|
+
|
|
24
|
+
const sendMessage = () => {
|
|
25
|
+
if (value.trim()) {
|
|
26
|
+
const date = new Date();
|
|
27
|
+
useAppStore.getState().setData((data) => [
|
|
28
|
+
...(data ?? []),
|
|
29
|
+
{
|
|
30
|
+
id: null,
|
|
31
|
+
approved: false,
|
|
32
|
+
content: value,
|
|
33
|
+
created_at: date,
|
|
34
|
+
user: {
|
|
35
|
+
name: customer.name,
|
|
36
|
+
profile_photo_url: null,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
sendCustomerMessage(customer.external_id, value, {
|
|
41
|
+
fake: useAppStore.getState().fake,
|
|
42
|
+
}).then((res) => {
|
|
43
|
+
const data = useAppStore.getState().data;
|
|
44
|
+
if (data) {
|
|
45
|
+
const itemIndex = data.findIndex(
|
|
46
|
+
(item) =>
|
|
47
|
+
item.id === null &&
|
|
48
|
+
new Date(item.created_at).getTime() === date.getTime()
|
|
49
|
+
);
|
|
50
|
+
if (itemIndex === -1) {
|
|
51
|
+
//TODO:??
|
|
52
|
+
} else {
|
|
53
|
+
const alteredData = [...data];
|
|
54
|
+
alteredData[itemIndex] = {
|
|
55
|
+
id: res.message.id,
|
|
56
|
+
content: res.message.content,
|
|
57
|
+
user: res.message.user ?? alteredData[itemIndex]?.user,
|
|
58
|
+
created_at: new Date(res.message.created_at),
|
|
59
|
+
approved: true,
|
|
60
|
+
};
|
|
61
|
+
useAppStore.setState({
|
|
62
|
+
data: alteredData,
|
|
63
|
+
});
|
|
64
|
+
scrollToBottom(false);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
//TODO: ??
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
setValue('');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<View
|
|
76
|
+
style={[styles.container, { backgroundColor: themeColors.background }]}
|
|
77
|
+
>
|
|
78
|
+
<TextInput
|
|
79
|
+
value={value}
|
|
80
|
+
onChangeText={(newValue) => setValue(newValue)}
|
|
81
|
+
onSubmitEditing={sendMessage}
|
|
82
|
+
returnKeyType="send"
|
|
83
|
+
style={[
|
|
84
|
+
styles.textInput,
|
|
85
|
+
{
|
|
86
|
+
backgroundColor: themeColors.background,
|
|
87
|
+
color: themeColors.text,
|
|
88
|
+
borderColor: themeColors.border,
|
|
89
|
+
},
|
|
90
|
+
]}
|
|
91
|
+
placeholder="Type a message..."
|
|
92
|
+
placeholderTextColor={themeColors.text + '80'}
|
|
93
|
+
/>
|
|
94
|
+
<TouchableOpacity
|
|
95
|
+
style={[styles.sendButton, { backgroundColor: themeColors.primary }]}
|
|
96
|
+
onPress={sendMessage}
|
|
97
|
+
>
|
|
98
|
+
<Image
|
|
99
|
+
style={[styles.sendIcon, { tintColor: themeColors.text }]}
|
|
100
|
+
source={sendDark}
|
|
101
|
+
/>
|
|
102
|
+
</TouchableOpacity>
|
|
103
|
+
</View>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const styles = StyleSheet.create({
|
|
108
|
+
container: {
|
|
109
|
+
flexDirection: 'row',
|
|
110
|
+
padding: 10,
|
|
111
|
+
borderTopWidth: 1,
|
|
112
|
+
},
|
|
113
|
+
textInput: {
|
|
114
|
+
flex: 1,
|
|
115
|
+
borderWidth: 1,
|
|
116
|
+
borderRadius: 20,
|
|
117
|
+
paddingHorizontal: 15,
|
|
118
|
+
paddingVertical: 8,
|
|
119
|
+
marginRight: 10,
|
|
120
|
+
fontSize: 16,
|
|
121
|
+
},
|
|
122
|
+
sendButton: {
|
|
123
|
+
width: 40,
|
|
124
|
+
height: 40,
|
|
125
|
+
borderRadius: 20,
|
|
126
|
+
justifyContent: 'center',
|
|
127
|
+
alignItems: 'center',
|
|
128
|
+
},
|
|
129
|
+
sendIcon: {
|
|
130
|
+
width: 20,
|
|
131
|
+
height: 20,
|
|
132
|
+
},
|
|
133
|
+
});
|