import React, {useState } from 'react'; import { StatusBar, StyleSheet, Text, useColorScheme, View, TouchableHighlight, TextInput } from 'react-native'; import { Icon } from 'react-native-elements'; const RegisterUserScreen = () => { const [username, setUsername] = useState("") const [orgname, setOrgname] = useState("") const [token, setToken] = useState("none") var [ isPress, setIsPress ] = useState(false); const register = () => { var data = { "username": username, "orgName": orgname } fetch("http://192.168.29.141:4000/users", { method: "POST", headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', }, body: JSON.stringify(data) }) .then(function (response) { return response.json(); }) .then(function (data) { console.log(data) setToken(data) }); } var touchProps = { activeOpacity: 1, underlayColor: 'white', style: isPress ? styles.btnPress : styles.btnNormal, onHideUnderlay: () => setIsPress(false), onShowUnderlay: () => setIsPress(true), onPress: register, } var textInputProps = { style:styles.input, onChangeText:setUsername, value:username, placeholder:"username", placeholderTextColor : "#4b4a4a", } return ( <> Log In Submit {token.message} ); } const styles = StyleSheet.create({ viewRoot: { backgroundColor: '#ffffff', height: '100%', justifyContent: 'center', alignItems: 'center' }, heading: { color: '#1C254E', fontSize: 60, textAlign: 'center', fontFamily: 'Ubuntu-Bold', }, icon: { alignSelf: "flex-start", marginLeft: '28%', flexDirection: 'row', }, btnNormal: { borderRadius: 10, height: 45, width: 140, backgroundColor: '#1C254E', alignItems: 'center', justifyContent: 'center', }, btnText: { textAlign: 'center', fontSize: 22, color:'white', }, btnPress: { borderRadius: 10, height: 45, width: 140, backgroundColor: '#1C254E', justifyContent: 'center', }, input: { height: 60, width: 280, margin: 12, borderRadius: 15, padding: 10, color: "black", backgroundColor: "#c4c4c4", }, }); export default RegisterUserScreen;