Skip to content

Commit

Permalink
explore
Browse files Browse the repository at this point in the history
  • Loading branch information
incredible-phoenix246 committed Feb 25, 2024
1 parent 678aa17 commit eca3021
Show file tree
Hide file tree
Showing 23 changed files with 1,477 additions and 111 deletions.
564 changes: 564 additions & 0 deletions v2/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-slot": "^1.0.2",
"axios": "^1.6.7",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"date-fns": "^3.3.1",
"iconsax-react": "^0.0.8",
"jwt-decode": "^4.0.0",
"lucide-react": "^0.335.0",
"next": "14.1.0",
"next-auth": "^5.0.0-beta.13",
"prettier": "^3.2.5",
"react": "^18",
"react-day-picker": "^8.10.0",
"react-dom": "^18",
"react-hook-form": "^7.50.1",
"react-icons": "^5.0.1",
Expand Down
27 changes: 27 additions & 0 deletions v2/public/arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions v2/src/actions/expore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
'use server';

import Calls from './calls';

const BaseUrl = process.env.BASEURL ?? 'https://evento-qo6d.onrender.com/api/v1';

const $http = Calls(BaseUrl);

export const allevent = async () => {
try {
const res = await $http.get('/events');
if (res.status === 200) {
return {
status: 'success',
events: res.data.data,
};
}
} catch (e: any) {
console.log(e);
if (e?.response?.status === 403) {
return {
error: 'Forbidden',
};
} else if (e?.response?.status === 404) {
return {
error: 'Not Found. The requested endpoint was not found.',
};
} else {
return {
error: 'An error occurred. Please try again later.',
};
}
}
};

export const allcategories = async () => {
try {
const res = await $http.get('/categories');
if (res.status === 200) {
return {
status: 'success',
categories: res.data.data,
};
}
} catch (e: any) {
console.log(e);
if (e?.response?.status === 403) {
return {
error: 'Forbidden',
};
} else if (e?.response?.status === 404) {
return {
error: 'Not Found. The requested endpoint was not found.',
};
} else {
return {
error: 'An error occurred. Please try again later.',
};
}
}
};

export const geteventsbycategories = async (categoryID: string) => {
try {
const res = await $http.get(`/categories/${categoryID}/events`);
if (res.status === 200) {
return {
status: 'success',
events: res.data.data,
};
}
} catch (e: any) {
console.log(e);
if (e?.response?.status === 403) {
return {
error: 'Forbidden',
};
} else if (e?.response?.status === 404) {
return {
error: 'Not Found. The requested endpoint was not found.',
};
} else {
return {
error: 'An error occurred. Please try again later.',
};
}
}
};
48 changes: 48 additions & 0 deletions v2/src/actions/notifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use server';

import Calls from './calls';
import { cookies } from 'next/headers';

const BaseUrl = process.env.BASEURL ?? 'https://evento-qo6d.onrender.com/api/v1';

const $http = Calls(BaseUrl, true);

export const getNotifications = async () => {
const userId = cookies()?.get('userId')?.value;

if (!userId) {
return {
error: 'Unauthorized. Missing access token.',
status: 401,
};
}
try {
const res = await $http.get(`/notifications/${userId}`);
if (res.status === 200) {
return {
status: 'success',
notifications: res.data.data,
};
}
} catch (e: any) {
console.log(e);
if (e?.response?.status === 401) {
return {
error: 'Unauthorized. Please check your access token.',
status: 401,
};
} else if (e?.response?.status === 403) {
return {
error: 'Forbidden',
};
} else if (e?.response?.status === 404) {
return {
error: 'Not Found. The requested endpoint was not found.',
};
} else {
return {
error: 'An error occurred. Please try again later.',
};
}
}
};
16 changes: 16 additions & 0 deletions v2/src/app/(home)/explore/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import Hero from '@/modules/explore/Hero';
import Categories from '@/modules/explore/Categories';
import EventsGrid from '@/modules/explore/EventsGrid';

const Explore = () => {
return (
<>
<Hero />
<Categories />
<EventsGrid />
</>
);
};

export default Explore;
11 changes: 7 additions & 4 deletions v2/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Theme from '@/components/ThemeButton';
import StateCtxProvider from '@/context/StateCtx';
import { SessionProvider } from 'next-auth/react';
import UserContextProvider from '@/context/UserCtx';
import ExploreContextProvider from '@/context/ExploreCtx';

