diff --git a/apps/web-client/src/components/Sidebar.jsx b/apps/web-client/src/components/Sidebar.jsx index c3a49408..807d66b4 100644 --- a/apps/web-client/src/components/Sidebar.jsx +++ b/apps/web-client/src/components/Sidebar.jsx @@ -9,11 +9,17 @@ import { AccordionItem, AccordionTrigger, } from '@/components/ui/accordion'; +import { logoutService } from '@/services/authenticationService'; const Sidebar = ({ className }) => { const router = useRouter(); const { organizationId } = router.query; + const handleLogout = async () => { + await logoutService(); + router.push('/login'); + }; + return (
@@ -21,7 +27,7 @@ const Sidebar = ({ className }) => {

Quick Access

+
diff --git a/apps/web-client/src/components/cards/EventCard.jsx b/apps/web-client/src/components/cards/EventCard.jsx index b7ed627d..c4f94fc7 100644 --- a/apps/web-client/src/components/cards/EventCard.jsx +++ b/apps/web-client/src/components/cards/EventCard.jsx @@ -18,7 +18,7 @@ const EventCard = ({ event }) => { { - router.push(`/dashboard/${event.organizationId}/${event.id}`); + router.push(`/organizations/${event.organizationId}/events/${event.id}`); }} > diff --git a/apps/web-client/src/components/cards/OrganizationCard.jsx b/apps/web-client/src/components/cards/OrganizationCard.jsx index cd7f2f93..c0e96d48 100644 --- a/apps/web-client/src/components/cards/OrganizationCard.jsx +++ b/apps/web-client/src/components/cards/OrganizationCard.jsx @@ -15,7 +15,7 @@ const OrganizationCard = ({ organization }) => { const router = useRouter(); return ( - router.push(`/dashboard/${organization?.id}`)}> + router.push(`/organizations/${organization?.id}`)}> {organization?.name} diff --git a/apps/web-client/src/components/cards/ParticipantCard.jsx b/apps/web-client/src/components/cards/ParticipantCard.jsx index 7635d1d3..49c57d8d 100644 --- a/apps/web-client/src/components/cards/ParticipantCard.jsx +++ b/apps/web-client/src/components/cards/ParticipantCard.jsx @@ -28,7 +28,7 @@ const ParticipantCard = ({ participant }) => { className="w-72" onClick={() => { router.push( - `/dashboard/${participant.organizationId}/${participant.eventId}/participants/${participant.id}`, + `/organizations/${participant.organizationId}/${participant.eventId}/participants/${participant.id}`, ); }} > diff --git a/apps/web-client/src/pages/index.jsx b/apps/web-client/src/pages/index.jsx index 72e27e62..0a5e09b2 100644 --- a/apps/web-client/src/pages/index.jsx +++ b/apps/web-client/src/pages/index.jsx @@ -6,8 +6,8 @@ const Home = () => { const router = useRouter(); useEffect(() => { - router.replace('/dashboard'); - }, []); + router.replace('/organizations'); + }, [router]); return (
diff --git a/apps/web-client/src/pages/login/index.jsx b/apps/web-client/src/pages/login/index.jsx index 5d5dd8da..db8a13bf 100644 --- a/apps/web-client/src/pages/login/index.jsx +++ b/apps/web-client/src/pages/login/index.jsx @@ -13,7 +13,7 @@ export default function Login() { const handleSubmit = async (e) => { e.preventDefault(); - if (await loginService({ email, password })) router.push('/dashboard'); + if (await loginService({ email, password })) router.push('/organizations'); else console.error('Error when logging in'); }; diff --git a/apps/web-client/src/pages/dashboard/[organizationId]/[eventId]/index.jsx b/apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/index.jsx similarity index 78% rename from apps/web-client/src/pages/dashboard/[organizationId]/[eventId]/index.jsx rename to apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/index.jsx index 31b321ce..cb2fc4c1 100644 --- a/apps/web-client/src/pages/dashboard/[organizationId]/[eventId]/index.jsx +++ b/apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/index.jsx @@ -9,8 +9,8 @@ const Home = () => { useEffect(() => { if (!organizationId || !eventId) return; - router.replace(`/dashboard/${organizationId}/${eventId}/participants`); - }, [organizationId, eventId]); + router.replace(`/organizations/${organizationId}/events/${eventId}/participants`); + }, [router, organizationId, eventId]); return (
diff --git a/apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/participants/index.jsx b/apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/participants/index.jsx new file mode 100644 index 00000000..1c5ef028 --- /dev/null +++ b/apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/participants/index.jsx @@ -0,0 +1,68 @@ +import React, { useEffect, useState } from 'react'; +import { useRouter } from 'next/router'; + +import DashboardLayout from '@/layouts/DashboardLayout'; +import EventCard from '@/components/cards/EventCard'; + +import { Skeleton } from '@/components/ui/skeleton'; +import { PlusCircledIcon } from '@radix-ui/react-icons'; +import { Button } from '@/components/ui/button'; +import axiosInstance from '@/lib/axios'; + +const Dashboard = () => { + const router = useRouter(); + const { organizationId, eventId } = router.query; + + const [loading, setLoading] = useState(true); + const [participants, setParticipants] = useState([]); + + const fetchParticipants = async () => { + try { + const { data, status } = await axiosInstance.get( + `/core/${organizationId}/events/${eventId}/participants`, + ); + + if (status === 200) setParticipants(data.participants || []); + + setLoading(false); + } catch (error) { + console.error(error); + setLoading(true); + } + }; + + useEffect(() => { + if (!organizationId || !eventId) return; + fetchParticipants(); + }, [router, organizationId, eventId]); + + return ( + +
+ +
+
+ {loading && ( + <> + + + + + + )} + {participants.map((p) => ( +
{JSON.stringify(p)}
+ ))} +
+
+ ); +}; + +export default Dashboard; diff --git a/apps/web-client/src/pages/dashboard/[organizationId]/[eventId]/scan/index.jsx b/apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/scan/index.jsx similarity index 100% rename from apps/web-client/src/pages/dashboard/[organizationId]/[eventId]/scan/index.jsx rename to apps/web-client/src/pages/organizations/[organizationId]/events/[eventId]/scan/index.jsx diff --git a/apps/web-client/src/pages/dashboard/[organizationId]/index.jsx b/apps/web-client/src/pages/organizations/[organizationId]/events/index.jsx similarity index 73% rename from apps/web-client/src/pages/dashboard/[organizationId]/index.jsx rename to apps/web-client/src/pages/organizations/[organizationId]/events/index.jsx index f45bcaf8..6b999441 100644 --- a/apps/web-client/src/pages/dashboard/[organizationId]/index.jsx +++ b/apps/web-client/src/pages/organizations/[organizationId]/events/index.jsx @@ -1,13 +1,13 @@ import React, { useEffect, useState } from 'react'; import { useRouter } from 'next/router'; -import DashboardLayout from '../../../layouts/DashboardLayout'; +import DashboardLayout from '../../../../layouts/DashboardLayout'; import EventCard from '@/components/cards/EventCard'; import { Skeleton } from '@/components/ui/skeleton'; -import { fetchAllEvents } from '@/services/eventService'; import { PlusCircledIcon } from '@radix-ui/react-icons'; import { Button } from '@/components/ui/button'; +import axiosInstance from '@/lib/axios'; const Dashboard = () => { const router = useRouter(); @@ -16,28 +16,29 @@ const Dashboard = () => { const [loading, setLoading] = useState(true); const [events, setEvents] = useState([]); - const fetchEvents = async () => { - try { - const r = await fetchAllEvents({ organizationId }); - setEvents(r || []); - setLoading(false); - } catch (error) { - console.error(error); - setLoading(true); - } - }; - useEffect(() => { if (!organizationId) return; + const fetchEvents = async () => { + try { + const { data, status } = await axiosInstance.get(`core/${organizationId}/events`); + + if (status === 200) setEvents(data.events || []); + + setLoading(false); + } catch (error) { + console.error(error); + setLoading(true); + } + }; fetchEvents(); - }, [organizationId]); + }, [router, organizationId]); return (
+
diff --git a/apps/web-client/src/pages/organizations/[organizationId]/index.jsx b/apps/web-client/src/pages/organizations/[organizationId]/index.jsx new file mode 100644 index 00000000..14fa6cc0 --- /dev/null +++ b/apps/web-client/src/pages/organizations/[organizationId]/index.jsx @@ -0,0 +1,24 @@ +import DashboardLayout from '@/layouts/DashboardLayout'; +import { useRouter } from 'next/router'; +import { useEffect } from 'react'; + +const Home = () => { + const router = useRouter(); + + const { organizationId } = router.query; + + useEffect(() => { + if (!organizationId) return; + router.replace(`/organizations/${organizationId}/events`); + }, [router, organizationId]); + + return ( +
+ +

Please wait ...

+
+
+ ); +}; + +export default Home; diff --git a/apps/web-client/src/pages/dashboard/index.jsx b/apps/web-client/src/pages/organizations/index.jsx similarity index 89% rename from apps/web-client/src/pages/dashboard/index.jsx rename to apps/web-client/src/pages/organizations/index.jsx index 4fa1d5b6..89e3a23a 100644 --- a/apps/web-client/src/pages/dashboard/index.jsx +++ b/apps/web-client/src/pages/organizations/index.jsx @@ -16,8 +16,6 @@ import { } from '@/components/ui/table'; import { Button } from '@/components/ui/button'; -import OrganizationCard from '@/components/cards/OrganizationCard'; -import { fetchAllOrganizations } from '@/services/organizationService'; import { useRouter } from 'next/router'; const Dashboard = () => { @@ -28,9 +26,8 @@ const Dashboard = () => { const fetchOrganizations = async () => { try { - const r = await fetchAllOrganizations(); - console.log(r); - setOrganizations(r || []); + const { data, status } = await axiosInstance.get('/users/organizations'); + if (status === 200) setOrganizations(data.organizations || []); setLoading(false); } catch (error) { console.error(error); @@ -70,7 +67,7 @@ const Dashboard = () => {