Skip to content

Commit beb2fc7

Browse files
committed
Merge branch 'wip/layout'
2 parents 0c5c97c + 943d0fd commit beb2fc7

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

src/features/login/LoginForm.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Text, TouchableOpacity, View } from 'bara-react'
1+
import { Text, TouchableOpacity, useBarnState, View } from 'bara-react'
22
import React from 'react'
3-
import { compose, graphql } from 'react-apollo'
3+
import { compose, graphql, withApollo } from 'react-apollo'
44
import { StyleSheet, TextInput } from 'react-native'
55

66
import * as a from './graphql'
@@ -11,7 +11,7 @@ const styles = StyleSheet.create({
1111
maxWidth: 750,
1212
backgroundColor: '#ccc',
1313
padding: 16,
14-
borderRadius: 16,
14+
borderRadius: 8,
1515
shadowColor: '#000000',
1616
shadowOffset: {
1717
width: 0,
@@ -36,17 +36,39 @@ const styles = StyleSheet.create({
3636
},
3737
})
3838

39-
export interface LoginProps {}
39+
export interface LoginProps {
40+
key: string
41+
}
4042

4143
const LoginForm = (props: LoginProps) => {
44+
const [username, setUsername] = useBarnState('form.login.username', '')
45+
const [password, setPassword] = useBarnState('form.login.password', '')
46+
47+
const { key } = props
48+
49+
function updateUsername(newVal: string) {
50+
setUsername(newVal)
51+
}
52+
53+
function updatePassword(newVal: string) {
54+
setPassword(newVal)
55+
}
56+
4257
return (
4358
<View style={styles.container}>
4459
<View style={styles.inputContainer}>
45-
<Text style={styles.inputLabel}>Username:</Text>
46-
<TextInput style={styles.inputText} />
60+
<Text style={styles.inputLabel}>Username: {username}</Text>
61+
<TextInput onChangeText={updateUsername} style={styles.inputText} />
62+
</View>
63+
<View style={styles.inputContainer}>
64+
<Text style={styles.inputLabel}>Password: {password}</Text>
65+
<TextInput onChangeText={updatePassword} style={styles.inputText} />
4766
</View>
4867
</View>
4968
)
5069
}
5170

52-
export default graphql(a.login)(LoginForm)
71+
export default compose(
72+
graphql(a.login, { name: 'login' }),
73+
graphql(a.translations),
74+
)(withApollo(LoginForm))

src/features/login/LoginScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const LoginScreen = (props: LoginProps) => {
2727
return (
2828
<View style={styles.container}>
2929
<Text style={styles.headerText}>Đăng Nhập</Text>
30-
<LoginForm />
30+
<LoginForm key="LOGIN" />
3131
</View>
3232
)
3333
}

src/features/login/graphql.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import { gql } from 'apollo-boost'
22

3+
export const translations = gql`
4+
query getLabelByKey($key: String!) {
5+
getLabelByKey(key: $key) {
6+
id
7+
translationTexts {
8+
text
9+
}
10+
}
11+
}
12+
`
13+
314
export const login = gql`
415
mutation login($username: String!, $password: String!) {
516
login(username: $username, password: $password) {

src/graphql/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ApolloClient from 'apollo-boost'
22

33
export const client = new ApolloClient({
4-
uri: 'https://graph.btngiadinh.com',
4+
// uri: 'https://graph.btngiadinh.com',
5+
uri: 'http://localhost:4000',
56
})

0 commit comments

Comments
 (0)