mirror of
https://github.com/lemeow125/Reactnative-notesapp.git
synced 2024-11-17 06:29:27 +08:00
Merge pull request #23 from lemeow125/feature/userinfo
Feature/userinfo
This commit is contained in:
commit
5af130d98e
3 changed files with 50 additions and 42 deletions
|
@ -66,10 +66,6 @@ export default function Login() {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<TouchableOpacity>
|
|
||||||
<Text style={styles.forgot_button}>Forgot Password?</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={async () => {
|
onPress={async () => {
|
||||||
setUser({
|
setUser({
|
||||||
|
|
|
@ -1,39 +1,53 @@
|
||||||
import * as React from 'react';
|
import * as React from "react";
|
||||||
import {View, Text} from 'react-native';
|
import { View, Text } from "react-native";
|
||||||
import styles from '../../styles';
|
import styles from "../../styles";
|
||||||
import Background from '../../Components/Background/Background';
|
import Background from "../../Components/Background/Background";
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from "react-native-safe-area-context";
|
||||||
import UserIcon from '../../Components/Icons/UserIcon/UserIcon';
|
import { UserInfo } from "../../Components/Api/Api";
|
||||||
import {TouchableOpacity, TextInput} from "react-native";
|
import { useQuery } from "react-query";
|
||||||
import { useState } from "react";
|
import { useSelector } from "react-redux";
|
||||||
|
import { RootState } from "../../Features/Redux/Store/Store";
|
||||||
|
|
||||||
export default function UserInfo() {
|
export default function UserPage() {
|
||||||
const [isEditable, setIsEditable] = useState(false);
|
const { data, isLoading, error } = useQuery("user", UserInfo, {
|
||||||
|
retry: 0,
|
||||||
|
onSuccess: (data) => console.log(data),
|
||||||
|
});
|
||||||
|
const logged_in = useSelector((state: RootState) => state.logged_in.value);
|
||||||
|
if (isLoading && !error) {
|
||||||
|
return (
|
||||||
|
<View style={styles.background}>
|
||||||
|
<View style={styles.addnotecont}>
|
||||||
|
<Text style={{ ...styles.text_white, ...{ fontSize: 25 } }}>
|
||||||
|
Loading...
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
} else if (error) {
|
||||||
|
return (
|
||||||
|
<View style={styles.background}>
|
||||||
|
<View style={styles.addnotecont}>
|
||||||
|
<Text style={{ ...styles.text_white, ...{ fontSize: 25 } }}>
|
||||||
|
An error has occured
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<Background>
|
<Background>
|
||||||
<Text style={{...styles.text_white, ...{fontSize: 32}}}></Text>
|
<View style={styles.addnotecont}>
|
||||||
<SafeAreaView>
|
<Text style={{ ...styles.text_white, ...{ fontSize: 25 } }}>
|
||||||
<View style={styles.userinfocont}>
|
Username: {data.username}
|
||||||
<Text style ={styles.userlabel} > <UserIcon size={32} color="white"/> USER INFO</Text>
|
</Text>
|
||||||
|
<Text style={{ ...styles.text_white, ...{ fontSize: 25 } }}>
|
||||||
</View>
|
Email: {data.email}
|
||||||
<View style={styles.form}>
|
</Text>
|
||||||
<View style={styles.inputRow}>
|
<Text style={{ ...styles.text_white, ...{ fontSize: 25 } }}>
|
||||||
<Text style={styles.label}>Username</Text>
|
User ID: {data.id}
|
||||||
<TextInput
|
</Text>
|
||||||
style={[styles.inputUser, !isEditable && styles.disabledInput]}
|
|
||||||
editable={isEditable}
|
|
||||||
/>
|
|
||||||
|
|
||||||
</View>
|
|
||||||
<TouchableOpacity
|
|
||||||
style={styles.editButton}
|
|
||||||
onPress={() => setIsEditable(!isEditable)}
|
|
||||||
>
|
|
||||||
<Text style={styles.buttonText}>{isEditable ? "Save" : "Edit Profile"}</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
</View>
|
||||||
</SafeAreaView>
|
|
||||||
</Background>
|
</Background>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ const styles = StyleSheet.create({
|
||||||
height: 50,
|
height: 50,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
backgroundColor: "#0dbc6a",
|
backgroundColor: "lightgreen",
|
||||||
},
|
},
|
||||||
registerbtn: {
|
registerbtn: {
|
||||||
width: "80%",
|
width: "80%",
|
||||||
|
@ -73,7 +73,7 @@ const styles = StyleSheet.create({
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
marginTop: 40,
|
marginTop: 40,
|
||||||
backgroundColor: "#e2b465",
|
backgroundColor: "orange",
|
||||||
},
|
},
|
||||||
loginText: {
|
loginText: {
|
||||||
color: "white",
|
color: "white",
|
||||||
|
@ -150,7 +150,7 @@ const styles = StyleSheet.create({
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
},
|
},
|
||||||
typehere: {
|
typehere: {
|
||||||
backgroundColor: "#00293e",
|
backgroundColor: "black",
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
width: "75%",
|
width: "75%",
|
||||||
height: 300,
|
height: 300,
|
||||||
|
@ -174,8 +174,6 @@ const styles = StyleSheet.create({
|
||||||
width: "80%",
|
width: "80%",
|
||||||
height: 40,
|
height: 40,
|
||||||
marginTop: 20,
|
marginTop: 20,
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
},
|
},
|
||||||
addnotecont: {
|
addnotecont: {
|
||||||
marginTop: 30,
|
marginTop: 30,
|
||||||
|
@ -184,7 +182,7 @@ const styles = StyleSheet.create({
|
||||||
minHeight: 500,
|
minHeight: 500,
|
||||||
width: 350,
|
width: 350,
|
||||||
borderRadius: 25,
|
borderRadius: 25,
|
||||||
backgroundColor: "black",
|
backgroundColor: "#001018",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue