Skip to content

Commit

Permalink
Merge pull request #12 from CodeCrew-CodeSchool/gameroom
Browse files Browse the repository at this point in the history
Gameroom
  • Loading branch information
ConnerKT authored Apr 30, 2024
2 parents e2b1292 + e5aeced commit d5f7d97
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

webapp/.env
6 changes: 3 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ const http = require("http");
const { Server } = require("socket.io");
const cors = require("cors");
const Redis = require("ioredis");
const redis = new Redis();
const redis = new Redis(process.env.REDIS);
const cookie = require('cookie');
const signature = require('cookie-signature');
const port = 3001;

const app = express();
app.use(cors({
origin: ["http://localhost:5500", "http://localhost:3000"],
origin: ["http://localhost:5500", "http://localhost:3000","https://codecrew-leetcode.onrender.com"],
credentials: true
}));

app.use(express.json())
const server = http.createServer(app);
const io = new Server(server, {
cors: {
origin: ["http://localhost:5500", "http://localhost:3000"],
origin: ["http://localhost:5500", "http://localhost:3000", "https://codecrew-leetcode.onrender.com"],
credentials: true
}
});
Expand Down
1 change: 0 additions & 1 deletion webapp/.env

This file was deleted.

3 changes: 2 additions & 1 deletion webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

# misc
.DS_Store
.env.local
env.local
.env
.env.development.local
.env.test.local
.env.production.local
Expand Down
42 changes: 29 additions & 13 deletions webapp/src/components/AdminView/SessionAddModal/SessionAddModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,30 @@ const SessionAddModal = ({ open, handleClose, allItems }) => {

const postSession = async (session, problemsList) => {
try {
const response = await axios.post(
`https://codecrew-leetcode-api.onrender.com/gameroom/${session}`,
problemsList
);
console.log(process.env.REACT_APP_GAMEROOM_API_URL, "URL GO BRRRRRRR")

const response = await axios.post(process.env.REACT_APP_GAMEROOM_API_URL, {
gameroomId: session,
problems: problemsList

});

console.log(response);

return response;
return response.data;
} catch (error) {

if (error.response) {

console.error('Server responded with error:', error.response.data);
} else if (error.request) {

console.error('No response received from server:', error.request);
} else {

console.error('Error setting up request:', error.message);
}

throw new Error('Failed to post problem:', error);
}
};
Expand All @@ -65,13 +80,7 @@ const SessionAddModal = ({ open, handleClose, allItems }) => {

setSelectedProblems([...selectedProblems, problemId]);
}
try {
const response = await postSession(sessionName,selectedProblems)
console.log(response);

}catch(err){
console.log(err);
}


};
const handleModalClose = () => {
Expand All @@ -82,7 +91,7 @@ const SessionAddModal = ({ open, handleClose, allItems }) => {
handleClose(); // Close the modal
};

const handleSubmission = () => {
const handleSubmission = async () => {
if (selectedProblems.length === 3) {

const selectedProblemNames = selectedProblems.map((_id) => {
Expand All @@ -94,6 +103,13 @@ const SessionAddModal = ({ open, handleClose, allItems }) => {
} else {
console.error("Please select exactly 3 problems");
}
try {
const response = await postSession(sessionName ,selectedProblems)
console.log(response);

}catch(err){
console.log(err);
}
};

return (
Expand Down

0 comments on commit d5f7d97

Please sign in to comment.