diff --git a/functions/graphql/nexus-typegen.ts b/functions/graphql/nexus-typegen.ts
index fe39635..f97c0c8 100644
--- a/functions/graphql/nexus-typegen.ts
+++ b/functions/graphql/nexus-typegen.ts
@@ -76,6 +76,16 @@ export interface NexusGenObjects {
id: number; // Int!
title: string; // String!
}
+ Hackathon: { // root type
+ cover_image: string; // String!
+ description: string; // String!
+ end_date: NexusGenScalars['Date']; // Date!
+ id: number; // Int!
+ location: string; // String!
+ start_date: NexusGenScalars['Date']; // Date!
+ title: string; // String!
+ website: string; // String!
+ }
LnurlDetails: { // root type
commentAllowed?: number | null; // Int
maxSendable?: number | null; // Int
@@ -198,6 +208,17 @@ export interface NexusGenFieldTypes {
title: string; // String!
votes_sum: number; // Int!
}
+ Hackathon: { // field return type
+ cover_image: string; // String!
+ description: string; // String!
+ end_date: NexusGenScalars['Date']; // Date!
+ id: number; // Int!
+ location: string; // String!
+ start_date: NexusGenScalars['Date']; // Date!
+ title: string; // String!
+ topics: NexusGenRootTypes['Topic'][]; // [Topic!]!
+ website: string; // String!
+ }
LnurlDetails: { // field return type
commentAllowed: number | null; // Int
maxSendable: number | null; // Int
@@ -235,6 +256,7 @@ export interface NexusGenFieldTypes {
allCategories: NexusGenRootTypes['Category'][]; // [Category!]!
allProjects: NexusGenRootTypes['Project'][]; // [Project!]!
allTopics: NexusGenRootTypes['Topic'][]; // [Topic!]!
+ getAllHackathons: NexusGenRootTypes['Hackathon'][]; // [Hackathon!]!
getCategory: NexusGenRootTypes['Category']; // Category!
getFeed: NexusGenRootTypes['Post'][]; // [Post!]!
getLnurlDetailsForProject: NexusGenRootTypes['LnurlDetails']; // LnurlDetails!
@@ -347,6 +369,17 @@ export interface NexusGenFieldTypeNames {
title: 'String'
votes_sum: 'Int'
}
+ Hackathon: { // field return type name
+ cover_image: 'String'
+ description: 'String'
+ end_date: 'Date'
+ id: 'Int'
+ location: 'String'
+ start_date: 'Date'
+ title: 'String'
+ topics: 'Topic'
+ website: 'String'
+ }
LnurlDetails: { // field return type name
commentAllowed: 'Int'
maxSendable: 'Int'
@@ -384,6 +417,7 @@ export interface NexusGenFieldTypeNames {
allCategories: 'Category'
allProjects: 'Project'
allTopics: 'Topic'
+ getAllHackathons: 'Hackathon'
getCategory: 'Category'
getFeed: 'Post'
getLnurlDetailsForProject: 'LnurlDetails'
@@ -474,6 +508,10 @@ export interface NexusGenArgTypes {
skip?: number | null; // Int
take: number | null; // Int
}
+ getAllHackathons: { // args
+ sortBy?: string | null; // String
+ topic?: number | null; // Int
+ }
getCategory: { // args
id: number; // Int!
}
diff --git a/functions/graphql/schema.graphql b/functions/graphql/schema.graphql
index 9a4a7d3..b834674 100644
--- a/functions/graphql/schema.graphql
+++ b/functions/graphql/schema.graphql
@@ -47,6 +47,18 @@ type Category {
"""Date custom scalar type"""
scalar Date
+type Hackathon {
+ cover_image: String!
+ description: String!
+ end_date: Date!
+ id: Int!
+ location: String!
+ start_date: Date!
+ title: String!
+ topics: [Topic!]!
+ website: String!
+}
+
type LnurlDetails {
commentAllowed: Int
maxSendable: Int
@@ -105,6 +117,7 @@ type Query {
allCategories: [Category!]!
allProjects(skip: Int = 0, take: Int = 50): [Project!]!
allTopics: [Topic!]!
+ getAllHackathons(sortBy: String, topic: Int): [Hackathon!]!
getCategory(id: Int!): Category!
getFeed(skip: Int = 0, sortBy: String = "all", take: Int = 10, topic: Int = 0): [Post!]!
getLnurlDetailsForProject(project_id: Int!): LnurlDetails!
diff --git a/functions/graphql/types/hackathon.js b/functions/graphql/types/hackathon.js
index ffc0f1b..74aa633 100644
--- a/functions/graphql/types/hackathon.js
+++ b/functions/graphql/types/hackathon.js
@@ -5,6 +5,7 @@ const {
extendType,
nonNull,
} = require('nexus');
+const { prisma } = require('../prisma')
@@ -15,13 +16,14 @@ const Hackathon = objectType({
t.nonNull.string('title');
t.nonNull.string('description');
t.nonNull.string('cover_image');
- t.nonNull.string('date');
+ t.nonNull.date('start_date');
+ t.nonNull.date('end_date');
t.nonNull.string('location');
t.nonNull.string('website');
t.nonNull.list.nonNull.field('topics', {
type: "Topic",
resolve: (parent) => {
- return []
+ return prisma.hackathon.findUnique({ where: { id: parent.id } }).topics();
}
});
}
@@ -29,15 +31,41 @@ const Hackathon = objectType({
const getAllHackathons = extendType({
type: "Query",
- args: {
- sortBy: stringArg(),
- topic: stringArg(),
- },
definition(t) {
t.nonNull.list.nonNull.field('getAllHackathons', {
type: "Hackathon",
+ args: {
+ sortBy: stringArg(),
+ topic: intArg(),
+ },
resolve(_, args) {
- return [];
+ const { sortBy, topic } = args;
+ return prisma.hackathon.findMany({
+ where: {
+ ...(sortBy === 'Upcoming' && {
+ start_date: {
+ gte: new Date(),
+ }
+ }),
+ ...(sortBy === 'Live' && {
+ start_date: { lte: new Date() },
+ end_date: { gte: new Date() }
+ }),
+ ...(sortBy === 'Finished' && {
+ end_date: {
+ lt: new Date()
+ }
+ }),
+
+ ...(topic && {
+ topics: {
+ some: {
+ id: topic
+ }
+ }
+ })
+ }
+ })
}
})
}
diff --git a/functions/graphql/types/index.js b/functions/graphql/types/index.js
index 3b97a9d..51268f1 100644
--- a/functions/graphql/types/index.js
+++ b/functions/graphql/types/index.js
@@ -4,6 +4,7 @@ const project = require('./project')
const vote = require('./vote')
const post = require('./post')
const users = require('./users')
+const hackathon = require('./hackathon')
module.exports = {
...scalars,
@@ -11,5 +12,6 @@ module.exports = {
...project,
...vote,
...post,
- ...users
+ ...users,
+ ...hackathon
}
\ No newline at end of file
diff --git a/src/App.tsx b/src/App.tsx
index 5df2256..7b79706 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -9,6 +9,7 @@ import LoadingPage from "./Components/LoadingPage/LoadingPage";
// Pages
const FeedPage = React.lazy(() => import("./features/Posts/pages/FeedPage/FeedPage"))
+const HackathonsPage = React.lazy(() => import("./features/Hackathons/pages/HackathonsPage/HackathonsPage"))
const HottestPage = React.lazy(() => import("src/features/Projects/pages/HottestPage/HottestPage"))
const PostDetailsPage = React.lazy(() => import("./features/Posts/pages/PostDetailsPage/PostDetailsPage"))
const CategoryPage = React.lazy(() => import("src/features/Projects/pages/CategoryPage/CategoryPage"))
@@ -47,6 +48,7 @@ function App() {
} />
} />
} />
+ } />
} />
diff --git a/src/Components/Navbar/Navbar.tsx b/src/Components/Navbar/Navbar.tsx
index df31f44..8d31332 100644
--- a/src/Components/Navbar/Navbar.tsx
+++ b/src/Components/Navbar/Navbar.tsx
@@ -8,6 +8,7 @@ import { setNavHeight } from "src/redux/features/ui.slice";
import NavDesktop from "./NavDesktop";
import { useMediaQuery } from "@react-hookz/web";
import { MEDIA_QUERIES } from "src/utils/theme/media_queries";
+import { IoMdTrophy } from "react-icons/io";
export const navLinks = [
@@ -18,6 +19,12 @@ export const navLinks = [
icon: MdComment,
color: "text-primary-600",
},
+ {
+ text: "Hackathons",
+ url: "/hackathons",
+ icon: IoMdTrophy,
+ color: "text-primary-600",
+ },
{
text: "Hottest",
url: "/hottest",
@@ -41,6 +48,7 @@ export default function Navbar() {
}));
const isLargeScreen = useMediaQuery(MEDIA_QUERIES.isLarge)
+ console.log(isLargeScreen, MEDIA_QUERIES.isLarge);
const onConnectWallet = () => {
diff --git a/src/features/Hackathons/Components/HackathonCard/HackathonCard.tsx b/src/features/Hackathons/Components/HackathonCard/HackathonCard.tsx
index fc5f545..0d29b45 100644
--- a/src/features/Hackathons/Components/HackathonCard/HackathonCard.tsx
+++ b/src/features/Hackathons/Components/HackathonCard/HackathonCard.tsx
@@ -1,6 +1,10 @@
import { Hackathon } from "src/features/Hackathons/types"
import { IoLocationOutline } from 'react-icons/io5'
import Button from "src/Components/Button/Button"
+import dayjs from "dayjs";
+import advancedFormat from 'dayjs/plugin/advancedFormat'
+import { trimText } from "src/utils/helperFunctions";
+dayjs.extend(advancedFormat)
export type HackathonCardType = Hackathon;
@@ -18,20 +22,20 @@ export default function HackathonCard({ hackathon }: Props) {
{hackathon.title}
- {hackathon.date}
+ {`${dayjs(hackathon.start_date).format('Do')} - ${dayjs(hackathon.end_date).format('Do MMMM, YYYY')}`}
{hackathon.location}
- {hackathon.description}
+ {trimText(hackathon.description, 110)}
- {hackathon.topics.map(topic =>
{topic.title}
)}
+ {hackathon.topics.map(topic =>
{topic.icon} {topic.title}
)}
-