Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
andychenbruce committed Mar 13, 2024
1 parent 4526774 commit b2edf63
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 136 deletions.
20 changes: 6 additions & 14 deletions frontend/src/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ export const Navbar = () => {
pass2: "",
});



const handleInputChange = (
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
) => {
Expand Down Expand Up @@ -127,10 +125,7 @@ export const Navbar = () => {
old_password: user.pass1,
new_password: user.pass2,
};
send_json_backend(
ENDPOINT_CHANGE_PASSWORD,
changePassRequest,
)
send_json_backend(ENDPOINT_CHANGE_PASSWORD, changePassRequest)
.then(() => {
handleChanegPassDialogClose();
setshowPassChangeSuccessSnackbar(true);
Expand Down Expand Up @@ -171,7 +166,7 @@ export const Navbar = () => {
width: "250px",
backgroundColor: "#9c27b0",
"&:hover": {
backgroundColor: "#7b1fa2",
backgroundColor: "#7b1fa2",
},
}}
onClick={() => {
Expand Down Expand Up @@ -214,10 +209,9 @@ export const Navbar = () => {
width: "250px",
backgroundColor: "#9c27b0",
"&:hover": {
backgroundColor: "#7b1fa2",
backgroundColor: "#7b1fa2",
},
}}

onClick={() => {
redirect("/deck_manage", []);
}}
Expand All @@ -233,7 +227,7 @@ export const Navbar = () => {
width: "250px",
backgroundColor: "#9c27b0",
"&:hover": {
backgroundColor: "#7b1fa2",
backgroundColor: "#7b1fa2",
},
}}
onClick={() => {
Expand All @@ -250,7 +244,7 @@ export const Navbar = () => {
width: "250px",
backgroundColor: "#9c27b0",
"&:hover": {
backgroundColor: "#7b1fa2",
backgroundColor: "#7b1fa2",
},
}}
onClick={handleMenuOpen}
Expand Down Expand Up @@ -342,9 +336,7 @@ export const Navbar = () => {
<TextField
style={{
marginBottom: 20,
borderColor: errorFields2.includes("email")
? "red"
: undefined,
borderColor: errorFields2.includes("email") ? "red" : undefined,
}}
error={errorFields2.includes("email")}
label="Email"
Expand Down
38 changes: 18 additions & 20 deletions frontend/src/pages/ai_test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const App: React.FC = () => {
const [prompt, setPrompt] = useState("");
const [response, setResponse] = useState("");

const submitPrompt = () => { //sends users prompt to backend
const submitPrompt = () => {
//sends users prompt to backend
const aiSend: AiPromptTest = {
prompt: prompt,
};
Expand All @@ -25,7 +26,7 @@ const App: React.FC = () => {

//this function submits a user's prompt when the 'enter' key is pressed
const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {
if (event.key === 'Enter') {
if (event.key === "Enter") {
submitPrompt();
}
};
Expand All @@ -45,21 +46,20 @@ const App: React.FC = () => {
AI Chat
</Typography>
<TextField
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
fullWidth
margin="normal"
style={{ borderRadius: "10px" }}
required
label="Ask a Question!"
InputLabelProps={{ style: { color: "white" } }}
InputProps={{ style: { color: "white" } }} // Setting text color to white
onKeyDown={handleKeyDown}
/>
value={prompt}
onChange={(e) => setPrompt(e.target.value)}
fullWidth
margin="normal"
style={{ borderRadius: "10px" }}
required
label="Ask a Question!"
InputLabelProps={{ style: { color: "white" } }}
InputProps={{ style: { color: "white" } }} // Setting text color to white
onKeyDown={handleKeyDown}
/>
<Button
variant="contained"
onClick={submitPrompt}

sx={{
backgroundColor: "#9c27b0",
"&:hover": {
Expand All @@ -72,13 +72,11 @@ const App: React.FC = () => {
</Button>
<p style={{ color: "white" }}>
{" "}
*Please use correct punctuation for best results
{" "}
</p>
<p style={{ color: "white" }}>
*Please use correct punctuation for best results{" "}
</p>
<p style={{ color: "white" }}>
*Please Note that responses may take a minute to process and
generate
{" "}
generate{" "}
</p>
</Paper>
<Paper
Expand Down
23 changes: 10 additions & 13 deletions frontend/src/pages/deck_manage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ const App: React.FC = () => {
})
.catch((error) => {
console.error("Error in:", error);
setpdfUploadError(true)
setpdfUploadError(true);
});
});
};
Expand Down Expand Up @@ -446,11 +446,11 @@ const App: React.FC = () => {
width: "100%",
height: "200px",
marginBottom: "10px",

backgroundColor: "#af52bf",
"&:hover": {
backgroundColor: "#7b1fa2",
},
"&:hover": {
backgroundColor: "#7b1fa2",
},
position: "relative",
display: "flex",
flexDirection: "column",
Expand Down Expand Up @@ -543,10 +543,10 @@ const App: React.FC = () => {
bottom: "20px",
right: "20px",
backgroundColor: "#9c27b0",
"&:hover": {
"&:hover": {
backgroundColor: "#7b1fa2",
},
border: '2px solid black'
border: "2px solid black",
}}
>
+
Expand All @@ -568,7 +568,6 @@ const App: React.FC = () => {
Create New Deck
</DialogTitle>


{/* CREATE DECK SECTION */}
<Divider style={{ backgroundColor: "#9370db" }} />
<DialogContent style={{ backgroundColor: "#9370db" }}>
Expand Down Expand Up @@ -670,18 +669,16 @@ const App: React.FC = () => {
</DialogActions>
</Dialog>


{/* SELECT ICON */}
{/* SELECT ICON */}
<Dialog
open={openIconDialog}
onClose={handleIconDialogClose}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
>
<DialogTitle
style={{ backgroundColor: "#8916c7", color: 'white'}}
style={{ backgroundColor: "#8916c7", color: "white" }}
id="alert-dialog-title"

>
Choose Deck Icon
</DialogTitle>
Expand Down Expand Up @@ -749,7 +746,7 @@ const App: React.FC = () => {
<Snackbar
open={pdfUploadError}
autoHideDuration={null}
onClose={()=>setpdfUploadError(false)}
onClose={() => setpdfUploadError(false)}
message="Could not upload file!"
></Snackbar>
</div>
Expand Down
1 change: 0 additions & 1 deletion frontend/src/pages/flashcard_editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ const App: React.FC = () => {
);
};


useEffect(() => {
listCards();
}, []);
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/pages/home_page/dummydeck.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from "react";
import { Button } from "@mui/material";
import { redirect } from "../../utils";
import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline';

import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline";

const DummyDeck = () => {
return (
Expand All @@ -25,7 +24,7 @@ const DummyDeck = () => {
alignItems: "center",
}}
>
<AddCircleOutlineIcon/>
<AddCircleOutlineIcon />
<span>Add New Deck</span>
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/home_page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ const home_page: React.FC = () => {
useEffect(updateDecks, []);

const [randomdecks, setRandomDecks]: [CardDeck[], Dispatch<CardDeck[]>] =
useState([] as CardDeck[]); //saves randomly selected decks to be displayed when page is updated
useState([] as CardDeck[]); //saves randomly selected decks to be displayed when page is updated

return (
<div>
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const Main: React.FC<PageProps> = () => {

const [errorMessage, setErrorMessage] = useState<string | null>(null);

const handleInputChange = ( //saves state that textfields are currently in
const handleInputChange = (
//saves state that textfields are currently in
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
) => {
const { value, name } = event.target;
Expand All @@ -37,7 +38,8 @@ const Main: React.FC<PageProps> = () => {
});
};

const onSubmit = (event: React.FormEvent<HTMLFormElement>) => { //when user presses enter or login, sends info to backend for verification of credentials
const onSubmit = (event: React.FormEvent<HTMLFormElement>) => {
//when user presses enter or login, sends info to backend for verification of credentials
event.preventDefault();
send_json_backend<LoginRequest, LoginResponse>(ENDPOINT_LOGIN, user)
.then((data: LoginResponse) => {
Expand All @@ -49,13 +51,16 @@ const Main: React.FC<PageProps> = () => {
});
};

const redirectToacc_create = () => { //redirect to acc creation page
const redirectToacc_create = () => {
//redirect to acc creation page
window.location.pathname = "/acc_create/";
};
const redirectTohome_page = () => { //after login success, redirect to home page
const redirectTohome_page = () => {
//after login success, redirect to home page
window.location.pathname = "/home_page/";
};
const handleClosePopup = () => { //handles bottom left popup for any errors that may occur
const handleClosePopup = () => {
//handles bottom left popup for any errors that may occur
setErrorMessage(null);
};

Expand Down
48 changes: 24 additions & 24 deletions frontend/src/pages/minigame/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,30 @@ const App: React.FC = () => {

const handleDragOver: DragEventHandler<HTMLDivElement> = (e) => {
e.preventDefault();
const mouseY = e.clientY;
const threshold = window.innerHeight / 3;
if (mouseY < threshold) {
const scrollDistance = threshold - mouseY;
// Calculate the scroll speed based on mouse position
const scrollSpeed = scrollDistance / threshold;
// Calculate the new scroll position
const scrollTop = window.scrollY || document.documentElement.scrollTop;
const newScroll = scrollTop - scrollSpeed * 10;
const animateScroll = () => {
const difference = newScroll - window.scrollY;
const step = difference / 5;
if (Math.abs(step) > 1) {
window.scrollBy(0, step);
requestAnimationFrame(animateScroll);
} else {
window.scrollTo(0, newScroll);
}
};
requestAnimationFrame(animateScroll);
}
const mouseY = e.clientY;
const threshold = window.innerHeight / 3;

if (mouseY < threshold) {
const scrollDistance = threshold - mouseY;
// Calculate the scroll speed based on mouse position
const scrollSpeed = scrollDistance / threshold;
// Calculate the new scroll position
const scrollTop = window.scrollY || document.documentElement.scrollTop;
const newScroll = scrollTop - scrollSpeed * 10;

const animateScroll = () => {
const difference = newScroll - window.scrollY;
const step = difference / 5;
if (Math.abs(step) > 1) {
window.scrollBy(0, step);
requestAnimationFrame(animateScroll);
} else {
window.scrollTo(0, newScroll);
}
};

requestAnimationFrame(animateScroll);
}
};

const handleDropLeft: DragEventHandler<HTMLDivElement> = (e) => {
Expand Down
Loading

0 comments on commit b2edf63

Please sign in to comment.