-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from CS3219-AY2425S1/feat/fe-for-matching
Feat/fe for matching
- Loading branch information
Showing
9 changed files
with
406 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
|
||
type Props = {}; | ||
|
||
const page = (props: Props) => { | ||
return <div>This is the collaboration page</div>; | ||
}; | ||
|
||
export default page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
'use client'; | ||
|
||
import { useState } from 'react'; | ||
import { useRouter } from 'next/navigation'; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from '@/components/ui/dialog'; | ||
import { Button } from '@/components/ui/button'; | ||
import { FilterSelect } from '@/app/(main)/components/filter/FilterSelect'; | ||
import { TopicsPopover } from '@/app/(main)/components/filter/TopicsPopover'; | ||
import { sendMessageToQueue } from '@/lib/rabbitmq'; | ||
import { axiosAuthClient } from '@/network/axiosClient'; | ||
import { DIFFICULTY_OPTIONS } from '@/lib/constants'; | ||
|
||
export function PreMatch() { | ||
const [open, setOpen] = useState(false); | ||
const [difficulty, setDifficulty] = useState(''); | ||
const [selectedTopics, setSelectedTopics] = useState<string[]>([]); | ||
const router = useRouter(); | ||
|
||
const handleConfirm = async () => { | ||
try { | ||
const profileDetails = await getProfileDetails(); | ||
const message = { | ||
_id: profileDetails.id, | ||
name: profileDetails.username, | ||
topic: selectedTopics[0] || '', // TODO: change to list, but current backend only accepts 1 | ||
// topic: selectedTopics.join(','), | ||
difficulty: difficulty, | ||
}; | ||
await sendMessageToQueue(message); | ||
setOpen(false); | ||
router.push('/match'); | ||
} catch (err) { | ||
console.error('Error in handleConfirm:', err); | ||
} | ||
}; | ||
|
||
const getProfileDetails = async () => { | ||
const result = await axiosAuthClient.get('/auth/verify-token'); | ||
return result.data.data; | ||
}; | ||
|
||
return ( | ||
<Dialog open={open} onOpenChange={setOpen}> | ||
<DialogTrigger asChild> | ||
<Button variant="ghost" className="text-gray-300 hover:text-white"> | ||
Match | ||
</Button> | ||
</DialogTrigger> | ||
<DialogContent className="sm:max-w-[425px]"> | ||
<DialogHeader> | ||
<DialogTitle>Choose Match Preferences</DialogTitle> | ||
</DialogHeader> | ||
<div className="grid gap-4 py-4"> | ||
<div className="flex items-center gap-4"> | ||
<label htmlFor="difficulty" className="text-right"> | ||
Difficulty: | ||
</label> | ||
<FilterSelect | ||
placeholder="Difficulty" | ||
options={DIFFICULTY_OPTIONS} | ||
onChange={(value) => setDifficulty(value)} | ||
value={difficulty} | ||
showSelectedValue={true} | ||
/> | ||
</div> | ||
<div className="flex items-center gap-4"> | ||
<label htmlFor="topics" className="text-right"> | ||
Topics: | ||
</label> | ||
<TopicsPopover | ||
selectedTopics={selectedTopics} | ||
onChange={setSelectedTopics} | ||
/> | ||
</div> | ||
</div> | ||
<Button | ||
onClick={handleConfirm} | ||
disabled={!difficulty || selectedTopics.length === 0} | ||
> | ||
Confirm and Match | ||
</Button> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} |
Oops, something went wrong.