From 9851c426e0dcf545bc49daf9d7ef26237ce5d44a Mon Sep 17 00:00:00 2001 From: leKimChiii Date: Sun, 16 Apr 2023 20:19:39 +0800 Subject: [PATCH 1/2] added inital info page --- src/Routes/UserInfo/UserInfo.tsx | 68 +++++++++++++++++++------------- src/styles.tsx | 10 ++--- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/Routes/UserInfo/UserInfo.tsx b/src/Routes/UserInfo/UserInfo.tsx index e755dba..54a42fe 100644 --- a/src/Routes/UserInfo/UserInfo.tsx +++ b/src/Routes/UserInfo/UserInfo.tsx @@ -3,37 +3,49 @@ import {View, Text} from 'react-native'; import styles from '../../styles'; import Background from '../../Components/Background/Background'; import { SafeAreaView } from 'react-native-safe-area-context'; -import UserIcon from '../../Components/Icons/UserIcon/UserIcon'; -import {TouchableOpacity, TextInput} from "react-native"; -import { useState } from "react"; +import { UserInfo } from '../../Components/Api/Api'; +import { useQuery } from 'react-query'; +import { useSelector } from 'react-redux'; +import { RootState } from '../../Features/Redux/Store/Store'; -export default function UserInfo() { - const [isEditable, setIsEditable] = useState(false); +export default function UserPage() { + const { data, isLoading, error } = useQuery("user", UserInfo, { retry: 0, onSuccess: (data) => console.log(data) }); + const logged_in = useSelector( + (state: RootState) => state.logged_in.value + ); + const logged_in_user = useSelector( + (state: RootState) => state.logged_in_user.value + ); + if (isLoading && !error) { + return ( + + + Loading... + + + ); + } else if (error) { + return ( + + + An error has occured + + + ); + } return ( - - - - USER INFO - - - - - Username - - - - setIsEditable(!isEditable)} - > - {isEditable ? "Save" : "Edit Profile"} - + + + + + Username: {logged_in_user.username} + Email: {logged_in_user.email} + User ID: {logged_in_user.id} + + + - ); -} +} \ No newline at end of file diff --git a/src/styles.tsx b/src/styles.tsx index 7b212a1..c90d7a5 100644 --- a/src/styles.tsx +++ b/src/styles.tsx @@ -64,7 +64,7 @@ const styles = StyleSheet.create({ height: 50, alignItems: "center", justifyContent: "center", - backgroundColor: "#0dbc6a", + backgroundColor: "lightgreen", }, registerbtn: { width: "80%", @@ -73,7 +73,7 @@ const styles = StyleSheet.create({ alignItems: "center", justifyContent: "center", marginTop: 40, - backgroundColor: "#e2b465", + backgroundColor: "orange", }, loginText: { color: "white", @@ -150,7 +150,7 @@ const styles = StyleSheet.create({ alignItems: "center", }, typehere: { - backgroundColor: "#00293e", + backgroundColor: "black", borderRadius: 10, width: "75%", height: 300, @@ -173,8 +173,6 @@ const styles = StyleSheet.create({ width: "80%", height: 40, marginTop: 20, - alignItems: "center", - justifyContent: "center", }, addnotecont: { marginTop: 30, @@ -182,7 +180,7 @@ const styles = StyleSheet.create({ height: 500, width: 350, borderRadius: 25, - backgroundColor: "black", + backgroundColor: "#001018", alignItems: "center", justifyContent: "center", }, From 2ba28ac8dd6ff3ba88703e65e10533f409749b4d Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sun, 16 Apr 2023 20:29:12 +0800 Subject: [PATCH 2/2] Finished up userinfo page and removed forgot password from login --- src/Routes/Login/Login.tsx | 4 --- src/Routes/UserInfo/UserInfo.tsx | 58 +++++++++++++++++--------------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/Routes/Login/Login.tsx b/src/Routes/Login/Login.tsx index b88bd00..60cea1f 100644 --- a/src/Routes/Login/Login.tsx +++ b/src/Routes/Login/Login.tsx @@ -66,10 +66,6 @@ export default function Login() { }} /> - - - Forgot Password? - { setUser({ diff --git a/src/Routes/UserInfo/UserInfo.tsx b/src/Routes/UserInfo/UserInfo.tsx index 54a42fe..9b605ec 100644 --- a/src/Routes/UserInfo/UserInfo.tsx +++ b/src/Routes/UserInfo/UserInfo.tsx @@ -1,26 +1,26 @@ -import * as React from 'react'; -import {View, Text} from 'react-native'; -import styles from '../../styles'; -import Background from '../../Components/Background/Background'; -import { SafeAreaView } from 'react-native-safe-area-context'; -import { UserInfo } from '../../Components/Api/Api'; -import { useQuery } from 'react-query'; -import { useSelector } from 'react-redux'; -import { RootState } from '../../Features/Redux/Store/Store'; +import * as React from "react"; +import { View, Text } from "react-native"; +import styles from "../../styles"; +import Background from "../../Components/Background/Background"; +import { SafeAreaView } from "react-native-safe-area-context"; +import { UserInfo } from "../../Components/Api/Api"; +import { useQuery } from "react-query"; +import { useSelector } from "react-redux"; +import { RootState } from "../../Features/Redux/Store/Store"; export default function UserPage() { - const { data, isLoading, error } = useQuery("user", UserInfo, { retry: 0, onSuccess: (data) => console.log(data) }); - const logged_in = useSelector( - (state: RootState) => state.logged_in.value - ); - const logged_in_user = useSelector( - (state: RootState) => state.logged_in_user.value - ); + 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 ( - Loading... + + Loading... + ); @@ -28,7 +28,9 @@ export default function UserPage() { return ( - An error has occured + + An error has occured + ); @@ -36,16 +38,16 @@ export default function UserPage() { return ( - - - - Username: {logged_in_user.username} - Email: {logged_in_user.email} - User ID: {logged_in_user.id} - - - + + Username: {data.username} + + + Email: {data.email} + + + User ID: {data.id} + ); -} \ No newline at end of file +}