@developer_tribe/react-native-comnyx 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/lib/commonjs/App.js +8 -3
  2. package/lib/commonjs/App.js.map +1 -1
  3. package/lib/commonjs/assets/arrow-right.png +0 -0
  4. package/lib/commonjs/assets/headphones-01.png +0 -0
  5. package/lib/commonjs/assets/iconamoon_clock-fill.png +0 -0
  6. package/lib/commonjs/assets/info-circle.png +0 -0
  7. package/lib/commonjs/assets/message-notification-square.png +0 -0
  8. package/lib/commonjs/assets/x-close.png +0 -0
  9. package/lib/commonjs/components/ChatList.js +355 -50
  10. package/lib/commonjs/components/ChatList.js.map +1 -1
  11. package/lib/commonjs/components/CustomAlert.js +132 -0
  12. package/lib/commonjs/components/CustomAlert.js.map +1 -0
  13. package/lib/commonjs/components/CustomerForm.js +252 -198
  14. package/lib/commonjs/components/CustomerForm.js.map +1 -1
  15. package/lib/commonjs/components/EmptyList.js +36 -11
  16. package/lib/commonjs/components/EmptyList.js.map +1 -1
  17. package/lib/commonjs/components/InitFailed.js +8 -5
  18. package/lib/commonjs/components/InitFailed.js.map +1 -1
  19. package/lib/commonjs/components/MessageInput.js +49 -16
  20. package/lib/commonjs/components/MessageInput.js.map +1 -1
  21. package/lib/commonjs/components/MessageItem.js +133 -42
  22. package/lib/commonjs/components/MessageItem.js.map +1 -1
  23. package/lib/commonjs/components/ScaledSheet.js +67 -0
  24. package/lib/commonjs/components/ScaledSheet.js.map +1 -0
  25. package/lib/commonjs/components/SizeMatter.js +27 -0
  26. package/lib/commonjs/components/SizeMatter.js.map +1 -0
  27. package/lib/commonjs/index.js +7 -0
  28. package/lib/commonjs/index.js.map +1 -1
  29. package/lib/commonjs/store.js +15 -9
  30. package/lib/commonjs/store.js.map +1 -1
  31. package/lib/commonjs/types/Theme.js +20 -2
  32. package/lib/commonjs/types/Theme.js.map +1 -1
  33. package/lib/commonjs/utils/deepMap.js +38 -0
  34. package/lib/commonjs/utils/deepMap.js.map +1 -0
  35. package/lib/commonjs/utils/formatDate.js +16 -0
  36. package/lib/commonjs/utils/formatDate.js.map +1 -0
  37. package/lib/commonjs/utils/scalingUtils.js +33 -0
  38. package/lib/commonjs/utils/scalingUtils.js.map +1 -0
  39. package/lib/commonjs/viewabilityConfig.js +11 -0
  40. package/lib/commonjs/viewabilityConfig.js.map +1 -0
  41. package/lib/module/App.js +8 -3
  42. package/lib/module/App.js.map +1 -1
  43. package/lib/module/assets/arrow-right.png +0 -0
  44. package/lib/module/assets/headphones-01.png +0 -0
  45. package/lib/module/assets/iconamoon_clock-fill.png +0 -0
  46. package/lib/module/assets/info-circle.png +0 -0
  47. package/lib/module/assets/message-notification-square.png +0 -0
  48. package/lib/module/assets/x-close.png +0 -0
  49. package/lib/module/components/ChatList.js +357 -54
  50. package/lib/module/components/ChatList.js.map +1 -1
  51. package/lib/module/components/CustomAlert.js +127 -0
  52. package/lib/module/components/CustomAlert.js.map +1 -0
  53. package/lib/module/components/CustomerForm.js +253 -200
  54. package/lib/module/components/CustomerForm.js.map +1 -1
  55. package/lib/module/components/EmptyList.js +38 -13
  56. package/lib/module/components/EmptyList.js.map +1 -1
  57. package/lib/module/components/InitFailed.js +9 -6
  58. package/lib/module/components/InitFailed.js.map +1 -1
  59. package/lib/module/components/MessageInput.js +50 -17
  60. package/lib/module/components/MessageInput.js.map +1 -1
  61. package/lib/module/components/MessageItem.js +134 -44
  62. package/lib/module/components/MessageItem.js.map +1 -1
  63. package/lib/module/components/ScaledSheet.js +62 -0
  64. package/lib/module/components/ScaledSheet.js.map +1 -0
  65. package/lib/module/components/SizeMatter.js +23 -0
  66. package/lib/module/components/SizeMatter.js.map +1 -0
  67. package/lib/module/index.js +1 -0
  68. package/lib/module/index.js.map +1 -1
  69. package/lib/module/store.js +15 -9
  70. package/lib/module/store.js.map +1 -1
  71. package/lib/module/types/Theme.js +20 -2
  72. package/lib/module/types/Theme.js.map +1 -1
  73. package/lib/module/utils/deepMap.js +34 -0
  74. package/lib/module/utils/deepMap.js.map +1 -0
  75. package/lib/module/utils/formatDate.js +11 -0
  76. package/lib/module/utils/formatDate.js.map +1 -0
  77. package/lib/module/utils/scalingUtils.js +25 -0
  78. package/lib/module/utils/scalingUtils.js.map +1 -0
  79. package/lib/module/viewabilityConfig.js +7 -0
  80. package/lib/module/viewabilityConfig.js.map +1 -0
  81. package/lib/typescript/commonjs/src/App.d.ts +2 -1
  82. package/lib/typescript/commonjs/src/App.d.ts.map +1 -1
  83. package/lib/typescript/commonjs/src/components/ChatList.d.ts +3 -1
  84. package/lib/typescript/commonjs/src/components/ChatList.d.ts.map +1 -1
  85. package/lib/typescript/commonjs/src/components/CustomAlert.d.ts +15 -0
  86. package/lib/typescript/commonjs/src/components/CustomAlert.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/src/components/CustomerForm.d.ts +3 -1
  88. package/lib/typescript/commonjs/src/components/CustomerForm.d.ts.map +1 -1
  89. package/lib/typescript/commonjs/src/components/EmptyList.d.ts.map +1 -1
  90. package/lib/typescript/commonjs/src/components/InitFailed.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/src/components/MessageInput.d.ts +1 -0
  92. package/lib/typescript/commonjs/src/components/MessageInput.d.ts.map +1 -1
  93. package/lib/typescript/commonjs/src/components/MessageItem.d.ts +2 -1
  94. package/lib/typescript/commonjs/src/components/MessageItem.d.ts.map +1 -1
  95. package/lib/typescript/commonjs/src/components/ScaledSheet.d.ts +2 -0
  96. package/lib/typescript/commonjs/src/components/ScaledSheet.d.ts.map +1 -0
  97. package/lib/typescript/commonjs/src/components/SizeMatter.d.ts +7 -0
  98. package/lib/typescript/commonjs/src/components/SizeMatter.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/src/index.d.ts +1 -0
  100. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  101. package/lib/typescript/commonjs/src/store.d.ts +6 -0
  102. package/lib/typescript/commonjs/src/store.d.ts.map +1 -1
  103. package/lib/typescript/commonjs/src/types/Conversation.d.ts +2 -0
  104. package/lib/typescript/commonjs/src/types/Conversation.d.ts.map +1 -1
  105. package/lib/typescript/commonjs/src/types/Theme.d.ts +9 -0
  106. package/lib/typescript/commonjs/src/types/Theme.d.ts.map +1 -1
  107. package/lib/typescript/commonjs/src/utils/deepMap.d.ts +7 -0
  108. package/lib/typescript/commonjs/src/utils/deepMap.d.ts.map +1 -0
  109. package/lib/typescript/commonjs/src/utils/formatDate.d.ts +2 -0
  110. package/lib/typescript/commonjs/src/utils/formatDate.d.ts.map +1 -0
  111. package/lib/typescript/commonjs/src/utils/scalingUtils.d.ts +10 -0
  112. package/lib/typescript/commonjs/src/utils/scalingUtils.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/viewabilityConfig.d.ts +5 -0
  114. package/lib/typescript/commonjs/src/viewabilityConfig.d.ts.map +1 -0
  115. package/lib/typescript/module/src/App.d.ts +2 -1
  116. package/lib/typescript/module/src/App.d.ts.map +1 -1
  117. package/lib/typescript/module/src/components/ChatList.d.ts +3 -1
  118. package/lib/typescript/module/src/components/ChatList.d.ts.map +1 -1
  119. package/lib/typescript/module/src/components/CustomAlert.d.ts +15 -0
  120. package/lib/typescript/module/src/components/CustomAlert.d.ts.map +1 -0
  121. package/lib/typescript/module/src/components/CustomerForm.d.ts +3 -1
  122. package/lib/typescript/module/src/components/CustomerForm.d.ts.map +1 -1
  123. package/lib/typescript/module/src/components/EmptyList.d.ts.map +1 -1
  124. package/lib/typescript/module/src/components/InitFailed.d.ts.map +1 -1
  125. package/lib/typescript/module/src/components/MessageInput.d.ts +1 -0
  126. package/lib/typescript/module/src/components/MessageInput.d.ts.map +1 -1
  127. package/lib/typescript/module/src/components/MessageItem.d.ts +2 -1
  128. package/lib/typescript/module/src/components/MessageItem.d.ts.map +1 -1
  129. package/lib/typescript/module/src/components/ScaledSheet.d.ts +2 -0
  130. package/lib/typescript/module/src/components/ScaledSheet.d.ts.map +1 -0
  131. package/lib/typescript/module/src/components/SizeMatter.d.ts +7 -0
  132. package/lib/typescript/module/src/components/SizeMatter.d.ts.map +1 -0
  133. package/lib/typescript/module/src/index.d.ts +1 -0
  134. package/lib/typescript/module/src/index.d.ts.map +1 -1
  135. package/lib/typescript/module/src/store.d.ts +6 -0
  136. package/lib/typescript/module/src/store.d.ts.map +1 -1
  137. package/lib/typescript/module/src/types/Conversation.d.ts +2 -0
  138. package/lib/typescript/module/src/types/Conversation.d.ts.map +1 -1
  139. package/lib/typescript/module/src/types/Theme.d.ts +9 -0
  140. package/lib/typescript/module/src/types/Theme.d.ts.map +1 -1
  141. package/lib/typescript/module/src/utils/deepMap.d.ts +7 -0
  142. package/lib/typescript/module/src/utils/deepMap.d.ts.map +1 -0
  143. package/lib/typescript/module/src/utils/formatDate.d.ts +2 -0
  144. package/lib/typescript/module/src/utils/formatDate.d.ts.map +1 -0
  145. package/lib/typescript/module/src/utils/scalingUtils.d.ts +10 -0
  146. package/lib/typescript/module/src/utils/scalingUtils.d.ts.map +1 -0
  147. package/lib/typescript/module/src/viewabilityConfig.d.ts +5 -0
  148. package/lib/typescript/module/src/viewabilityConfig.d.ts.map +1 -0
  149. package/package.json +2 -2
  150. package/src/App.tsx +4 -2
  151. package/src/assets/arrow-right.png +0 -0
  152. package/src/assets/headphones-01.png +0 -0
  153. package/src/assets/iconamoon_clock-fill.png +0 -0
  154. package/src/assets/info-circle.png +0 -0
  155. package/src/assets/message-notification-square.png +0 -0
  156. package/src/assets/x-close.png +0 -0
  157. package/src/components/ChatList.tsx +413 -60
  158. package/src/components/CustomAlert.tsx +132 -0
  159. package/src/components/CustomerForm.tsx +272 -224
  160. package/src/components/EmptyList.tsx +31 -7
  161. package/src/components/InitFailed.tsx +9 -6
  162. package/src/components/MessageInput.tsx +86 -49
  163. package/src/components/MessageItem.tsx +181 -58
  164. package/src/components/ScaledSheet.ts +93 -0
  165. package/src/components/SizeMatter.tsx +22 -0
  166. package/src/index.tsx +1 -0
  167. package/src/store.ts +13 -3
  168. package/src/types/Conversation.ts +2 -0
  169. package/src/types/Theme.ts +27 -0
  170. package/src/utils/deepMap.ts +47 -0
  171. package/src/utils/formatDate.ts +8 -0
  172. package/src/utils/scalingUtils.ts +27 -0
  173. package/src/viewabilityConfig.ts +4 -0
  174. package/lib/commonjs/assets/double-check.png +0 -0
  175. package/lib/commonjs/assets/send.png +0 -0
  176. package/lib/module/assets/double-check.png +0 -0
  177. package/lib/module/assets/send.png +0 -0
  178. package/src/assets/double-check.png +0 -0
  179. package/src/assets/send.png +0 -0
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { Modal, View, Image, TouchableOpacity } from 'react-native';
5
+ import { useThemeColors } from "../hooks/useThemeColors.js";
6
+ import { AppText } from "./AppText.js";
7
+ import { ScaledSheet } from "./ScaledSheet.js";
8
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
+ const infoIcon = require('../assets/info-circle.png');
10
+ function CustomPopup({
11
+ isVisible,
12
+ onClose,
13
+ title,
14
+ description,
15
+ onCancelButton,
16
+ onResendButton,
17
+ buttonText
18
+ }) {
19
+ const themeColors = useThemeColors();
20
+ return /*#__PURE__*/_jsx(Modal, {
21
+ visible: isVisible,
22
+ transparent: true,
23
+ onRequestClose: onClose,
24
+ children: /*#__PURE__*/_jsx(View, {
25
+ style: styles.overlay,
26
+ children: /*#__PURE__*/_jsxs(View, {
27
+ style: [styles.popup, {
28
+ backgroundColor: themeColors.background
29
+ }],
30
+ children: [/*#__PURE__*/_jsx(Image, {
31
+ source: infoIcon,
32
+ height: 64,
33
+ width: 64
34
+ }), /*#__PURE__*/_jsx(AppText, {
35
+ style: styles.title,
36
+ children: title
37
+ }), /*#__PURE__*/_jsx(AppText, {
38
+ style: [styles.description, {
39
+ color: themeColors.navy
40
+ }],
41
+ children: description
42
+ }), onResendButton && /*#__PURE__*/_jsx(TouchableOpacity, {
43
+ style: [styles.buttonUp, {
44
+ backgroundColor: themeColors.dark_background
45
+ }],
46
+ onPress: onResendButton,
47
+ children: /*#__PURE__*/_jsx(AppText, {
48
+ localization: 'customer.form.resend',
49
+ style: [styles.buttonText, {
50
+ color: themeColors.light_text
51
+ }]
52
+ })
53
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
54
+ style: [styles.buttonDown, {
55
+ borderColor: themeColors.dark_background
56
+ }],
57
+ onPress: onCancelButton,
58
+ children: /*#__PURE__*/_jsx(AppText, {
59
+ localization: buttonText,
60
+ style: [styles.buttonText, {
61
+ color: themeColors.text
62
+ }]
63
+ })
64
+ })]
65
+ })
66
+ })
67
+ });
68
+ }
69
+ const styles = ScaledSheet.create({
70
+ overlay: {
71
+ flex: 1,
72
+ justifyContent: 'center',
73
+ alignItems: 'center',
74
+ backgroundColor: 'rgba(0, 0, 0, 0.60)'
75
+ },
76
+ popup: {
77
+ width: '80%',
78
+ borderRadius: '20@s',
79
+ overflow: 'hidden',
80
+ alignItems: 'center',
81
+ paddingVertical: '20@vs'
82
+ },
83
+ title: {
84
+ marginVertical: '16@vs',
85
+ fontWeight: 700,
86
+ fontSize: '16@vs'
87
+ },
88
+ description: {
89
+ marginBottom: '16@vs',
90
+ alignItems: 'center',
91
+ textAlign: 'center',
92
+ width: '85%',
93
+ fontWeight: 500,
94
+ fontSize: '16@vs'
95
+ },
96
+ buttonText: {
97
+ color: 'white',
98
+ fontSize: '16@vs',
99
+ fontWeight: '600'
100
+ },
101
+ buttonContainer: {
102
+ flexDirection: 'column',
103
+ width: '90%',
104
+ justifyContent: 'center',
105
+ alignItems: 'center'
106
+ },
107
+ buttonUp: {
108
+ borderRadius: '12@s',
109
+ width: '256@s',
110
+ height: '56@vs',
111
+ marginBottom: '16@vs',
112
+ alignItems: 'center',
113
+ justifyContent: 'center'
114
+ },
115
+ buttonDown: {
116
+ backgroundColor: 'transparent',
117
+ borderRadius: '12@s',
118
+ width: '256@s',
119
+ height: '56@vs',
120
+ alignItems: 'center',
121
+ justifyContent: 'center',
122
+ marginBottom: '12@vs',
123
+ borderWidth: 1
124
+ }
125
+ });
126
+ export default /*#__PURE__*/React.memo(CustomPopup);
127
+ //# sourceMappingURL=CustomAlert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Modal","View","Image","TouchableOpacity","useThemeColors","AppText","ScaledSheet","jsx","_jsx","jsxs","_jsxs","infoIcon","require","CustomPopup","isVisible","onClose","title","description","onCancelButton","onResendButton","buttonText","themeColors","visible","transparent","onRequestClose","children","style","styles","overlay","popup","backgroundColor","background","source","height","width","color","navy","buttonUp","dark_background","onPress","localization","light_text","buttonDown","borderColor","text","create","flex","justifyContent","alignItems","borderRadius","overflow","paddingVertical","marginVertical","fontWeight","fontSize","marginBottom","textAlign","buttonContainer","flexDirection","borderWidth","memo"],"sourceRoot":"../../../src","sources":["components/CustomAlert.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,EAAEC,IAAI,EAAEC,KAAK,EAAEC,gBAAgB,QAAQ,cAAc;AACnE,SAASC,cAAc,QAAQ,4BAAyB;AACxD,SAASC,OAAO,QAAQ,cAAW;AAEnC,SAASC,WAAW,QAAQ,kBAAe;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAY5C,MAAMC,QAAQ,GAAGC,OAAO,CAAC,2BAA2B,CAAC;AAErD,SAASC,WAAWA,CAAC;EACnBC,SAAS;EACTC,OAAO;EACPC,KAAK;EACLC,WAAW;EACXC,cAAc;EACdC,cAAc;EACdC;AACgB,CAAC,EAAE;EACnB,MAAMC,WAAW,GAAGjB,cAAc,CAAC,CAAC;EAEpC,oBACEI,IAAA,CAACR,KAAK;IAACsB,OAAO,EAAER,SAAU;IAACS,WAAW,EAAE,IAAK;IAACC,cAAc,EAAET,OAAQ;IAAAU,QAAA,eACpEjB,IAAA,CAACP,IAAI;MAACyB,KAAK,EAAEC,MAAM,CAACC,OAAQ;MAAAH,QAAA,eAC1Bf,KAAA,CAACT,IAAI;Q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E,OAAO;IACrBI,WAAW,EAAE;EACf;AACF,CAAC,CAAC;AAEF,4BAAe5D,KAAK,CAAC6D,IAAI,CAAC/C,WAAW,CAAC","ignoreList":[]}
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
 
3
- import { View, TextInput, StyleSheet, TouchableOpacity, Modal, FlatList, Pressable, Keyboard } from 'react-native';
3
+ import { View, TextInput, TouchableOpacity, Pressable, Keyboard, Image, ScrollView } from 'react-native';
4
4
  import { useForm, Controller } from 'react-hook-form';
5
5
  import { useAppStore } from "../store.js";
6
6
  import { createCustomer } from "../api/index.js";
7
7
  import { AppText } from "./AppText.js";
8
8
  import { useLocalize } from "../hooks/useLocalize.js";
9
9
  import { useThemeColors } from "../hooks/useThemeColors.js";
10
+ import CustomPopup from "./CustomAlert.js";
10
11
  import { useState } from 'react';
11
- import { countries } from "../constants/countries.js";
12
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
13
- export function CustomerForm() {
12
+ import { ScaledSheet } from "./ScaledSheet.js";
13
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ const closeIcon = require('../assets/x-close.png');
15
+ const infoIcon = require('../assets/info-circle.png');
16
+ export function CustomerForm({
17
+ onBack
18
+ }) {
14
19
  const {
15
20
  control,
16
21
  handleSubmit,
@@ -20,13 +25,17 @@ export function CustomerForm() {
20
25
  } = useForm();
21
26
  const themeColors = useThemeColors();
22
27
  const localize = useLocalize();
23
- const [isCountryModalVisible, setIsCountryModalVisible] = useState(false);
24
28
  const inputStyle = {
25
29
  ...styles.input,
26
30
  color: themeColors.text,
27
- borderColor: themeColors.border,
31
+ borderColor: themeColors.gainsboro,
28
32
  backgroundColor: themeColors.background
29
33
  };
34
+ const [popupVisible, setPopupVisible] = useState(false);
35
+ const [popupContent, setPopupContent] = useState({
36
+ title: '',
37
+ description: 'null'
38
+ });
30
39
  const onSubmit = async data => {
31
40
  try {
32
41
  const customer = await createCustomer({
@@ -45,232 +54,245 @@ export function CustomerForm() {
45
54
  console.error('Error creating customer:', error);
46
55
  }
47
56
  };
57
+ const showErrorPopup = (title, description) => {
58
+ setPopupVisible(true);
59
+ setPopupContent({
60
+ title: title ?? 'customer.form.failed.name',
61
+ description: description ?? 'customer.form.failed.name.desc'
62
+ });
63
+ };
64
+
65
+ // eslint-disable-next-line react/no-unstable-nested-components
66
+ const InfoButton = ({
67
+ title,
68
+ description
69
+ }) => {
70
+ return /*#__PURE__*/_jsx(TouchableOpacity, {
71
+ onPress: () => showErrorPopup(title, description),
72
+ activeOpacity: 1,
73
+ children: /*#__PURE__*/_jsx(Image, {
74
+ source: infoIcon,
75
+ style: styles.infoIcon
76
+ })
77
+ });
78
+ };
48
79
  return /*#__PURE__*/_jsxs(Pressable, {
49
80
  style: [styles.container, {
50
81
  backgroundColor: themeColors.background
51
82
  }],
52
83
  onPress: Keyboard.dismiss,
53
- children: [/*#__PURE__*/_jsxs(View, {
54
- style: styles.headerContainer,
55
- children: [/*#__PURE__*/_jsx(AppText, {
56
- localization: "customer.form.title",
57
- style: [styles.headerText, {
58
- color: themeColors.text
59
- }]
60
- }), /*#__PURE__*/_jsx(AppText, {
61
- localization: "customer.form.instructions",
62
- style: [styles.headerText, {
63
- color: themeColors.text
64
- }]
65
- })]
66
- }), /*#__PURE__*/_jsx(Controller, {
67
- control: control,
68
- rules: {
69
- maxLength: {
70
- value: 30,
71
- message: localize('customer.form.validation.name.maxLength')
72
- }
73
- },
74
- render: ({
75
- field: {
76
- onChange,
77
- value
78
- }
79
- }) => /*#__PURE__*/_jsx(TextInput, {
80
- style: inputStyle,
81
- placeholder: localize('customer.form.placeholder.name'),
82
- placeholderTextColor: "#6C757D",
83
- value: value,
84
- onChangeText: onChange
85
- }),
86
- name: "name"
87
- }), errors.name && /*#__PURE__*/_jsx(AppText, {
88
- localization: errors.name.message ? undefined : 'customer.form.error',
89
- style: [styles.error, {
90
- color: themeColors.error
91
- }],
92
- children: errors.name.message
93
- }), /*#__PURE__*/_jsx(Controller, {
94
- control: control,
95
- rules: {
96
- maxLength: {
97
- value: 2,
98
- message: localize('customer.form.validation.country.maxLength')
99
- }
100
- },
101
- render: ({
102
- field: {
103
- onChange,
104
- value
105
- }
106
- }) => /*#__PURE__*/_jsxs(_Fragment, {
107
- children: [/*#__PURE__*/_jsx(Pressable, {
108
- style: [styles.input, {
109
- borderColor: themeColors.border,
110
- backgroundColor: themeColors.background,
111
- justifyContent: 'center'
84
+ children: [/*#__PURE__*/_jsx(ScrollView, {
85
+ contentContainerStyle: styles.scrollContainer,
86
+ keyboardShouldPersistTaps: "handled",
87
+ children: /*#__PURE__*/_jsxs(View, {
88
+ style: [styles.container, {
89
+ backgroundColor: themeColors.background
90
+ }],
91
+ children: [/*#__PURE__*/_jsx(TouchableOpacity, {
92
+ style: [styles.iconContainer, {
93
+ backgroundColor: themeColors.dark_background
112
94
  }],
113
- onPress: () => setIsCountryModalVisible(true),
114
- children: /*#__PURE__*/_jsx(AppText, {
115
- style: {
116
- color: value ? themeColors.text : '#6C757D'
117
- },
118
- children: value ? countries.find(c => c.code === value)?.name : localize('customer.form.placeholder.country')
95
+ onPress: onBack,
96
+ children: /*#__PURE__*/_jsx(Image, {
97
+ source: closeIcon,
98
+ style: [styles.closeIcon, {
99
+ tintColor: themeColors.light_text
100
+ }]
119
101
  })
120
- }), /*#__PURE__*/_jsx(Modal, {
121
- visible: isCountryModalVisible,
122
- transparent: true,
123
- animationType: "slide",
124
- onRequestClose: () => setIsCountryModalVisible(false),
125
- children: /*#__PURE__*/_jsx(View, {
126
- style: [styles.modalContainer, {
127
- backgroundColor: 'rgba(0, 0, 0, 0.5)'
102
+ }), /*#__PURE__*/_jsxs(View, {
103
+ style: [styles.headerContainer, {
104
+ backgroundColor: themeColors.dark_background
105
+ }],
106
+ children: [/*#__PURE__*/_jsx(AppText, {
107
+ localization: "customer.form.title",
108
+ style: [styles.headerText, {
109
+ color: themeColors.gainsboro
110
+ }]
111
+ }), /*#__PURE__*/_jsx(AppText, {
112
+ localization: "customer.form.instructions",
113
+ style: [styles.headerText, {
114
+ color: themeColors.light_text
115
+ }]
116
+ })]
117
+ }), /*#__PURE__*/_jsxs(View, {
118
+ style: styles.titleContainer,
119
+ children: [/*#__PURE__*/_jsx(AppText, {
120
+ style: [styles.title, {
121
+ color: themeColors.slate
122
+ }],
123
+ children: localize('customer.form.title')
124
+ }), /*#__PURE__*/_jsx(Controller, {
125
+ control: control,
126
+ rules: {
127
+ maxLength: {
128
+ value: 30,
129
+ message: localize('customer.form.validation.name.maxLength')
130
+ }
131
+ },
132
+ render: ({
133
+ field: {
134
+ onChange,
135
+ value
136
+ }
137
+ }) => /*#__PURE__*/_jsxs(View, {
138
+ style: [styles.inputContainer, {
139
+ borderBottomColor: themeColors.gainsboro
140
+ }],
141
+ children: [/*#__PURE__*/_jsx(TextInput, {
142
+ style: inputStyle,
143
+ placeholder: localize('customer.form.placeholder.name'),
144
+ placeholderTextColor: themeColors.gainsboro,
145
+ value: value,
146
+ onChangeText: onChange
147
+ }), errors.name && /*#__PURE__*/_jsx(InfoButton, {
148
+ title: 'customer.form.failed.name',
149
+ description: 'customer.form.failed.name.desc'
150
+ })]
151
+ }),
152
+ name: "name"
153
+ }), /*#__PURE__*/_jsx(AppText, {
154
+ style: [styles.title, {
155
+ color: themeColors.slate
128
156
  }],
129
- children: /*#__PURE__*/_jsx(View, {
130
- style: [styles.modalContent, {
131
- backgroundColor: themeColors.background
157
+ children: "Email"
158
+ }), /*#__PURE__*/_jsx(Controller, {
159
+ control: control,
160
+ rules: {
161
+ pattern: {
162
+ value: /^\S+@\S+$/i,
163
+ message: localize('customer.form.validation.email.pattern')
164
+ }
165
+ },
166
+ render: ({
167
+ field: {
168
+ onChange,
169
+ value
170
+ }
171
+ }) => /*#__PURE__*/_jsxs(View, {
172
+ style: [styles.inputContainer, {
173
+ borderBottomColor: themeColors.gainsboro
174
+ }],
175
+ children: [/*#__PURE__*/_jsx(TextInput, {
176
+ style: inputStyle,
177
+ placeholder: localize('customer.form.placeholder.email'),
178
+ placeholderTextColor: themeColors.gainsboro,
179
+ value: value,
180
+ onChangeText: onChange,
181
+ keyboardType: "email-address"
182
+ }), errors.email && /*#__PURE__*/_jsx(InfoButton, {
183
+ title: 'customer.form.failed.email',
184
+ description: 'customer.form.failed.email.desc'
185
+ })]
186
+ }),
187
+ name: "email"
188
+ }), /*#__PURE__*/_jsx(AppText, {
189
+ style: [styles.title, {
190
+ color: themeColors.slate
191
+ }],
192
+ children: "Phone"
193
+ }), /*#__PURE__*/_jsx(Controller, {
194
+ control: control,
195
+ rules: {
196
+ validate: value => {
197
+ if (!value) return true;
198
+ return typeof value === 'string' || localize('customer.form.validation.phone.invalid');
199
+ }
200
+ },
201
+ render: ({
202
+ field: {
203
+ onChange,
204
+ value
205
+ }
206
+ }) => /*#__PURE__*/_jsxs(View, {
207
+ style: [styles.inputContainer, {
208
+ borderBottomColor: themeColors.gainsboro
132
209
  }],
133
- children: /*#__PURE__*/_jsx(FlatList, {
134
- data: countries,
135
- keyExtractor: item => item.code,
136
- initialScrollIndex: countries.findIndex(c => c.code === value),
137
- renderItem: ({
138
- item
139
- }) => /*#__PURE__*/_jsx(Pressable, {
140
- style: [styles.countryItem, {
141
- backgroundColor: value === item.code ? themeColors.primary : themeColors.background,
142
- borderBottomColor: themeColors.border
143
- }],
144
- onPress: () => {
145
- onChange(item.code);
146
- setIsCountryModalVisible(false);
147
- },
148
- children: /*#__PURE__*/_jsx(AppText, {
149
- style: {
150
- color: value === item.code ? themeColors.background : themeColors.text,
151
- fontSize: 16
152
- },
153
- children: item.name
154
- })
155
- })
156
- })
157
- })
210
+ children: [/*#__PURE__*/_jsx(TextInput, {
211
+ style: inputStyle,
212
+ placeholder: localize('customer.form.placeholder.phone'),
213
+ placeholderTextColor: themeColors.gainsboro,
214
+ value: value,
215
+ onChangeText: onChange,
216
+ keyboardType: "phone-pad"
217
+ }), errors.phone && /*#__PURE__*/_jsx(InfoButton, {
218
+ title: 'customer.form.failed.phone',
219
+ description: 'customer.form.failed.phone.desc'
220
+ })]
221
+ }),
222
+ name: "phone"
223
+ })]
224
+ }), /*#__PURE__*/_jsx(TouchableOpacity, {
225
+ style: [styles.button, {
226
+ backgroundColor: themeColors.dark_background
227
+ }],
228
+ onPress: handleSubmit(onSubmit),
229
+ children: /*#__PURE__*/_jsx(AppText, {
230
+ localization: "customer.form.submit",
231
+ style: [styles.buttonText, {
232
+ color: themeColors.light_text
233
+ }]
158
234
  })
159
235
  })]
160
- }),
161
- name: "country"
162
- }), errors.country && /*#__PURE__*/_jsx(AppText, {
163
- localization: errors.country.message ? undefined : 'customer.form.error',
164
- style: [styles.error, {
165
- color: themeColors.error
166
- }],
167
- children: errors.country.message
168
- }), /*#__PURE__*/_jsx(Controller, {
169
- control: control,
170
- rules: {
171
- pattern: {
172
- value: /^\S+@\S+$/i,
173
- message: localize('customer.form.validation.email.pattern')
174
- }
175
- },
176
- render: ({
177
- field: {
178
- onChange,
179
- value
180
- }
181
- }) => /*#__PURE__*/_jsx(TextInput, {
182
- style: inputStyle,
183
- placeholder: localize('customer.form.placeholder.email'),
184
- placeholderTextColor: "#6C757D",
185
- value: value,
186
- onChangeText: onChange,
187
- keyboardType: "email-address"
188
- }),
189
- name: "email"
190
- }), errors.email && /*#__PURE__*/_jsx(AppText, {
191
- localization: errors.email.message ? undefined : 'customer.form.error',
192
- style: [styles.error, {
193
- color: themeColors.error
194
- }],
195
- children: errors.email.message
196
- }), /*#__PURE__*/_jsx(Controller, {
197
- control: control,
198
- rules: {
199
- validate: value => {
200
- if (!value) return true;
201
- return typeof value === 'string' || localize('customer.form.validation.phone.invalid');
202
- }
203
- },
204
- render: ({
205
- field: {
206
- onChange,
207
- value
208
- }
209
- }) => /*#__PURE__*/_jsx(TextInput, {
210
- style: inputStyle,
211
- placeholder: localize('customer.form.placeholder.phone'),
212
- placeholderTextColor: "#6C757D",
213
- value: value,
214
- onChangeText: onChange,
215
- keyboardType: "phone-pad"
216
- }),
217
- name: "phone"
218
- }), errors.phone && /*#__PURE__*/_jsx(AppText, {
219
- localization: errors.phone.message ? undefined : 'customer.form.error',
220
- style: [styles.error, {
221
- color: themeColors.error
222
- }],
223
- children: errors.phone.message
224
- }), /*#__PURE__*/_jsx(TouchableOpacity, {
225
- style: [styles.button, {
226
- backgroundColor: themeColors.primary
227
- }],
228
- onPress: handleSubmit(onSubmit),
229
- children: /*#__PURE__*/_jsx(AppText, {
230
- localization: "customer.form.submit",
231
- style: styles.buttonText
232
236
  })
237
+ }), /*#__PURE__*/_jsx(CustomPopup, {
238
+ isVisible: popupVisible,
239
+ onClose: () => setPopupVisible(false),
240
+ title: popupContent.title,
241
+ description: popupContent.description,
242
+ onCancelButton: () => {
243
+ setPopupVisible(false);
244
+ setPopupContent({
245
+ title: '',
246
+ description: ''
247
+ });
248
+ },
249
+ onResendButton: () => {
250
+ setPopupVisible(false);
251
+ }
233
252
  })]
234
253
  });
235
254
  }
236
- const styles = StyleSheet.create({
255
+ const styles = ScaledSheet.create({
237
256
  container: {
238
- padding: 24,
257
+ paddingBottom: '24@vs',
239
258
  flex: 1,
240
- justifyContent: 'center'
259
+ justifyContent: 'space-between'
241
260
  },
242
261
  headerContainer: {
243
- marginBottom: 24
262
+ paddingHorizontal: '24@s',
263
+ marginBottom: '24@vs',
264
+ paddingBottom: '32@vs'
244
265
  },
245
266
  headerText: {
246
- fontSize: 15,
267
+ fontSize: '30@vs',
247
268
  fontWeight: '600',
248
- textAlign: 'center'
269
+ textAlign: 'left'
249
270
  },
250
271
  input: {
251
- height: 56,
252
- borderWidth: 1,
253
- borderRadius: 12,
254
- paddingHorizontal: 16,
255
- fontSize: 16,
272
+ borderRadius: '12@s',
273
+ paddingHorizontal: '12@s',
274
+ fontSize: '16@vs',
256
275
  backgroundColor: 'white',
257
- marginBottom: 16
276
+ paddingVertical: '8@vs',
277
+ width: '95%'
258
278
  },
259
279
  button: {
260
- padding: 16,
261
- borderRadius: 12,
280
+ paddingHorizontal: '16@s',
281
+ paddingVertical: '16@vs',
282
+ borderRadius: '12@s',
262
283
  alignItems: 'center',
263
- marginTop: 24
284
+ marginTop: '24@vs',
285
+ marginHorizontal: '20@s'
264
286
  },
265
287
  buttonText: {
266
288
  color: 'white',
267
- fontSize: 16,
289
+ fontSize: '16@vs',
268
290
  fontWeight: '600'
269
291
  },
270
292
  error: {
271
- fontSize: 14,
272
- marginLeft: 16,
273
- top: -16
293
+ fontSize: '14@vs',
294
+ marginLeft: '16@s',
295
+ top: '-16@vs'
274
296
  },
275
297
  modalContainer: {
276
298
  flex: 1,
@@ -280,12 +302,43 @@ const styles = StyleSheet.create({
280
302
  modalContent: {
281
303
  width: '90%',
282
304
  height: '70%',
283
- borderRadius: 12,
305
+ borderRadius: '12@s',
284
306
  overflow: 'hidden'
285
307
  },
286
308
  countryItem: {
287
- padding: 16,
309
+ paddingHorizontal: '16@s',
310
+ paddingVertical: '16@vs',
288
311
  borderBottomWidth: 1
312
+ },
313
+ title: {
314
+ fontSize: '16@vs'
315
+ },
316
+ iconContainer: {
317
+ paddingHorizontal: '20@s',
318
+ paddingVertical: '10@vs'
319
+ },
320
+ inputContainer: {
321
+ flexDirection: 'row',
322
+ alignItems: 'center',
323
+ borderWidth: 1,
324
+ marginBottom: '8@vs'
325
+ },
326
+ closeIcon: {
327
+ width: '24@s',
328
+ height: '24@vs'
329
+ },
330
+ scrollContainer: {
331
+ flexGrow: 1,
332
+ justifyContent: 'space-between'
333
+ },
334
+ infoIcon: {
335
+ width: '24@s',
336
+ height: '24@vs',
337
+ tintColor: 'red'
338
+ },
339
+ titleContainer: {
340
+ marginHorizontal: '20@s',
341
+ flex: 1
289
342
  }
290
343
  });
291
344
  //# sourceMappingURL=CustomerForm.js.map