Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed nav oops sorry #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default function App() {
</Link>
<Link href="/screens/plant/plant" style={{ color: "blue" }}>
Go to Plants
</Link>
<Link href="/screens/events" style={{ color: "blue" }}>
Go to Events Page
</Link>
Expand Down
4 changes: 2 additions & 2 deletions app/screens/discover/discover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function DiscoverPage () {
<Pressable
key={index}
style={styles.eventBox}
onPress={() => navigation.navigate('screens/program_page/event_page',
onPress={() => navigation.navigate('EventPage',
{
title: event.name,
date: event.date,
Expand Down Expand Up @@ -115,7 +115,7 @@ export default function DiscoverPage () {
<Pressable
style={styles.programContainer}
key={index}
onPress={() => navigation.navigate('screens/program_page/program_page')}
onPress={() => navigation.navigate('ProgramPage')}
>
<Image source={defaultPic} style={styles.programImage}/>
<Text>{program.description}</Text>
Expand Down
64 changes: 37 additions & 27 deletions app/screens/homepage/homepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,45 @@ export default function Homepage() {

const [loading, setLoading] = useState(true);
let level_img = sample_logo;
const tempUserId = '6789f49f8e0a009647312c7a';
const tempEventId = '67932a72413f4d68be84e592';

useEffect(() => {
const fetchUserData = async () => {
try {
// fetching user data here
const userResponse = await axios.get('http://localhost:4000/api/users/6789f49f8e0a009647312c7a');
const testResponse = await axios.get('http://localhost:4000/api/events/678f315b8d423da67c615e95');
setTestEvent(testResponse)
if (userResponse.status === 200) {
setUserData(userResponse.data);
// fetching events for the user's attendingEvents
setUserAttendingEvents(userResponse.data.attendingEvents)
console.log(userAttendingEvents)
// const attendingEvents = userData.attendingEvents.map((eventId) => axios.get(`http://localhost:4000/api/events/${eventId}`));
// const attendingEventsResponse = await Promise.all(attendingEvents)
// const events_attending = attendingEventsResponse.map((response) => response.data);
// setUserAttendingEvents(events_attending)
useEffect(() => {
const fetchUserData = async () => {
try {
// fetching user data here
const userResponse = await axios.get(`http://localhost:4000/api/users/${tempUserId}`);
const testResponse = await axios.get(`http://localhost:4000/api/events/${tempEventId}`);
setTestEvent(testResponse.data);

if (userResponse.status === 200) {
const fetchedUser = userResponse.data;
setUserData(fetchedUser);

if (Array.isArray(fetchedUser.attendingEvents)) {
const attendingEventsRequests = fetchedUser.attendingEvents.map((eventId) =>
axios.get(`http://localhost:4000/api/events/${eventId}`)
);
const attendingEventsResponse = await Promise.all(attendingEventsRequests);
const events_attending = attendingEventsResponse.map((response) => response.data);
setUserAttendingEvents(events_attending);
} else {
console.error('Failed to fetch user: ', response.data.error);
console.warn("No attending events found for the user");
setUserAttendingEvents([]);
}
} catch (error) {
console.error('Error fetching user or events: ', error.message);
} finally {
setLoading(false);
} else {
console.error('Failed to fetch user: ', userResponse.data.error);
}
};

fetchUserData();
}, []);
} catch (error) {
console.error('Error fetching user or events: ', error.message);
} finally {
setLoading(false);
}
};

fetchUserData();
}, []);


if (userData && userData.tamagatchiXP !== undefined) {
if (userData.tamagatchiXP < 1000) {
Expand All @@ -60,14 +70,14 @@ export default function Homepage() {

return (
<ScrollView style={styles.main_container}>
{/* <Text style = {styles.title}> Your Teapot Garden </Text>
<Text style = {styles.title}> Your Teapot Garden </Text>
<Placeholder imageSource={level_img} />
<Text style = {styles.subtitle}> Upcoming Events </Text>
<View style={styles.events_container}>
{userAttendingEvents.map((event, index) => (
<EventCard key={index} title={event.title} time={event.time} date={event.date} location={event.location} image={event.image} />
))}
</View> */}
</View>
</ScrollView>
);
}
Expand Down
4 changes: 2 additions & 2 deletions app/screens/plant/plant.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { SafeAreaView, StatusBar } from 'react-native';
import PlantSelector from './PlantSelector_comp.js';

const plant = () => {
const Plant = () => {
return (
<SafeAreaView style={{ flex: 1 }}>
<StatusBar barStyle="dark-content" />
Expand All @@ -11,4 +11,4 @@ const plant = () => {
);
};

export default plant;
export default Plant;
12 changes: 10 additions & 2 deletions app/src/components/hamburgermenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { View, Text, StyleSheet, TouchableOpacity, Image } from "react-native";
import { createDrawerNavigator, DrawerContentScrollView, DrawerItem } from "@react-navigation/drawer";
import Homepage from "@screens/homepage/homepage";
import DiscoverPage from "@screens/discover/discover";
import Profile from "@screens/profile/profile";
import Profile from "@screens/profile/profile_page";
import Plant from "@screens/plant/plant";
import Index from "@app/index";

import EventPage from "@screens/event/event_page";
import ProgramPage from "@screens/program_page/program_page";

import notificationIcon from "@assets/notifications.png";
import menuIcon from "@assets/menu.png";
import tempIcon from "@assets/tempicon.png";
Expand All @@ -24,7 +29,7 @@ const CustomDrawerContent = (props) => {

<View style={styles.drawerItemsContainer}>
{["Home", "View Plant", "My Events", "Discover"].map((screen, index) => {
const routeName = (screen === "View Plant" || screen === "My Events") ? "Temp" : screen;
const routeName = (screen === "My Events") ? "Temp" : screen;
const isActive = props.state.routes[props.state.index].name === routeName;

return (
Expand Down Expand Up @@ -87,7 +92,10 @@ const HamburgerMenu = () => {
<Drawer.Screen name="Home" component={Homepage} />
<Drawer.Screen name="Discover" component={DiscoverPage} />
<Drawer.Screen name="Profile" component={Profile} />
<Drawer.Screen name="View Plant" component={Plant} />
<Drawer.Screen name="Temp" component={Index} />
<Drawer.Screen name="EventPage" component={EventPage} />
<Drawer.Screen name="ProgramPage" component={ProgramPage} />
</Drawer.Navigator>
);
};
Expand Down
Loading