send user data to userprofile
This commit is contained in:
parent
4019b40b33
commit
ad5b542ae5
6
App.js
6
App.js
|
@ -27,6 +27,7 @@ import RegisterUserScreen from './components/RegisterUserScreen';
|
||||||
import LoginUserScreen from './components/LoginUserScreen.js';
|
import LoginUserScreen from './components/LoginUserScreen.js';
|
||||||
import SearchHouse from './components/SearchHouse.js';
|
import SearchHouse from './components/SearchHouse.js';
|
||||||
import HouseProfile from './components/HouseProfile.js';
|
import HouseProfile from './components/HouseProfile.js';
|
||||||
|
import UserProfile from './components/UserProfile.js';
|
||||||
|
|
||||||
const Section = ({children, title}): Node => {
|
const Section = ({children, title}): Node => {
|
||||||
const isDarkMode = useColorScheme() === 'dark';
|
const isDarkMode = useColorScheme() === 'dark';
|
||||||
|
@ -92,6 +93,11 @@ const App = () => {
|
||||||
component={HouseProfile}
|
component={HouseProfile}
|
||||||
options={{headerShown: false}}
|
options={{headerShown: false}}
|
||||||
/>
|
/>
|
||||||
|
<Stack.Screen
|
||||||
|
name="UserProfile"
|
||||||
|
component={UserProfile}
|
||||||
|
options={{headerShown: false}}
|
||||||
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
);
|
);
|
||||||
|
|
|
@ -65,6 +65,7 @@ const LoginUserScreen = ({navigation}) => {
|
||||||
setToken(response_data.token);
|
setToken(response_data.token);
|
||||||
var userobj = JSON.parse(response_data.user);
|
var userobj = JSON.parse(response_data.user);
|
||||||
setMessage('user ' + userobj.username + ' logged in');
|
setMessage('user ' + userobj.username + ' logged in');
|
||||||
|
navigation.navigate('UserProfile', {user: userobj});
|
||||||
} else {
|
} else {
|
||||||
setMessage(response_data.msg);
|
setMessage(response_data.msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,12 +55,16 @@ const homes = [
|
||||||
id: 5,
|
id: 5,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const UserProfile = ({navigation}) => {
|
const UserProfile = props => {
|
||||||
const [search, setSearch] = React.useState('');;
|
const [search, setSearch] = React.useState('');
|
||||||
const [loading, setLoading] = React.useState(false);;
|
const [loading, setLoading] = React.useState(false);
|
||||||
const [searchData, setSearchData] = React.useState([]);;
|
const [searchData, setSearchData] = React.useState([]);
|
||||||
const [tempSearchData, setTempSearchData] = React.useState([]);;
|
const [tempSearchData, setTempSearchData] = React.useState([]);
|
||||||
const [error, setError] = React.useState(null);;
|
const [userProfile, setUserProfile] = React.useState({});
|
||||||
|
const [error, setError] = React.useState(null);
|
||||||
|
useEffect(() => {
|
||||||
|
setUserProfile(props.route.params.user);
|
||||||
|
}, []);
|
||||||
const renderHeader = () => {
|
const renderHeader = () => {
|
||||||
return (
|
return (
|
||||||
<SearchBar
|
<SearchBar
|
||||||
|
@ -98,13 +102,13 @@ const UserProfile = ({navigation}) => {
|
||||||
<View style={styles.viewRoot}>
|
<View style={styles.viewRoot}>
|
||||||
<View style={styles.iconContainer}>
|
<View style={styles.iconContainer}>
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
onPress={() => navigation.goBack()}
|
onPress={() => props.navigation.goBack()}
|
||||||
underlayColor="white"
|
underlayColor="white"
|
||||||
activeOpacity={0.5}>
|
activeOpacity={0.5}>
|
||||||
<Icon name="arrow-back" type="ionicon" size={36} color="#206ba5" />
|
<Icon name="arrow-back" type="ionicon" size={36} color="#206ba5" />
|
||||||
</TouchableHighlight>
|
</TouchableHighlight>
|
||||||
<TouchableHighlight
|
<TouchableHighlight
|
||||||
onPress={() => navigation.goBack()}
|
onPress={() => props.navigation.goBack()}
|
||||||
underlayColor="white"
|
underlayColor="white"
|
||||||
activeOpacity={0.5}>
|
activeOpacity={0.5}>
|
||||||
<Icon
|
<Icon
|
||||||
|
@ -116,14 +120,21 @@ const UserProfile = ({navigation}) => {
|
||||||
</TouchableHighlight>
|
</TouchableHighlight>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.headingContainer}>
|
<View style={styles.headingContainer}>
|
||||||
<Text style={styles.heading}>John Doe</Text>
|
<Text style={styles.heading}>
|
||||||
|
{userProfile.username ? userProfile.username : 'John Doe'}
|
||||||
|
</Text>
|
||||||
<Text style={styles.subHeading}>Tenant</Text>
|
<Text style={styles.subHeading}>Tenant</Text>
|
||||||
|
|
||||||
<View style={{flexDirection: 'row', marginTop: 30}}>
|
<View style={{flexDirection: 'row', marginTop: 30}}>
|
||||||
<Icon name="card-outline" type="ionicon" size={36} color="brown" />
|
<Icon name="card-outline" type="ionicon" size={36} color="brown" />
|
||||||
<Text style={[styles.pricingHeading]}>Basic Member</Text>
|
<Text style={[styles.pricingHeading]}>Basic Member</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={{flexDirection: 'row', marginTop: 30,justifyContent: "space-evenly"}}>
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: 'row',
|
||||||
|
marginTop: 30,
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
}}>
|
||||||
<View style={styles.twoColContainer}>
|
<View style={styles.twoColContainer}>
|
||||||
<Text style={[styles.twoColHeading]}>Past Houses</Text>
|
<Text style={[styles.twoColHeading]}>Past Houses</Text>
|
||||||
<Text style={[styles.twoColNumber]}>3</Text>
|
<Text style={[styles.twoColNumber]}>3</Text>
|
||||||
|
@ -139,7 +150,7 @@ const UserProfile = ({navigation}) => {
|
||||||
{/* <Card /> */}
|
{/* <Card /> */}
|
||||||
|
|
||||||
<Text style={styles.cardHeading}>Current House</Text>
|
<Text style={styles.cardHeading}>Current House</Text>
|
||||||
<HouseCard info={homes[1]} />
|
<HouseCard info={homes[1]} />
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
|
@ -176,8 +187,8 @@ const styles = StyleSheet.create({
|
||||||
fontFamily: 'Ubuntu-Bold',
|
fontFamily: 'Ubuntu-Bold',
|
||||||
},
|
},
|
||||||
cardHeading: {
|
cardHeading: {
|
||||||
marginLeft:20,
|
marginLeft: 20,
|
||||||
marginTop:50,
|
marginTop: 50,
|
||||||
color: '#1C254E',
|
color: '#1C254E',
|
||||||
fontSize: 30,
|
fontSize: 30,
|
||||||
textAlign: 'left',
|
textAlign: 'left',
|
||||||
|
@ -204,7 +215,7 @@ const styles = StyleSheet.create({
|
||||||
twoColContainer: {
|
twoColContainer: {
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginLeft: -40,
|
marginLeft: -40,
|
||||||
},
|
},
|
||||||
twoColHeading: {
|
twoColHeading: {
|
||||||
color: '#1C254E',
|
color: '#1C254E',
|
||||||
|
@ -226,7 +237,7 @@ const styles = StyleSheet.create({
|
||||||
// justifyContent: 'center',
|
// justifyContent: 'center',
|
||||||
},
|
},
|
||||||
verticalLine: {
|
verticalLine: {
|
||||||
marginLeft: -40,
|
marginLeft: -40,
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: 5,
|
width: 5,
|
||||||
backgroundColor: '#206ba5',
|
backgroundColor: '#206ba5',
|
||||||
|
|
Loading…
Reference in New Issue