react-native-altibbi 0.1.2 → 0.1.4

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.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import Navigation from './src/navigation/navigation';
3
+ const App = () => React.createElement(Navigation, null);
4
+ export default App;
@@ -0,0 +1,28 @@
1
+ import { Text, TouchableOpacity, View } from 'react-native';
2
+ export const Radio = (props) => {
3
+ const [picked, setPicked] = props.pick;
4
+ const { array, title } = props;
5
+ return (React.createElement(React.Fragment, null,
6
+ React.createElement(Text, { style: {
7
+ fontWeight: 'bold',
8
+ fontSize: 18,
9
+ color: 'black',
10
+ marginTop: 20,
11
+ } }, title),
12
+ React.createElement(View, { style: {
13
+ flex: 1,
14
+ flexDirection: 'row',
15
+ marginTop: 10,
16
+ flexWrap: 'wrap',
17
+ } }, array.map((item) => {
18
+ return (React.createElement(TouchableOpacity, { activeOpacity: 1, key: item, style: { marginRight: 20 }, onPress: () => {
19
+ setPicked(item);
20
+ } },
21
+ React.createElement(Text, { style: {
22
+ marginTop: 5,
23
+ fontWeight: 'bold',
24
+ fontSize: 18,
25
+ color: item === picked ? '#10e1d0' : '#9d9d9d',
26
+ } }, ' ' + item)));
27
+ }))));
28
+ };
@@ -0,0 +1,232 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { ActivityIndicator, Button, FlatList, Image, Platform, StyleSheet, Text, TextInput, View, } from 'react-native';
3
+ import { PERMISSIONS, request } from 'react-native-permissions';
4
+ import { ImageLibraryOptions, ImagePickerResponse, launchImageLibrary, } from 'react-native-image-picker';
5
+ import { AltibbiChat, ConnectionHandler, GroupChannelHandler, GroupChannelModule, uploadMedia, GroupChannel, } from 'react-native-altibbi';
6
+ const Chat = (props) => {
7
+ const data = props?.route?.params?.event;
8
+ const ref = useRef(null);
9
+ const channelRef = useRef();
10
+ const [loading, setLoading] = useState(true);
11
+ const [textInput, setTextInput] = useState('');
12
+ const [message, setMessage] = useState(null);
13
+ const [messageList, setMessageList] = useState([]);
14
+ const init = () => {
15
+ ref.current = AltibbiChat.init({
16
+ appId: data.app_id,
17
+ modules: [new GroupChannelModule()],
18
+ });
19
+ };
20
+ const connect = async () => {
21
+ await ref?.current?.connect(data.chat_user_id, data.chat_user_token);
22
+ };
23
+ const disconnect = () => {
24
+ ref?.current?.disconnect().then((r) => {
25
+ console.log(r);
26
+ });
27
+ };
28
+ const reconnect = () => {
29
+ ref?.current?.reconnect();
30
+ };
31
+ const getChannel = async (channelURL) => {
32
+ const channel = await ref?.current?.groupChannel
33
+ .getChannel(channelURL)
34
+ .catch((e) => {
35
+ console.log(e);
36
+ return e;
37
+ });
38
+ channelRef.current = channel;
39
+ return channel;
40
+ };
41
+ const sendMessage = (msg) => {
42
+ const send = channelRef?.current?.sendUserMessage(msg);
43
+ send?.onSucceeded((message1) => {
44
+ console.log('onSucceeded');
45
+ const newMessage = {
46
+ createdAt: message1.createdAt,
47
+ message: message1.message,
48
+ messageId: message1.messageId,
49
+ sender: {
50
+ userId: message1.sender.userId,
51
+ },
52
+ };
53
+ setMessage(newMessage);
54
+ });
55
+ send.onFailed((err) => {
56
+ console.log('onFailed', err);
57
+ });
58
+ send.onPending(() => {
59
+ console.log('onPending');
60
+ });
61
+ };
62
+ const loadAllMessage = async (channelURL) => {
63
+ const channel = await getChannel(channelURL);
64
+ const previousMessageList = await channel.createPreviousMessageListQuery();
65
+ let allMessages = [];
66
+ while (previousMessageList.hasNext) {
67
+ let newMsgArr = await previousMessageList.load();
68
+ allMessages = [...allMessages, ...newMsgArr];
69
+ }
70
+ return allMessages;
71
+ };
72
+ const renderMessage = ({ item }) => (React.createElement(View, { style: item.sender.userId == data.chat_user_id
73
+ ? styles.userMessage
74
+ : styles.otherMessage }, item?.message?.includes('cdn') ? (React.createElement(Image, { source: { uri: item.message }, style: { width: 150, height: 150 }, resizeMode: 'cover' })) : (React.createElement(Text, { style: styles.messageText }, item.message))));
75
+ const onUserJoined = () => { };
76
+ const onUserLeft = () => { };
77
+ const onTypingStatusUpdated = () => { };
78
+ const onMessageReceived = (channel, message) => {
79
+ setMessage({
80
+ createdAt: message.createdAt,
81
+ message: message.message,
82
+ messageId: message.messageId,
83
+ sender: message.sender.userId,
84
+ });
85
+ };
86
+ const onConnected = (userId) => {
87
+ console.log(userId);
88
+ };
89
+ const onReconnectStarted = () => { };
90
+ const onReconnectSucceeded = () => { };
91
+ const onReconnectFailed = () => { };
92
+ const onDisconnected = () => { };
93
+ const addHandler = () => {
94
+ let groupChannelHandler = new GroupChannelHandler({
95
+ onUserJoined,
96
+ onUserLeft,
97
+ onTypingStatusUpdated,
98
+ onMessageReceived,
99
+ });
100
+ let connectionHandler = new ConnectionHandler({
101
+ onConnected,
102
+ onReconnectStarted,
103
+ onReconnectSucceeded,
104
+ onReconnectFailed,
105
+ onDisconnected,
106
+ });
107
+ ref?.current?.groupChannel?.addGroupChannelHandler('CHA_HAN', groupChannelHandler);
108
+ ref?.current?.addConnectionHandler('CHA_CONN', connectionHandler);
109
+ };
110
+ const removeConnectionHandler = (appChannel) => {
111
+ ref.current.removeConnectionHandler(appChannel);
112
+ };
113
+ const removeGroupChannelHandler = (appChannel) => {
114
+ ref.current.groupChannel.removeGroupChannelHandler(appChannel);
115
+ };
116
+ const setPushTriggerOption = (pushTriggerOption) => {
117
+ ref.current.setPushTriggerOption(pushTriggerOption);
118
+ };
119
+ // for ios
120
+ const registerAPNSPushTokenForCurrentUser = (token) => {
121
+ ref.current.registerAPNSPushTokenForCurrentUser(token);
122
+ };
123
+ // for android
124
+ const registerFCMPushTokenForCurrentUser = (token) => {
125
+ ref.current.registerFCMPushTokenForCurrentUser(token);
126
+ };
127
+ const openImagePicker = () => {
128
+ const options = {
129
+ mediaType: 'photo',
130
+ includeBase64: false,
131
+ maxHeight: 2000,
132
+ maxWidth: 2000,
133
+ };
134
+ launchImageLibrary(options, (response) => {
135
+ if (response.didCancel) {
136
+ console.log('User cancelled image picker');
137
+ }
138
+ else if (response.errorMessage) {
139
+ console.log('Image picker error: ', response.errorMessage);
140
+ }
141
+ else {
142
+ const source = Platform.OS === 'android'
143
+ ? response.assets?.[0].uri
144
+ : response.assets?.[0].uri?.replace('file://', '');
145
+ const fileName = encodeURI(source.replace(/^.*[\\\/]/, ''));
146
+ uploadMedia(source, response.assets?.[0]?.type || '', fileName).then((res) => {
147
+ sendMessage({
148
+ message: res.data.url,
149
+ });
150
+ });
151
+ }
152
+ });
153
+ };
154
+ const uploadUsingGallery = async () => {
155
+ let permission = await request(Platform.OS === 'ios'
156
+ ? PERMISSIONS.IOS.PHOTO_LIBRARY
157
+ : parseFloat(Platform.Version + '') > 32
158
+ ? PERMISSIONS.ANDROID.READ_MEDIA_IMAGES
159
+ : PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE);
160
+ if (permission === 'granted' ||
161
+ permission === 'limited' ||
162
+ ['undetermined', 'authorized'].includes(permission)) {
163
+ openImagePicker();
164
+ }
165
+ return null;
166
+ };
167
+ useEffect(() => {
168
+ if (message !== '') {
169
+ const newArray = [...messageList];
170
+ newArray.push(message);
171
+ setMessageList([...newArray]);
172
+ }
173
+ }, [message]);
174
+ useEffect(() => {
175
+ const chatStart = async () => {
176
+ init();
177
+ addHandler();
178
+ connect().then(() => {
179
+ loadAllMessage(`channel_${data.group_id}`).then((res) => {
180
+ setMessageList(res);
181
+ setLoading(false);
182
+ });
183
+ });
184
+ };
185
+ chatStart();
186
+ }, []);
187
+ if (loading) {
188
+ return React.createElement(ActivityIndicator, null);
189
+ }
190
+ return (React.createElement(React.Fragment, null,
191
+ React.createElement(View, { style: styles.container },
192
+ React.createElement(FlatList, { data: messageList, keyExtractor: (item, index) => `${item.messageId}_${index}`, renderItem: renderMessage })),
193
+ React.createElement(View, { style: { flexDirection: 'row', width: '100%', padding: 10 } },
194
+ React.createElement(Button, { title: 'image', onPress: () => uploadUsingGallery() }),
195
+ React.createElement(TextInput, { style: styles.input, onChangeText: (txt) => setTextInput(txt), value: textInput, placeholder: "type .." }),
196
+ React.createElement(Button, { title: 'send', onPress: () => sendMessage({
197
+ message: textInput,
198
+ }) }))));
199
+ };
200
+ const styles = StyleSheet.create({
201
+ container: {
202
+ flex: 1,
203
+ justifyContent: 'flex-end', // to show the latest messages at the bottom
204
+ padding: 16,
205
+ },
206
+ userMessage: {
207
+ alignSelf: 'flex-end',
208
+ backgroundColor: '#10e1d0', // blue color for user messages
209
+ padding: 8,
210
+ borderRadius: 8,
211
+ marginBottom: 8,
212
+ maxWidth: '70%',
213
+ },
214
+ otherMessage: {
215
+ alignSelf: 'flex-start',
216
+ backgroundColor: '#a1a1a1', // light gray color for other messages
217
+ padding: 8,
218
+ borderRadius: 8,
219
+ marginBottom: 8,
220
+ maxWidth: '70%',
221
+ },
222
+ messageText: {
223
+ color: '#fff', // text color for user messages
224
+ },
225
+ input: {
226
+ flex: 1,
227
+ height: 40,
228
+ marginHorizontal: 12,
229
+ borderWidth: 1,
230
+ },
231
+ });
232
+ export default Chat;
@@ -0,0 +1,219 @@
1
+ import React, { useState } from 'react';
2
+ import { View, Text, ScrollView, TextInput, TouchableOpacity, StyleSheet, Platform, } from 'react-native';
3
+ import { createConsultation, deleteConsultation, getConsultationInfo, getConsultationList, getLastConsultation, getPrescription, MediumArray, MediumType, uploadMedia, } from 'react-native-altibbi';
4
+ import { ImageLibraryOptions, ImagePickerResponse, launchImageLibrary, } from 'react-native-image-picker';
5
+ import { PERMISSIONS, request } from 'react-native-permissions';
6
+ import RNFetchBlob from 'rn-fetch-blob';
7
+ import { Buffer } from 'buffer';
8
+ import { Radio } from '../component/radio';
9
+ const styles = StyleSheet.create({
10
+ textInput: {
11
+ flex: 1,
12
+ height: 40,
13
+ borderRadius: 15,
14
+ textAlign: 'center',
15
+ borderColor: 'gray',
16
+ borderWidth: 1,
17
+ marginTop: 10,
18
+ marginRight: 10,
19
+ },
20
+ button: {
21
+ backgroundColor: '#10e1d0',
22
+ flex: 1,
23
+ borderRadius: 15,
24
+ marginTop: 20,
25
+ height: 40,
26
+ marginRight: 10,
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ },
30
+ viewHolder: {
31
+ flexDirection: 'row',
32
+ width: '100%',
33
+ },
34
+ buttonText: {
35
+ fontWeight: 'bold',
36
+ fontSize: 18,
37
+ color: 'white',
38
+ },
39
+ input: {
40
+ marginVertical: 20,
41
+ fontSize: 16,
42
+ borderColor: 'gray',
43
+ borderWidth: 1,
44
+ borderRadius: 8,
45
+ padding: 20,
46
+ textAlign: 'auto',
47
+ },
48
+ input2: {
49
+ marginTop: 20,
50
+ fontSize: 16,
51
+ borderColor: 'gray',
52
+ borderWidth: 1,
53
+ borderRadius: 8,
54
+ textAlign: 'auto',
55
+ paddingLeft: 20,
56
+ minHeight: 50,
57
+ },
58
+ input3: {
59
+ marginTop: 20,
60
+ borderColor: 'gray',
61
+ borderWidth: 1,
62
+ borderRadius: 8,
63
+ textAlign: 'center',
64
+ height: 40,
65
+ marginRight: 20,
66
+ width: 40,
67
+ },
68
+ });
69
+ const Consultation = (props) => {
70
+ const [picked, setPicked] = useState(MediumArray[0]);
71
+ const [textBody, setTextBody] = useState('');
72
+ const [deleteConsultationId, setDeleteConsultationId] = useState('');
73
+ const [getConsultationId, setGetConsultationId] = useState('');
74
+ const [getConsultationListId, setGetConsultationListId] = useState('');
75
+ const [prescriptionId, setPrescriptionId] = useState('');
76
+ const [userId, setUserId] = useState();
77
+ const [imageID, setImageID] = useState();
78
+ const openImagePicker = () => {
79
+ const options = {
80
+ mediaType: 'photo',
81
+ includeBase64: false,
82
+ maxHeight: 2000,
83
+ maxWidth: 2000,
84
+ };
85
+ launchImageLibrary(options, (response) => {
86
+ const source = Platform.OS === 'android'
87
+ ? response?.assets?.[0].uri
88
+ : response?.assets?.[0].uri?.replace('file://', '');
89
+ const fileName = encodeURI(source.replace(/^.*[\\\/]/, ''));
90
+ const type = response?.assets?.[0]?.type || '';
91
+ uploadMedia(source, type, fileName).then((res) => {
92
+ setImageID(res?.data?.id);
93
+ });
94
+ }).then();
95
+ };
96
+ const uploadUsingGallery = async () => {
97
+ let permission = await request(Platform.OS === 'ios'
98
+ ? PERMISSIONS.IOS.PHOTO_LIBRARY
99
+ : parseFloat(Platform.Version + '') > 32
100
+ ? PERMISSIONS.ANDROID.READ_MEDIA_IMAGES
101
+ : PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE);
102
+ if (permission === 'granted' ||
103
+ permission === 'limited' ||
104
+ ['undetermined', 'authorized'].includes(permission)) {
105
+ openImagePicker();
106
+ }
107
+ return null;
108
+ };
109
+ const getCurrentConsultationInfo = () => {
110
+ getLastConsultation().then((res) => {
111
+ console.log(res);
112
+ if (res.data[0].status !== 'closed') {
113
+ props.navigation.navigate('WaitingRoom', {
114
+ videoConfig: res?.data[0]?.videoConfig,
115
+ voipConfig: res?.data[0]?.voipConfig,
116
+ chatConfig: res?.data[0]?.chatConfig,
117
+ status: res?.data[0]?.status,
118
+ medium: res?.data[0]?.medium,
119
+ channel: res.data[0].pusherChannel,
120
+ consultationId: res.data[0].id,
121
+ socketParams: res.data[0].socketParams,
122
+ });
123
+ }
124
+ });
125
+ };
126
+ return (React.createElement(ScrollView, { style: { backgroundColor: '#F3F3F4' } },
127
+ React.createElement(View, { style: { padding: 20 } },
128
+ React.createElement(Radio, { pick: [picked, setPicked], array: MediumArray, title: 'Medium' }),
129
+ React.createElement(View, { style: { flexDirection: 'row', flex: 1 } },
130
+ React.createElement(TextInput, { keyboardType: 'number-pad', style: [styles.input2, { flex: 1 }], placeholder: "userId", value: `${userId || ''}`, onChangeText: (text) => setUserId(parseInt(text, 10)) }),
131
+ React.createElement(TouchableOpacity, { onPress: () => uploadUsingGallery(), style: {
132
+ alignItems: 'center',
133
+ justifyContent: 'center',
134
+ backgroundColor: '#10e1d0',
135
+ marginTop: 20,
136
+ marginLeft: 10,
137
+ paddingHorizontal: 20,
138
+ borderRadius: 15,
139
+ } },
140
+ React.createElement(Text, { style: styles.buttonText }, "file"))),
141
+ React.createElement(TextInput, { style: styles.input, multiline: true, placeholder: "Medical consultaiton question with minimum 10 characters", value: textBody, onChangeText: (text) => setTextBody(text) }),
142
+ React.createElement(TouchableOpacity, { onPress: () => {
143
+ if (!textBody || textBody.length < 10 || !userId) {
144
+ return;
145
+ }
146
+ if (picked === 'video') {
147
+ request(Platform.OS === 'ios'
148
+ ? PERMISSIONS.IOS.CAMERA
149
+ : PERMISSIONS.ANDROID.CAMERA);
150
+ }
151
+ createConsultation({
152
+ question: textBody,
153
+ medium: picked,
154
+ user_id: userId,
155
+ mediaIds: imageID ? [imageID] : [],
156
+ })
157
+ .then((res) => {
158
+ console.log(res);
159
+ getCurrentConsultationInfo();
160
+ })
161
+ .catch((error) => {
162
+ console.log(error);
163
+ });
164
+ }, style: styles.button },
165
+ React.createElement(Text, { style: styles.buttonText }, "Create Consultation")),
166
+ React.createElement(View, { style: { flexDirection: 'row' } },
167
+ React.createElement(TextInput, { keyboardType: 'number-pad', style: styles.input3, placeholder: "id", value: getConsultationListId, onChangeText: (idText) => setGetConsultationListId(idText) }),
168
+ React.createElement(TouchableOpacity, { onPress: () => {
169
+ getConsultationList(parseInt(getConsultationListId), 1, 20).then((res) => {
170
+ console.log(res);
171
+ });
172
+ }, style: styles.button },
173
+ React.createElement(Text, { style: styles.buttonText }, "Consultation List"))),
174
+ React.createElement(TouchableOpacity, { onPress: () => {
175
+ getCurrentConsultationInfo();
176
+ }, style: styles.button },
177
+ React.createElement(Text, { style: styles.buttonText }, "Last Consultation")),
178
+ React.createElement(View, { style: { flexDirection: 'row' } },
179
+ React.createElement(TextInput, { keyboardType: 'number-pad', style: styles.input3, placeholder: "id", value: deleteConsultationId, onChangeText: (idText) => setDeleteConsultationId(idText) }),
180
+ React.createElement(TouchableOpacity, { onPress: () => {
181
+ if (!deleteConsultationId) {
182
+ return;
183
+ }
184
+ deleteConsultation(parseInt(deleteConsultationId)).then((res) => {
185
+ console.log(res);
186
+ });
187
+ }, style: styles.button },
188
+ React.createElement(Text, { style: styles.buttonText }, "Delete Consultation"))),
189
+ React.createElement(View, { style: { flexDirection: 'row' } },
190
+ React.createElement(TextInput, { keyboardType: 'number-pad', style: styles.input3, placeholder: "id", value: getConsultationId, onChangeText: (idText) => setGetConsultationId(idText) }),
191
+ React.createElement(TouchableOpacity, { onPress: () => {
192
+ if (!getConsultationId) {
193
+ return;
194
+ }
195
+ getConsultationInfo(parseInt(getConsultationId)).then((res) => {
196
+ console.log(res);
197
+ });
198
+ }, style: styles.button },
199
+ React.createElement(Text, { style: styles.buttonText }, "Get Consultation by id"))),
200
+ React.createElement(View, { style: { flexDirection: 'row' } },
201
+ React.createElement(TextInput, { keyboardType: 'number-pad', style: styles.input3, placeholder: "id", value: prescriptionId, onChangeText: (idText) => setPrescriptionId(idText) }),
202
+ React.createElement(TouchableOpacity, { onPress: () => {
203
+ getPrescription(parseInt(prescriptionId)).then(async (response) => {
204
+ const { dirs: { DownloadDir, DocumentDir }, // DownloadDir for android , DocumentDir for ios
205
+ } = RNFetchBlob.fs;
206
+ const arrayBuffer = await response.arrayBuffer();
207
+ const buffer = Buffer.from(arrayBuffer);
208
+ const base64String = buffer.toString('base64');
209
+ const filePath = (Platform.OS === 'ios' ? DocumentDir : DownloadDir) +
210
+ '/prescription' +
211
+ new Date().getTime() +
212
+ '.pdf';
213
+ await RNFetchBlob.fs.createFile(filePath, base64String, 'base64');
214
+ console.log('Download Completed');
215
+ });
216
+ }, style: styles.button },
217
+ React.createElement(Text, { style: styles.buttonText }, "download Prescription"))))));
218
+ };
219
+ export default Consultation;
@@ -0,0 +1,38 @@
1
+ import React, { useEffect } from 'react';
2
+ import { StyleSheet, Text, TouchableOpacity, View, } from 'react-native';
3
+ import { init } from 'react-native-altibbi';
4
+ import { useNavigation } from '@react-navigation/native';
5
+ const styles = StyleSheet.create({
6
+ container: {
7
+ flex: 1,
8
+ padding: 20,
9
+ },
10
+ button: {
11
+ width: '100%',
12
+ borderRadius: 15,
13
+ height: 50,
14
+ backgroundColor: '#10e1d0',
15
+ alignItems: 'center',
16
+ justifyContent: 'center',
17
+ marginTop: 20,
18
+ },
19
+ buttonText: {
20
+ color: 'white',
21
+ fontSize: 20,
22
+ },
23
+ });
24
+ const Home = () => {
25
+ useEffect(() => {
26
+ init('', '', 'ar');
27
+ }, []);
28
+ const navigation = useNavigation();
29
+ const navigate = (page) => {
30
+ navigation.navigate(page);
31
+ };
32
+ return (React.createElement(View, { style: styles.container },
33
+ React.createElement(TouchableOpacity, { onPress: () => navigate('User'), style: styles.button },
34
+ React.createElement(Text, { style: styles.buttonText }, "User Page")),
35
+ React.createElement(TouchableOpacity, { onPress: () => navigate('Consultation'), style: styles.button },
36
+ React.createElement(Text, { style: styles.buttonText }, "consultation Page"))));
37
+ };
38
+ export default Home;
@@ -0,0 +1,133 @@
1
+ import React, { useState } from 'react';
2
+ import { ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
3
+ import { bloodTypeArray, boolStringArray, createUser, deleteUser, genderTypeArray, getUser, getUsers, materialStatusArray, } from 'react-native-altibbi';
4
+ import { Radio } from '../component/radio';
5
+ const styles = StyleSheet.create({
6
+ textInput: {
7
+ flex: 1,
8
+ height: 40,
9
+ borderRadius: 15,
10
+ textAlign: 'center',
11
+ borderColor: 'gray',
12
+ borderWidth: 1,
13
+ marginTop: 10,
14
+ marginRight: 10,
15
+ },
16
+ button: {
17
+ backgroundColor: '#10e1d0',
18
+ flex: 1,
19
+ borderRadius: 15,
20
+ marginTop: 10,
21
+ height: 40,
22
+ marginRight: 10,
23
+ alignItems: 'center',
24
+ justifyContent: 'center',
25
+ },
26
+ viewHolder: {
27
+ flexDirection: 'row',
28
+ width: '100%',
29
+ },
30
+ buttonText: {
31
+ fontSize: 16,
32
+ color: 'white',
33
+ },
34
+ });
35
+ const User = () => {
36
+ const [name, setName] = useState('');
37
+ const [phoneNumber, setPhoneNumber] = useState('');
38
+ const [email, setEmail] = useState('');
39
+ const [dateOfBirth, setDateOfBirth] = useState('');
40
+ const [gender, setGender] = useState(genderTypeArray[0]);
41
+ const [insuranceId, setInsuranceId] = useState('');
42
+ const [policyNumber, setPolicyNumber] = useState('');
43
+ const [nationalityNumber, setNationalityNumber] = useState('');
44
+ const [height, setHeight] = useState('');
45
+ const [weight, setWeight] = useState('');
46
+ const [bloodType, setBloodType] = useState();
47
+ const [smoker, setSmoker] = useState();
48
+ const [alcoholic, setAlcoholic] = useState();
49
+ const [maritalStatus, setMaritalStatus] = useState();
50
+ const [id, setID] = useState('');
51
+ const [id2, setID2] = useState('');
52
+ return (React.createElement(ScrollView, { style: { backgroundColor: '#F3F3F4' } },
53
+ React.createElement(View, { style: { padding: 20 } },
54
+ React.createElement(View, { style: styles.viewHolder },
55
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setName(text), value: name, placeholder: 'Name' }),
56
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setDateOfBirth(text), value: dateOfBirth, placeholder: 'date of birth' })),
57
+ React.createElement(View, { style: styles.viewHolder },
58
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setEmail(text), value: email, placeholder: 'email' }),
59
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setPhoneNumber(text), value: phoneNumber, placeholder: 'phoneNumber' })),
60
+ React.createElement(View, { style: styles.viewHolder },
61
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setInsuranceId(text), value: insuranceId, placeholder: 'insuranceId' })),
62
+ React.createElement(View, { style: styles.viewHolder },
63
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setHeight(text), value: height, placeholder: 'height' }),
64
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setWeight(text), value: weight, placeholder: 'weight' })),
65
+ React.createElement(View, { style: styles.viewHolder },
66
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setPolicyNumber(text), value: policyNumber, placeholder: 'policyNumber' }),
67
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setNationalityNumber(text), value: nationalityNumber, placeholder: 'nationalityNumber' })),
68
+ React.createElement(Radio, { pick: [gender, setGender], array: genderTypeArray, title: 'Gender' }),
69
+ React.createElement(Radio, { pick: [maritalStatus, setMaritalStatus], array: materialStatusArray, title: 'Marital Status' }),
70
+ React.createElement(Radio, { pick: [alcoholic, setAlcoholic], array: boolStringArray, title: 'Alcoholic' }),
71
+ React.createElement(Radio, { pick: [smoker, setSmoker], array: boolStringArray, title: 'Smoker' }),
72
+ React.createElement(Radio, { pick: [bloodType, setBloodType], array: bloodTypeArray, title: 'Gender' }),
73
+ React.createElement(TouchableOpacity, { style: styles.button, onPress: () => {
74
+ const params = {
75
+ name,
76
+ phone_number: phoneNumber,
77
+ email,
78
+ date_of_birth: dateOfBirth,
79
+ gender,
80
+ insurance_id: insuranceId,
81
+ policy_number: policyNumber,
82
+ nationality_number: nationalityNumber,
83
+ height,
84
+ weight,
85
+ blood_type: bloodType,
86
+ smoker,
87
+ alcoholic,
88
+ marital_status: maritalStatus,
89
+ };
90
+ createUser(params).then((res) => {
91
+ console.log(res);
92
+ }).catch((err) => {
93
+ console.log('something went wrong', err);
94
+ });
95
+ ;
96
+ } },
97
+ React.createElement(Text, { style: styles.buttonText }, "Create User")),
98
+ React.createElement(View, { style: styles.viewHolder },
99
+ React.createElement(TouchableOpacity, { style: styles.button, onPress: () => {
100
+ if (!id || id.length === 0) {
101
+ console.log(id);
102
+ return;
103
+ }
104
+ getUser(id).then((res) => {
105
+ console.log('Example userName: ', res.data.name);
106
+ }).catch((err) => {
107
+ console.log('something went wrong', err);
108
+ });
109
+ } },
110
+ React.createElement(Text, { style: styles.buttonText }, "Get User By Id")),
111
+ React.createElement(TextInput, { keyboardType: 'number-pad', style: styles.textInput, onChangeText: (text) => setID(text), value: id, placeholder: 'user Id' })),
112
+ React.createElement(View, { style: styles.viewHolder },
113
+ React.createElement(TouchableOpacity, { style: styles.button, onPress: () => {
114
+ deleteUser(id2).then((res) => {
115
+ console.log(res);
116
+ }).catch((err) => {
117
+ console.log('something went wrong', err);
118
+ });
119
+ ;
120
+ } },
121
+ React.createElement(Text, { style: styles.buttonText }, "delete user")),
122
+ React.createElement(TextInput, { style: styles.textInput, onChangeText: (text) => setID2(text), value: id2, placeholder: 'userDeleteId' })),
123
+ React.createElement(TouchableOpacity, { style: styles.button, onPress: () => {
124
+ getUsers(1).then((res) => {
125
+ console.log(res);
126
+ }).catch((err) => {
127
+ console.log('something went wrong', err);
128
+ });
129
+ ;
130
+ } },
131
+ React.createElement(Text, { style: styles.buttonText }, "get all users")))));
132
+ };
133
+ export default User;