Skip to content

Commit c978a40

Browse files
committed
fix signup url
1 parent a7fb9a8 commit c978a40

File tree

2 files changed

+69
-20
lines changed

2 files changed

+69
-20
lines changed

peerprep-fe/src/app/collaboration/page.tsx

Lines changed: 68 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { useFilteredProblems } from '@/hooks/useFilteredProblems';
1515
import { DEFAULT_CODE, SUPPORTED_PROGRAMMING_LANGUAGES } from '@/lib/constants';
1616
import { Problem } from '@/types/types';
1717
import { UserCircle } from 'lucide-react';
18-
import React, { useState } from 'react';
18+
import React, { useCallback, useEffect, useRef, useState } from 'react';
1919

2020
const CollaborationPage = () => {
2121
const [selectionProblem, setSelectionProblem] = useState<Problem | null>(
@@ -25,6 +25,38 @@ const CollaborationPage = () => {
2525
const [language, setLanguage] = useState(SUPPORTED_PROGRAMMING_LANGUAGES[0]);
2626
const { problems, isLoading } = useFilteredProblems();
2727

28+
// Layout states
29+
const [leftWidth, setLeftWidth] = useState(50);
30+
const isDragging = useRef(false);
31+
const containerRef = useRef<HTMLDivElement>(null);
32+
33+
// Handle dragging of the divider
34+
const handleMouseDown = useCallback(() => {
35+
isDragging.current = true;
36+
}, []);
37+
38+
const handleMouseUp = useCallback(() => {
39+
isDragging.current = false;
40+
}, []);
41+
42+
const handleMouseMove = useCallback((e: MouseEvent) => {
43+
if (!isDragging.current || !containerRef.current) return;
44+
const containerRect = containerRef.current.getBoundingClientRect();
45+
const newLeftWidth =
46+
((e.clientX - containerRect.left) / containerRect.width) * 100;
47+
setLeftWidth(Math.max(20, Math.min(80, newLeftWidth)));
48+
}, []);
49+
50+
useEffect(() => {
51+
document.addEventListener('mousemove', handleMouseMove);
52+
document.addEventListener('mouseup', handleMouseUp);
53+
return () => {
54+
document.removeEventListener('mousemove', handleMouseMove);
55+
document.removeEventListener('mouseup', handleMouseUp);
56+
};
57+
}, [handleMouseMove, handleMouseUp]);
58+
59+
// Handle selection of a problem
2860
const handleCallback = (id: number) => {
2961
const problem = problems.find((p) => p._id === id);
3062
if (problem) {
@@ -33,29 +65,45 @@ const CollaborationPage = () => {
3365
};
3466

3567
return (
36-
<div className="flex min-h-screen bg-gray-900 p-6 pt-24 text-gray-100">
37-
{selectionProblem ? (
38-
<div className="w-1/2 overflow-y-auto p-6">
68+
<div
69+
className="flex h-screen overflow-hidden bg-gray-900 p-6 pt-24 text-gray-100"
70+
ref={containerRef}
71+
>
72+
<div
73+
className="h-full overflow-y-auto p-6"
74+
style={{ width: `${leftWidth}%` }}
75+
>
76+
{selectionProblem ? (
3977
<ProblemDescriptionPanel
4078
problem={selectionProblem}
4179
resetQuestion={() => setSelectionProblem(null)}
4280
/>
43-
</div>
44-
) : (
45-
<div className="w-1/2 overflow-y-auto p-6">
46-
<h2 className="mb-4 text-2xl font-bold">Choose a question</h2>
47-
<ProblemTable
48-
problems={problems}
49-
isLoading={isLoading}
50-
rowCallback={handleCallback}
51-
/>
52-
</div>
53-
)}
81+
) : (
82+
<>
83+
<h2 className="mb-4 text-2xl font-bold">Choose a question</h2>
84+
<ProblemTable
85+
problems={problems}
86+
isLoading={isLoading}
87+
rowCallback={handleCallback}
88+
/>
89+
</>
90+
)}
91+
</div>
92+
93+
<div
94+
className="flex w-2 cursor-col-resize items-center justify-center bg-gray-600 transition-colors duration-200 hover:bg-gray-500"
95+
onMouseDown={handleMouseDown}
96+
>
97+
<div className="h-8 w-1 rounded-full bg-gray-400" />
98+
</div>
5499

55-
<div className="flex w-1/2 flex-col bg-gray-800 p-6">
56-
<div className="flex justify-between">
100+
<div
101+
className="flex h-full flex-col overflow-y-auto bg-gray-800 p-6"
102+
style={{ width: `${100 - leftWidth}%` }}
103+
>
104+
<div className="mb-4 flex justify-between">
57105
<Select value={language} onValueChange={setLanguage}>
58-
<SelectTrigger className="mb-4 w-32">
106+
<SelectTrigger className="w-32">
59107
<SelectValue placeholder="Select Language" />
60108
</SelectTrigger>
61109
<SelectContent>
@@ -93,8 +141,8 @@ const CollaborationPage = () => {
93141
<Textarea
94142
value={code}
95143
onChange={(e) => setCode(e.target.value)}
96-
className="mb-4 flex-grow bg-gray-900 font-mono text-gray-100"
97-
style={{ resize: 'none' }}
144+
className="flex-grow overflow-y-auto bg-gray-900 font-mono text-gray-100"
145+
style={{ resize: 'none', height: 'calc(100% - 3rem)' }}
98146
/>
99147
</div>
100148
</div>

peerprep-fe/src/app/signup/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export default function SignUpPage() {
2424
e.preventDefault();
2525
setError('');
2626

27+
// const type = 'user';
2728
if (password !== confirmPassword) {
2829
router.push('/signup');
2930
setError('Passwords do not match');

0 commit comments

Comments
 (0)