Skip to content

Commit 06e5bec

Browse files
committed
Fix Criteria-less match me
Prevent modal from showing up unless difficulty and language is set
1 parent fc1cd03 commit 06e5bec

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Frontend/src/components/Sidebar.jsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import Button from 'react-bootstrap/Button';
44
import Card from 'react-bootstrap/Card';
55
import Form from 'react-bootstrap/Form';
66
import Modal from "react-bootstrap/Modal";
7-
import Matching from "./Matching";
8-
import SuccessfulMatch from "./SuccessfulMatch";
9-
import UnsuccessfulMatch from "./UnsuccessfulMatch";
7+
import Matching from "./matching/Matching";
8+
import SuccessfulMatch from "./matching/SuccessfulMatch";
9+
import UnsuccessfulMatch from "./matching/UnsuccessfulMatch";
10+
import CriteriaDisplay from './matching/CriteriaDisplay';
1011
const { getUserFromToken } = require('./user/userAvatarBox');
1112

1213
function Sidebar() {
@@ -60,8 +61,8 @@ function Sidebar() {
6061
}, []);
6162

6263
const handleMatch = () => {
63-
setShowMatching(true);
6464
if (ws && difficulty && language) {
65+
setShowMatching(true);
6566
ws.send(JSON.stringify({ userId, difficulty, language })); // Send to server
6667
} else {
6768
alert('Please select a difficulty and language.');
@@ -94,6 +95,10 @@ function Sidebar() {
9495
<option value="Java">Java</option>
9596
<option value="C++">C++</option>
9697
</Form.Select>
98+
99+
{/* Display Criteria Selected*/}
100+
<CriteriaDisplay difficulty={difficulty} language={language}></CriteriaDisplay>
101+
97102
<Button variant="primary" onClick={handleMatch}>Match me!</Button>
98103

99104
{/* Modals */}

Frontend/src/components/Matching.jsx renamed to Frontend/src/components/matching/Matching.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect } from 'react';
22
import CloseButton from 'react-bootstrap/esm/CloseButton';
3-
import '../css/Matching.css';
3+
import '../../css/Matching.css';
44

55
function Matching({ handleClose }) {
66
const [seconds, setSeconds] = useState(0);
@@ -26,7 +26,7 @@ function Matching({ handleClose }) {
2626
<div className="matching-text">
2727
<h2>Matching you....</h2>
2828
<p>{`${minutes < 10 ? `0${minutes}` : minutes}:${seconds < 10 ? `0${seconds}` : seconds}`}</p>
29-
<button className='btn btn-primary btn-sm' onClick={handleClose} >Cancel</button>
29+
{/*<button className='btn btn-primary btn-sm' onClick={handleClose} >Cancel</button>*/}
3030
</div>
3131
</div>
3232
);
File renamed without changes.

Frontend/src/components/UnsuccessfulMatch.jsx renamed to Frontend/src/components/matching/UnsuccessfulMatch.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function UnsuccessfulMatch({ handleClose }) {
88
<div className="matching-text">
99
<CloseButton className="close-button" onClick={handleClose}></CloseButton>
1010
<h2>Sorry, we are unable to find you a match.</h2>
11-
<button className='btn btn-primary btn-sm'>Match me again</button>
11+
{/*<button className='btn btn-primary btn-sm'>Match me again</button>*/}
1212
</div>
1313
</div>
1414
);

0 commit comments

Comments
 (0)