Skip to content

Commit 1e0d6ce

Browse files
htovarm7Héctor TovarRodrogamby
authored
Resources page (#36)
* feat: added the add info section * feat: added the option to submit info * feat: add AdditionalContent model and related API endpoints for managing additional resources * feat: added the CRUD for resources * fix * fix * fix * fix * refactor: clean up unused imports and variables in resources and post components * refactor: remove unused 'use client' directive and React import from isAdmin component * add comment time and little ui adjustment * fix trpc client import * Delete src/trpc/client.ts --------- Co-authored-by: Héctor Tovar <soyeduardoo20@gmail.com> Co-authored-by: Rodro <rodrigo.gamboa@Outlook.com>
1 parent b05ca4a commit 1e0d6ce

File tree

13 files changed

+1444
-75
lines changed

13 files changed

+1444
-75
lines changed

package-lock.json

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@trpc/react-query": "^11.0.0-rc.446",
3030
"@trpc/server": "^11.0.0-rc.446",
3131
"clsx": "^2.1.1",
32+
"framer-motion": "^12.18.1",
3233
"geist": "^1.3.0",
3334
"graphql": "^16.10.0",
3435
"graphql-request": "^7.1.2",

prisma/schema.prisma

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ datasource db {
77
url = env("DATABASE_URL")
88
}
99

10-
enum Difficulty {
11-
EASY
12-
MEDIUM
13-
HARD
14-
}
15-
1610
model Account {
1711
id String @id @default(cuid())
1812
userId String
@@ -41,16 +35,17 @@ model Session {
4135
}
4236

4337
model User {
44-
id String @id @default(cuid())
45-
name String?
46-
email String? @unique
47-
emailVerified DateTime?
48-
image String?
49-
leetcodeUser String?
50-
role String @default("MEMBER")
51-
accounts Account[]
52-
sessions Session[]
53-
solvedProblems Problem[] @relation("SolvedProblems")
38+
id String @id @default(cuid())
39+
name String?
40+
email String? @unique
41+
emailVerified DateTime?
42+
image String?
43+
role String @default("MEMBER")
44+
leetcodeUser String?
45+
accounts Account[]
46+
additionalContents AdditionalContent[] @relation("UserAdditionalContents")
47+
sessions Session[]
48+
solvedProblems Problem[] @relation("SolvedProblems")
5449
}
5550

5651
model VerificationToken {
@@ -80,4 +75,20 @@ model Problem {
8075
weekId String
8176
week Week @relation(fields: [weekId], references: [id], onDelete: Cascade)
8277
solvedBy User[] @relation("SolvedProblems")
78+
79+
}
80+
81+
model AdditionalContent {
82+
id String @id @default(cuid())
83+
topic String
84+
content String
85+
createdAt DateTime @default(now())
86+
authorId String
87+
author User @relation("UserAdditionalContents", fields: [authorId], references: [id], onDelete: Cascade)
88+
}
89+
90+
enum Difficulty {
91+
EASY
92+
MEDIUM
93+
HARD
8394
}

src/app/(pages)/resources/page.tsx

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,34 @@
1+
'use client';
2+
import { useState } from "react";
3+
import { motion, AnimatePresence } from "framer-motion";
4+
import Resources from "~/app/_components/nav/navResources";
5+
import ResourceContent from "~/app/_components/resources/resourceContent";
16

2-
const Resources = () => {
3-
return (
4-
<div>
5-
Hi
6-
</div>
7-
)
8-
}
7+
const HomeResources = () => {
8+
const [selectedResource, setSelectedResource] = useState("Resources Page");
99

10-
export default Resources;
10+
return (
11+
<div className="flex">
12+
<div className="w-1/4 overflow-y-auto">
13+
<Resources onSelect={setSelectedResource} selected={selectedResource}/>
14+
</div>
15+
<div className="w-3/4 overflow-y-auto">
16+
<AnimatePresence mode="wait">
17+
<motion.div
18+
key={selectedResource}
19+
initial={{ opacity: 0, y: 10 }}
20+
animate={{ opacity: 1, y: 0 }}
21+
exit={{ opacity: 0, y: -10 }}
22+
transition={{ duration: 0.35 }}
23+
className="p-6 flex-1 text-white relative"
24+
>
25+
<h1 className="text-4xl font-bold mb-4">{selectedResource}</h1>
26+
<ResourceContent topic={selectedResource}/>
27+
</motion.div>
28+
</AnimatePresence>
29+
</div>
30+
</div>
31+
);
32+
};
33+
34+
export default HomeResources;

src/app/_components/fetchData.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { api } from "~/trpc/react";
44

55
export function TestButton() {
6-
const utils = api.useUtils();
76
const { data } = api.leetcode.hasCompletedProblemRecently.useQuery({
87
username: "Oscar_gg",
98
problemSlug: "final-array-state-after-k-multiplication-operations-i",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
type NavResourcesProps = {
2+
onSelect: (topic: string) => void;
3+
selected: string;
4+
}
5+
6+
const topics = [
7+
"Complexities and Analysis of Algorithm",
8+
"Arrays",
9+
"Searching Algorithms",
10+
"Sorting Algorithms",
11+
"Hashing",
12+
"Two Pointer Technique",
13+
"Window Sliding Technique",
14+
"Prefix Sum Technique",
15+
"String",
16+
"Recursion",
17+
"Matrix/Grid",
18+
"Linked List",
19+
"Stack",
20+
"Queue",
21+
"Deque",
22+
"Tree",
23+
"Heap",
24+
"Graph",
25+
"Greedy Algorithm",
26+
"Dynamic Programming",
27+
"Mocks Interviews",
28+
];
29+
30+
const Resources = ({ onSelect, selected }: NavResourcesProps) => {
31+
return (
32+
<nav className="flex flex-col gap-2 p-4 text-white min-w-[200px] h-screen overflow-y-auto">
33+
{topics.map((topic) => (
34+
<button
35+
key={topic}
36+
onClick={() => onSelect(topic)}
37+
className={`
38+
text-left p-2 rounded duration-300
39+
hover:bg-gray-700 hover:scale-105
40+
${selected === topic ? "underline font-semibold bg-gray-800" : ""}
41+
`}
42+
>
43+
{topic}
44+
</button>
45+
))}
46+
</nav>
47+
);
48+
};
49+
50+
export default Resources;

src/app/_components/post.tsx

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)