Skip to content

Commit

Permalink
Feat: Connected adding breakpoints with server
Browse files Browse the repository at this point in the history
And also added toast functionality to infrom the user
  • Loading branch information
Shubh942 committed Aug 8, 2024
1 parent 02d0263 commit cc53822
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 6 deletions.
34 changes: 34 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"react-icons": "^5.2.1",
"react-router-dom": "^6.23.1",
"react-terminal": "^1.4.4",
"react-toastify": "^10.0.5",
"react-toggle-dark-mode": "^1.1.1",
"terminal-in-react": "^4.3.1"
},
Expand Down
10 changes: 10 additions & 0 deletions webapp/src/components/Breakpoint/Breakpoint.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@
align-items: center;
gap: 28px;
}

.save-button {
display: flex;
padding: 4px 8px;
justify-content: center;
align-items: center;
gap: 10px;
border-radius: 2px;
background: var(--primary-orange, #e88f40);
}
64 changes: 61 additions & 3 deletions webapp/src/components/Breakpoint/Breakpoint.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,78 @@
import React from "react";
import React, { useState } from "react";
import "./Breakpoint.css";

import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import axios from "axios";

const Breakpoint = () => {
const [breakLine, setBreakLine] = useState("");
const [breakFunction, setBreakFunction] = useState("");

const handleBreakSave = async (e) => {
e.preventDefault();
console.log("click");
if (!breakLine && !breakFunction) {
toast.error("Enter any of the field", {
autoClose: 1000,
});
return;
}
try {
const data = await axios.post("http://127.0.0.1:10000/set_breakpoint", {
location: breakLine,
name: "program",
});
console.log(data);
toast.success("Added breakpoint", {
autoClose: 1000,
});
} catch (error) {
toast.error("Something went Wrong", {
autoClose: 1000,
});
}
};
return (
<div className="breakpoint-container">
<div className="add-breakpoint">Add Breakpoint</div>
<div className="lower-breakpoint">
<div className="line-breakpoint">
<a>Line</a>
<input type="text" name="" id="" />
<input
type="text"
name=""
id=""
value={breakLine}
onChange={(e) => setBreakLine(e.target.value)}
/>
</div>
<div className="line-breakpoint">
<a>Function</a>
<input type="text" name="" id="" />
<input
type="text"
name=""
id=""
value={breakFunction}
onChange={(e) => setBreakFunction(e.target.value)}
/>
</div>
<button className="save-button" onClick={handleBreakSave}>
Add
</button>
</div>
<ToastContainer
position="bottom-right"
autoClose={1000}
hideProgressBar={false}
newestOnTop={false}
closeOnClick
rtl={false}
pauseOnFocusLoss
draggable
pauseOnHover
theme="light"
/>
</div>
);
};
Expand Down
3 changes: 0 additions & 3 deletions webapp/src/context/DataContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,15 @@ export const DataProvider = ({ children }) => {
const fetchData = useCallback(async () => {
if (refresh) {
try {
// Your data fetching logic here
const stackResponse = await axios.get("/api/stack");
const functionsResponse = await axios.get("/api/functions");

setStack(stackResponse.data);
setFunctions(functionsResponse.data);

// Reset refresh after data is fetched
setRefresh(false);
} catch (error) {
console.error("Error fetching data:", error);
// Optional: set refresh to false on error as well
setRefresh(false);
}
}
Expand Down

0 comments on commit cc53822

Please sign in to comment.