export const metadata: Metadata = {
title: 'Evento',
Expand All @@ -27,10 +28,12 @@ export default function RootLayout({
<SessionProvider>
<UserContextProvider>
<StateCtxProvider>
<AuthContextProvider>
{children}
<Theme />
</AuthContextProvider>
<ExploreContextProvider>
<AuthContextProvider>
{children}
<Theme />
</AuthContextProvider>
</ExploreContextProvider>
</StateCtxProvider>
</UserContextProvider>
</SessionProvider>
Expand Down
104 changes: 104 additions & 0 deletions v2/src/components/Cards/ExploreCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
'use client';

import Link from 'next/link';
import Image from 'next/image';
import React, { useState } from 'react';
import { EventProps } from '@/types';
import { useUserCtx } from '@/context/UserCtx';
import { Location, Timer1 } from 'iconsax-react';
import { convertUTCtoLocalTime } from '@/utils';
import { useExploreCtx } from '@/context/ExploreCtx';

const ExploreCard = ({
imageURL,
eventID,
startDate,
organizerID,
tickets,
participants,
location,
title,
}: EventProps) => {
const [weekday, monthDay] = convertUTCtoLocalTime(startDate!);
const [, , , time] = convertUTCtoLocalTime(startDate!);
const { eventsSearchTerm } = useExploreCtx();
const { user } = useUserCtx();

return (
<>
<Link
href={organizerID === user.userID ? `/event-management/?eventid=${eventID}` : `/event/?eventid=${eventID}`}
className="block border border-Grey-G80/50 dark:border-dark-two card-shadow rounded-lg hover:scale-[1.01]"
>
<div className="relative w-full h-[180px] rounded-t-lg overflow-hidden">
<Image src={imageURL!} fill alt="Event Image" className="object-cover" />
</div>
<div className="p-4">
<div className="flex justify-between items-center mb-1 font-nunito">
<span className="font-bold text-sm text-primary-100 dark:text-dark-two ">
{weekday}, {monthDay}
</span>
{tickets?.map((ticket) => (
<div key={ticket.ticketID}>
<span className="text-primary-100 bg-secondary-100 dark:bg-dark-two dark:text-dark-one rounded block px-3 py-1 capitalize">
{ticket.ticketType === 'Free' ? 'Free' : `$${ticket.ticketPrice}`}
</span>
</div>
))}
</div>
<h2 className="text-Grey-G800 dark:text-dark-two text-lg whitespace-nowrap overflow-hidden text-ellipsis sm:text-xl font-bold pt-1 pb-2 font-montserrat">
{/* {title!} */}
<strong>
<span
dangerouslySetInnerHTML={{
__html: title!.replace(
new RegExp(`(${eventsSearchTerm})`, 'gi'),
(match, group) =>
`<span style="color: black; background-color: ${
group.toLowerCase() === eventsSearchTerm.toLowerCase() ? 'yellow' : 'inherit'
}">${match}</span>`,
),
}}
/>
</strong>
</h2>
<p className="text-Grey-G500 dark:text-dark-two text-sm flex items-center gap-0.5 mb-1 font-nunito">
<Location size={16} />
<span className="font-medium">{location!}</span>
</p>
<p className="text-Grey-G500 dark:text-dark-two flex items-center gap-0.5 mb-2 font-nunito">
<Timer1 size={16} />
<span className="font-medium">{time}</span>
</p>
<div className="flex items-center font-montserrat">
{participants?.length !== 0 && (
<div className="flex items-center">
{participants?.map((item, index) => {
if (index >= 3) return;
return (
<div key={index} className="h-8 w-8 first:ml-0 -ml-1.5 rounded-full overflow-hidden">
<Image
src={item?.profileImage ?? '/assets/avatar.png'}
height={32}
width={32}
alt="Attendant"
className="object-top object-cover"
/>
</div>
);
})}
{participants && participants?.length > 3 && (
<span className="pl-3 text-sm font-medium font-nunito">
+{participants?.length - 3} People registered
</span>
)}
</div>
)}
</div>
</div>
</Link>
</>
);
};

export default ExploreCard;
12 changes: 12 additions & 0 deletions v2/src/components/DropDowns/Notification.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React, { useState, useEffect } from 'react';
import Image from 'next/image';
import { NotificationsProps, Notification } from '@/types';
import { Activity } from 'iconsax-react';
import { useStateCtx } from '@/context/StateCtx';

const NotificationDropDown = () => {
const { OpenNotification, setOpenNotification } = useStateCtx();
return <div>Notification</div>;
};

export default NotificationDropDown;
2 changes: 1 addition & 1 deletion v2/src/components/DropDowns/ProfileDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ProfileDropDown = () => {
</div>
</Link>
</div>
<div className="flex items-center gap-2 cursor-pointer text-Grey-G500 dark:text-dark-two rounded-lg px-2">
<div className="flex items-center gap-2 h-9 cursor-pointer text-Grey-G500 dark:text-dark-two rounded-lg px-2">
<Link href="/" className="flex items-center gap-2">
{/* <Button onClick={handleLogout} isLoading={isloading} className="px-2 h-9"> */}
<LogoutCurve size={18} />
Expand Down
4 changes: 2 additions & 2 deletions v2/src/components/Header/NavBarAuthenticated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const NavBarAuthenticated = () => {
<div className="flex items-center justify-between">
<Link
href="/"
className="flex gap-14 text-primary-100 dark:text-dark-two text-[30px] font-medium font-chelsea"
className="flex gap-14 text-primary-100 text-[30px] font-medium font-chelsea"
>
EVENTO
</Link>
Expand Down Expand Up @@ -67,7 +67,7 @@ const NavBarAuthenticated = () => {
</div>
</div>
</nav>
<ProfileDropDown />
{OpenProfile && <ProfileDropDown />}
</header>
);
};
Expand Down
Loading

0 comments on commit eca3021

Please sign in to comment.