ordering-ui-react-native 0.15.54 → 0.15.55

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.15.54",
3
+ "version": "0.15.55",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -1,18 +1,66 @@
1
- import React, { useState } from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
  import { StyleSheet, View, Dimensions, Platform } from 'react-native';
3
- import { useLanguage } from 'ordering-components/native';
3
+ import { useForm, Controller } from 'react-hook-form';
4
+ import { useLanguage, useApi } from 'ordering-components/native';
4
5
  import { useTheme } from 'styled-components/native';
5
- import { LogoWrapper, Container, BackgroundImage } from './styles';
6
- import { OButton, OIcon, OText } from '../shared';
6
+ import { LogoWrapper, Container, BackgroundImage, FormInput } from './styles';
7
+ import { OButton, OIcon, OText, OInput } from '../shared';
7
8
  import { _setStoreData } from '../../providers/StoreUtil';
8
9
 
9
10
  export const Home = (props: any) => {
10
- const { onNavigationRedirect } = props;
11
+ const { onNavigationRedirect, useRootPoint } = props;
11
12
  const safeHeight = Platform.OS === 'ios' ? 80 : 40;
12
13
 
13
14
  const theme = useTheme();
15
+ const [ordering, { setOrdering }] = useApi();
14
16
  const [, t] = useLanguage();
17
+ const { control, handleSubmit, errors } = useForm();
15
18
 
19
+
20
+ const styles = StyleSheet.create({
21
+ logo: {
22
+ height: 65,
23
+ width: 300,
24
+ },
25
+ wrapperContent: {
26
+ width: '100%',
27
+ },
28
+ wrapperText: {
29
+ marginBottom: 20,
30
+ },
31
+ textTitle: {
32
+ fontWeight: '600',
33
+ fontStyle: 'normal',
34
+ fontSize: 50,
35
+ },
36
+ textSubtitle: {
37
+ fontWeight: 'normal',
38
+ fontStyle: 'normal',
39
+ fontSize: 14,
40
+ },
41
+ wrapperBtn: {
42
+ marginBottom: 20
43
+ },
44
+ btn: {
45
+ borderRadius: 7.6,
46
+ marginTop: 20,
47
+ },
48
+ btnText: {
49
+ fontFamily: 'Poppins',
50
+ fontStyle: 'normal',
51
+ fontWeight: 'normal',
52
+ fontSize: 18,
53
+ },
54
+ input: {
55
+ borderWidth: 1,
56
+ borderRadius: 7.6,
57
+ borderColor: Object.keys(errors).length > 0 ? theme.colors.error : theme.colors.inputSignup,
58
+ backgroundColor: theme.colors.transparent,
59
+ },
60
+ });
61
+
62
+ const [projectName, setProjectName] = useState<any>(null)
63
+ const [isLoadingProject, setLoadingProject] = useState(false)
16
64
  const [orientation, setOrientation] = useState(
17
65
  Dimensions.get('window').width < Dimensions.get('window').height
18
66
  ? 'Portrait'
@@ -34,6 +82,27 @@ export const Home = (props: any) => {
34
82
  }
35
83
  });
36
84
 
85
+ const onSubmit = (values: any) => {
86
+ setLoadingProject(true)
87
+ setProjectName(values)
88
+ setOrdering({ ...ordering, project: values?.project_name })
89
+ _setStoreData('project_name', values?.project_name)
90
+ };
91
+
92
+ useEffect(() => {
93
+ if (Object.keys(errors).length > 0) {
94
+ setProjectName(null)
95
+ setLoadingProject(false)
96
+ }
97
+ }, [errors])
98
+
99
+ useEffect(() => {
100
+ if (ordering?.project === projectName?.project_name) {
101
+ setLoadingProject(false)
102
+ onNavigationRedirect('Login')
103
+ }
104
+ }, [ordering])
105
+
37
106
  return (
38
107
  <Container height={windowHeight - safeHeight} orientation={orientation}>
39
108
  <BackgroundImage
@@ -54,58 +123,62 @@ export const Home = (props: any) => {
54
123
  </OText>
55
124
  </View>
56
125
 
57
- <View style={styles.wrapperBtn}>
58
- <OButton
59
- text={t('LOGIN', 'Login')}
60
- textStyle={{
61
- ...styles.btnText,
62
- color: theme.colors.inputTextColor,
63
- }}
64
- bgColor={theme.colors.primary}
65
- borderColor={theme.colors.primary}
66
- style={styles.btn}
67
- imgRightSrc={false}
68
- onClick={() => onNavigationRedirect('Login')}
69
- />
70
- </View>
126
+ <>
127
+ {useRootPoint && (
128
+ <FormInput>
129
+ <Controller
130
+ control={control}
131
+ name='project_name'
132
+ rules={{ required: t(`VALIDATION_ERROR_PROJECT_NAME_REQUIRED`, 'The field project name is required') }}
133
+ defaultValue=""
134
+ render={({ onChange, value }: any) => (
135
+ <OInput
136
+ name='project_name'
137
+ placeholderTextColor={theme.colors.arrowColor}
138
+ placeholder={t('PROJECT_NAME', 'Project Name')}
139
+ icon={theme.images.general.project}
140
+ iconColor={theme.colors.arrowColor}
141
+ onChange={(e: any) => onChange(e?.target?.value)}
142
+ selectionColor={theme.colors.primary}
143
+ color={theme.colors.white}
144
+ value={value}
145
+ style={styles.input}
146
+ returnKeyType='done'
147
+ autoCorrect={false}
148
+ autoCapitalize='none'
149
+ blurOnSubmit={false}
150
+ onSubmitEditing={() => handleSubmit(onSubmit)()}
151
+ />
152
+ )}
153
+ />
154
+ </FormInput>
155
+ )}
156
+ {Object.keys(errors).length > 0 && (
157
+ <OText
158
+ color={theme.colors.white}
159
+ style={{ alignSelf: 'center', marginTop: 5 }}
160
+ >
161
+ {errors['project_name'].message}
162
+ </OText>
163
+ )}
164
+ <View style={styles.wrapperBtn}>
165
+ <OButton
166
+ text={useRootPoint ? t('SET_PROJECT', 'Set project') : t('LOGIN', 'Login')}
167
+ textStyle={{
168
+ ...styles.btnText,
169
+ color: theme.colors.inputTextColor,
170
+ }}
171
+ bgColor={theme.colors.primary}
172
+ borderColor={theme.colors.primary}
173
+ isLoading={isLoadingProject}
174
+ style={styles.btn}
175
+ imgRightSrc={false}
176
+ onClick={() => useRootPoint ? handleSubmit(onSubmit)() : onNavigationRedirect('Login')}
177
+ />
178
+ </View>
179
+ </>
71
180
  </View>
72
181
  </BackgroundImage>
73
182
  </Container>
74
183
  );
75
184
  };
76
-
77
- const styles = StyleSheet.create({
78
- logo: {
79
- height: 65,
80
- width: 300,
81
- },
82
- wrapperContent: {
83
- width: '100%',
84
- },
85
- wrapperText: {
86
- marginBottom: 20,
87
- },
88
- textTitle: {
89
- fontWeight: '600',
90
- fontStyle: 'normal',
91
- fontSize: 50,
92
- },
93
- textSubtitle: {
94
- fontWeight: 'normal',
95
- fontStyle: 'normal',
96
- fontSize: 14,
97
- },
98
- wrapperBtn: {
99
- marginBottom: 20,
100
- },
101
- btn: {
102
- borderRadius: 7.6,
103
- marginTop: 20,
104
- },
105
- btnText: {
106
- fontFamily: 'Poppins',
107
- fontStyle: 'normal',
108
- fontWeight: 'normal',
109
- fontSize: 18,
110
- },
111
- });
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components/native';
1
+ import styled, { css } from 'styled-components/native';
2
2
 
3
3
  export const Container = styled.View`
4
4
  width: 100%;
@@ -25,3 +25,10 @@ export const BackgroundImage = styled.ImageBackground`
25
25
  align-items: center;
26
26
  padding: 20px 40px;
27
27
  `;
28
+
29
+ export const FormInput = styled.View`
30
+ display: flex;
31
+ flex-direction: column;
32
+ width: 100%;
33
+ min-height: 50px;
34
+ `;
@@ -90,33 +90,12 @@ const BusinessReviewsUI = (props: BusinessReviewsParams) => {
90
90
  </View>
91
91
  );
92
92
 
93
- const ReviewItem = ({ comment, created_at, total, customer }: any) => (
93
+ const ReviewItem = ({ comment, created_at, total }: any) => (
94
94
  <View style={{ marginBottom: 30 }}>
95
- <View
96
- style={{ flexDirection: 'row', marginBottom: 19, alignItems: 'center' }}>
97
- <OIcon
98
- url={theme.images.dummies.customerPhoto}
99
- width={38}
100
- height={38}
101
- style={{
102
- borderRadius: 7.6,
103
- borderWidth: 1,
104
- borderColor: theme.colors.border,
105
- marginEnd: 9,
106
- }}
107
- />
108
- <View>
109
- <OText size={12} color={theme.colors.textNormal} weight={'500'}>
110
- {customer?.name || 'Jane Cooper'}
111
- </OText>
112
- <OText size={10} color={theme.colors.textSecondary}>
113
- {moment(created_at).format('MMMM d, yyyy • hh:mm')}
114
- </OText>
115
- </View>
116
- </View>
117
- <OText size={10} color={theme.colors.textNormal}>
118
- {comment}
95
+ <OText size={12} color={theme.colors.textSecondary}>
96
+ {moment(created_at).format('MMMM d, yyyy hh:mm')}
119
97
  </OText>
98
+ <OText size={12} color={theme.colors.textNormal}>{comment}</OText>
120
99
  </View>
121
100
  );
122
101