diff --git a/backend/controllers/clubsController.js b/backend/controllers/clubsController.js index 07dc68b..a1fd9ad 100644 --- a/backend/controllers/clubsController.js +++ b/backend/controllers/clubsController.js @@ -1,3 +1,4 @@ +import supabaseConnection from '../database.js'; import clubs from '../models/clubs.js'; const clubsController = { @@ -61,5 +62,19 @@ const clubsController = { res.status(500).json({ message: 'Internal Server Error' }); } }, + + getEventsClub: async (req, res) => { + try { + const clubId = req.params?.id; + if (!clubId) { + return res.status(400).json({ message: 'Club ID is required' }); + } + const events = await supabaseConnection.from('events').select('*').eq('hostClubId', clubId); + res.status(200).json(events) + } catch (error) { + console.error('Error updating club info:', error); + res.status(500).json({ message: 'Internal Server Error' }); + } + } }; -export default clubsController; +export default clubsController; \ No newline at end of file diff --git a/backend/routes/clubsRouter.js b/backend/routes/clubsRouter.js index ba681b3..1cd7109 100644 --- a/backend/routes/clubsRouter.js +++ b/backend/routes/clubsRouter.js @@ -6,6 +6,11 @@ const router = Router(); router.get('/', clubsController.getAllClubs); router.get('/me/:id', clubsController.getClubByAccountId); router.get('/:id', clubsController.getClubById); +<<<<<<< Updated upstream router.patch('/:id', clubsController.updateClub); +======= +router.patch(':id', clubsController.updateClub); +router.get('/:id/events', clubsController.getEventsClub); +>>>>>>> Stashed changes export default router; diff --git a/frontend/app/dashboard/index.tsx b/frontend/app/dashboard/index.tsx new file mode 100644 index 0000000..4ffdddb --- /dev/null +++ b/frontend/app/dashboard/index.tsx @@ -0,0 +1,13 @@ +import { useState, useEffect } from "react"; +import { FlatList, Text, View } from "react-native"; +import { useAuth } from "@/context"; +import ClubDashboardEventsList from "../../components/club/dashboard/ClubDashboardEventsList"; +export default function Dashboard() { + + return ( + + + + ); + +} \ No newline at end of file diff --git a/frontend/app/index.tsx b/frontend/app/index.tsx index e32ca9f..0eb2457 100644 --- a/frontend/app/index.tsx +++ b/frontend/app/index.tsx @@ -1,35 +1,26 @@ import { Text, View } from "react-native"; -import { useState, useEffect } from "react"; -import { supabase } from "../lib/supabase"; -import { Session } from "@supabase/supabase-js"; +import { SafeAreaView } from "react-native-safe-area-context"; +// import Feed from "../components/feed/feed.js"; import { useAuth } from "../context/AuthContext"; import Feed from "../components/feed/feed.js" import { SafeAreaView } from "react-native-safe-area-context"; - export default function Index() { const { session, accountType } = useAuth(); return ( - - + + {session && session.user ? ( - + <> Welcome, {session.user.email}! - + Account Type: {accountType === 'club' ? 'Club Account' : 'User Account'} - - - + + ) : ( Please log in or sign up. @@ -37,6 +28,5 @@ export default function Index() { )} - ); -} \ No newline at end of file +} diff --git a/frontend/components/club/dashboard/ClubDashboardEventCard.js b/frontend/components/club/dashboard/ClubDashboardEventCard.js new file mode 100644 index 0000000..90195d8 --- /dev/null +++ b/frontend/components/club/dashboard/ClubDashboardEventCard.js @@ -0,0 +1,73 @@ +import {Button, Text, TouchableHighlight, View, StyleSheet} from "react-native"; + +export function ClubDashboardEventCard({ data }) { + const { id, title, description, startTimestamp, endTimestamp} = data; + + const handleEdit = (e) => { + console.log("trying to edit event:" + id); + } + + return ( + + + + {title} + + {description} + + {formatTimestamp(startTimestamp)} - {formatTimestamp(endTimestamp)} + + + + Edit + + + ); +} + +function formatTimestamp(ts) { + const date = new Date(ts); + return date.toLocaleString(); +} + +const styles = StyleSheet.create({ + container: { + padding: 12, + borderRadius: 10, + backgroundColor: '#fff', + marginVertical: 6, + marginHorizontal: 12, + shadowColor: '#000', + shadowOpacity: 0.1, + shadowRadius: 4, + elevation: 2, + alignSelf: 'stretch', + }, + headerContainer: { + flex: 1, + flexDirection: "row", + flexWrap: 'wrap', + gap: 10, + alignItems: 'center', + marginBottom: 4, + + fontSize: 30, + }, + title: { + fontWeight: 'bold', + fontSize: 20 + }, + subtitle: { + fontWeight: 'bold', + color: 'grey' + }, + description: { + fontSize: 14, + color: '#444', + marginBottom: 6, + }, + timestamp: { + fontSize: 12, + color: '#888', + }, +}); \ No newline at end of file diff --git a/frontend/components/club/dashboard/ClubDashboardEventsList.js b/frontend/components/club/dashboard/ClubDashboardEventsList.js new file mode 100644 index 0000000..022caa5 --- /dev/null +++ b/frontend/components/club/dashboard/ClubDashboardEventsList.js @@ -0,0 +1,39 @@ +import { useEffect, useState } from "react"; +import { View, Text, FlatList} from "react-native"; +import {ClubDashboardEventCard} from "./ClubDashboardEventCard"; + +//TODO: make it so this page is ONLY accessible to the account that's logged in. +export default function ClubDashboardEventsList({clubId}) { + + const [eventData, setEventData] = useState([]); + + const fetchEventData = async () => { + const res = await fetch(`http://localhost:3000/api/clubs/${clubId}/events`); + if(res.ok) { + const body = await res.json(); + setEventData(body.data); + } + } + + useEffect(() => { + fetchEventData(); + }, []); + + const renderListItem = ({item}) => { + return ( + + ); + } + + return ( + Getting events... + } + renderItem={renderListItem} + /> + ); +} \ No newline at end of file