Skip to content

Commit 97f65cc

Browse files
committed
add question dialog popup
1 parent d050809 commit 97f65cc

File tree

6 files changed

+318
-144
lines changed

6 files changed

+318
-144
lines changed
Lines changed: 133 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import FilterBar from "./Filter/FilterBar";
2-
import ProblemTable from "./ProblemTable";
1+
import FilterBar from "./filter/FilterBar";
2+
import ProblemTable from "./problems/ProblemTable";
3+
import { Problem } from "@/types/types";
34

45
export default function LoggedIn() {
56
return (
@@ -13,75 +14,142 @@ export default function LoggedIn() {
1314
}
1415

1516
// TODO: replace with backend-fetched data
16-
const problems = [
17+
const problems: Problem[] = [
1718
{
18-
status: "attempted",
19-
title: "2220. Minimum Bit Flips to Convert Number",
20-
topics: ["Bit Manipulation"],
21-
difficulty: "Easy",
22-
difficultyColor: "text-green-500",
19+
question_id: 1,
20+
title: "Two Sum",
21+
difficulty: 1,
22+
description:
23+
"Given an array of integers nums\u00a0and an integer target, return indices of the two numbers such that they add up to target.\nYou may assume that each input would have exactly one solution, and you may not use the same element twice.\nYou can return the answer in any order.",
24+
examples: [
25+
"Example 1:\nInput: nums = [2,7,11,15], target = 9\nOutput: [0,1]\nExplanation: Because nums[0] + nums[1] == 9, we return [0, 1].",
26+
"Example 2:\nInput: nums = [3,2,4], target = 6\nOutput: [1,2]",
27+
"Example 3:\nInput: nums = [3,3], target = 6\nOutput: [0,1]",
28+
],
29+
constraints:
30+
"Constraints:\n\n2 <= nums.length <= 10^4\n-10^9 <= nums[i] <= 10^9\n-10^9 <= target <= 10^9\nOnly one valid answer exists.\n\n\u00a0\nFollow-up:\u00a0Can you come up with an algorithm that is less than O(n^2)\u00a0time complexity?",
31+
tags: ["Array", "Hash Table"],
32+
title_slug: "two-sum",
2333
},
2434
{
25-
status: "solved",
26-
title: "1. Two Sum",
27-
topics: ["Array", "Hash Table"],
28-
difficulty: "Easy",
29-
difficultyColor: "text-green-500",
35+
question_id: 9,
36+
title: "Palindrome Number",
37+
difficulty: 2,
38+
description:
39+
"Given an integer x, return true if x is a palindrome, and false otherwise.",
40+
examples: [
41+
"Example 1:\nInput: x = 121\nOutput: true\nExplanation: 121 reads as 121 from left to right and from right to left.",
42+
"Example 2:\nInput: x = -121\nOutput: false\nExplanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome.",
43+
"Example 3:\nInput: x = 10\nOutput: false\nExplanation: Reads 01 from right to left. Therefore it is not a palindrome.",
44+
],
45+
constraints:
46+
"Constraints:\n\n-2^31\u00a0<= x <= 2^31\u00a0- 1\n\n\u00a0\nFollow up: Could you solve it without converting the integer to a string?",
47+
tags: ["Math"],
48+
title_slug: "palindrome-number",
3049
},
3150
{
32-
status: "unsolved",
33-
title: "2. Add Two Numbers",
34-
topics: ["Linked List", "Math"],
35-
difficulty: "Medium",
36-
difficultyColor: "text-yellow-500",
51+
question_id: 13,
52+
title: "Roman to Integer",
53+
difficulty: 1,
54+
description:
55+
"Roman numerals are represented by seven different symbols:\u00a0I, V, X, L, C, D and M.\n\nSymbol Value\nI 1\nV 5\nX 10\nL 50\nC 100\nD 500\nM 1000\nFor example,\u00a02 is written as II\u00a0in Roman numeral, just two ones added together. 12 is written as\u00a0XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.\nRoman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV. Because the one is before the five we subtract it making four. The same principle applies to the number nine, which is written as IX. There are six instances where subtraction is used:\n\nI can be placed before V (5) and X (10) to make 4 and 9.\u00a0\nX can be placed before L (50) and C (100) to make 40 and 90.\u00a0\nC can be placed before D (500) and M (1000) to make 400 and 900.\n\nGiven a roman numeral, convert it to an integer.",
56+
examples: [
57+
'Example 1:\nInput: s = "III"\nOutput: 3\nExplanation: III = 3.',
58+
'Example 2:\nInput: s = "LVIII"\nOutput: 58\nExplanation: L = 50, V= 5, III = 3.',
59+
'Example 3:\nInput: s = "MCMXCIV"\nOutput: 1994\nExplanation: M = 1000, CM = 900, XC = 90 and IV = 4.',
60+
],
61+
constraints:
62+
"Constraints:\n\n1 <= s.length <= 15\ns contains only\u00a0the characters ('I', 'V', 'X', 'L', 'C', 'D', 'M').\nIt is guaranteed\u00a0that s is a valid roman numeral in the range [1, 3999].",
63+
tags: ["Hash Table", "Math", "String"],
64+
title_slug: "roman-to-integer",
3765
},
3866
{
39-
status: "solved",
40-
title: "3. Longest Substring Without Repeating Characters",
41-
topics: ["Hash Table", "String", "Sliding Window"],
42-
difficulty: "Medium",
43-
difficultyColor: "text-yellow-500",
44-
},
45-
{
46-
status: "unsolved",
47-
title: "4. Median of Two Sorted Arrays",
48-
topics: ["Array", "Binary Search", "Divide and Conquer"],
49-
difficulty: "Hard",
50-
difficultyColor: "text-red-500",
51-
},
52-
{
53-
status: "unsolved",
54-
title: "5. Longest Palindromic Substring",
55-
topics: ["String", "Dynamic Programming"],
56-
difficulty: "Medium",
57-
difficultyColor: "text-yellow-500",
58-
},
59-
{
60-
status: "unsolved",
61-
title: "6. Zigzag Conversion",
62-
topics: ["String"],
63-
difficulty: "Medium",
64-
difficultyColor: "text-yellow-500",
65-
},
66-
{
67-
status: "unsolved",
68-
title: "7. Reverse Integer",
69-
topics: ["Math"],
70-
difficulty: "Medium",
71-
difficultyColor: "text-yellow-500",
72-
},
73-
{
74-
status: "unsolved",
75-
title: "8. String to Integer (atoi)",
76-
topics: ["String", "Math"],
77-
difficulty: "Medium",
78-
difficultyColor: "text-yellow-500",
79-
},
80-
{
81-
status: "solved",
82-
title: "9. Palindrome Number",
83-
topics: ["Math"],
84-
difficulty: "Easy",
85-
difficultyColor: "text-green-500",
67+
question_id: 14,
68+
title: "Longest Common Prefix",
69+
difficulty: 3,
70+
description:
71+
'Write a function to find the longest common prefix string amongst an array of strings.\nIf there is no common prefix, return an empty string "".',
72+
examples: [
73+
'Example 1:\nInput: strs = ["flower","flow","flight"]\nOutput: "fl"',
74+
'Example 2:\nInput: strs = ["dog","racecar","car"]\nOutput: ""\nExplanation: There is no common prefix among the input strings.',
75+
],
76+
constraints:
77+
"Constraints:\n\n1 <= strs.length <= 200\n0 <= strs[i].length <= 200\nstrs[i] consists of only lowercase English letters.",
78+
tags: ["String", "Trie"],
79+
title_slug: "longest-common-prefix",
8680
},
8781
];
82+
83+
// // TODO: replace with backend-fetched data
84+
// const problems = [
85+
// {
86+
// status: "attempted",
87+
// title: "2220. Minimum Bit Flips to Convert Number",
88+
// topics: ["Bit Manipulation"],
89+
// difficulty: "Easy",
90+
// difficultyColor: "text-green-500",
91+
// },
92+
// {
93+
// status: "solved",
94+
// title: "1. Two Sum",
95+
// topics: ["Array", "Hash Table"],
96+
// difficulty: "Easy",
97+
// difficultyColor: "text-green-500",
98+
// },
99+
// {
100+
// status: "unsolved",
101+
// title: "2. Add Two Numbers",
102+
// topics: ["Linked List", "Math"],
103+
// difficulty: "Medium",
104+
// difficultyColor: "text-yellow-500",
105+
// },
106+
// {
107+
// status: "solved",
108+
// title: "3. Longest Substring Without Repeating Characters",
109+
// topics: ["Hash Table", "String", "Sliding Window"],
110+
// difficulty: "Medium",
111+
// difficultyColor: "text-yellow-500",
112+
// },
113+
// {
114+
// status: "unsolved",
115+
// title: "4. Median of Two Sorted Arrays",
116+
// topics: ["Array", "Binary Search", "Divide and Conquer"],
117+
// difficulty: "Hard",
118+
// difficultyColor: "text-red-500",
119+
// },
120+
// {
121+
// status: "unsolved",
122+
// title: "5. Longest Palindromic Substring",
123+
// topics: ["String", "Dynamic Programming"],
124+
// difficulty: "Medium",
125+
// difficultyColor: "text-yellow-500",
126+
// },
127+
// {
128+
// status: "unsolved",
129+
// title: "6. Zigzag Conversion",
130+
// topics: ["String"],
131+
// difficulty: "Medium",
132+
// difficultyColor: "text-yellow-500",
133+
// },
134+
// {
135+
// status: "unsolved",
136+
// title: "7. Reverse Integer",
137+
// topics: ["Math"],
138+
// difficulty: "Medium",
139+
// difficultyColor: "text-yellow-500",
140+
// },
141+
// {
142+
// status: "unsolved",
143+
// title: "8. String to Integer (atoi)",
144+
// topics: ["String", "Math"],
145+
// difficulty: "Medium",
146+
// difficultyColor: "text-yellow-500",
147+
// },
148+
// {
149+
// status: "solved",
150+
// title: "9. Palindrome Number",
151+
// topics: ["Math"],
152+
// difficulty: "Easy",
153+
// difficultyColor: "text-green-500",
154+
// },
155+
// ];

peerprep-fe/src/app/(main)/components/ProblemTable.tsx

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {
2+
Dialog,
3+
DialogContent,
4+
DialogHeader,
5+
DialogTitle,
6+
DialogDescription,
7+
} from "@/components/ui/dialog";
8+
import { Button } from "@/components/ui/button";
9+
import { ProblemDialogData } from "@/types/types";
10+
11+
export default function ProblemDialog({
12+
isOpen,
13+
onClose,
14+
problem,
15+
}: {
16+
isOpen: boolean;
17+
onClose: () => void;
18+
problem: ProblemDialogData | null;
19+
}) {
20+
if (!problem) return null;
21+
22+
const difficultyText =
23+
problem.difficulty === 1
24+
? "Easy"
25+
: problem.difficulty === 2
26+
? "Medium"
27+
: "Hard";
28+
29+
return (
30+
<Dialog open={isOpen} onOpenChange={onClose}>
31+
<DialogContent className="bg-black">
32+
<DialogHeader>
33+
<DialogTitle>{problem.title}</DialogTitle>
34+
<DialogDescription>Difficulty: {difficultyText}</DialogDescription>
35+
</DialogHeader>
36+
<div className="mt-4">
37+
<h3 className="text-lg font-semibold mb-2">Description:</h3>
38+
<p>{problem.description}</p>
39+
</div>
40+
<div className="mt-6 flex justify-end">
41+
{/* TODO: link to match route/page */}
42+
<Button variant="secondary">Match</Button>
43+
</div>
44+
</DialogContent>
45+
</Dialog>
46+
);
47+
}

0 commit comments

Comments
 (0)