Skip to content

Commit

Permalink
chore: Aplica refactorización del código
Browse files Browse the repository at this point in the history
Se han eliminado partes no usadas del código para mantener el código limpio y usable.

Co-Authored-By: Evelyn Gisele Yugsi Yugsi <[email protected]>
  • Loading branch information
Javitoox and eveyugyug committed Jan 8, 2022
1 parent bdfb061 commit e943be3
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 86 deletions.
2 changes: 1 addition & 1 deletion decide_panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"axios": "^0.24.0",
"chart.js": "^3.7.0",
"babel-plugin-istanbul": "^6.1.1",
"chart.js": "^3.7.0",
"cypress": "8.4.1",
"env-cmd": "^10.1.0",
"eslint-plugin-cypress": "^2.12.1",
Expand Down
55 changes: 0 additions & 55 deletions decide_panel/src/components/Bar.js

This file was deleted.

26 changes: 3 additions & 23 deletions decide_panel/src/components/Graphics.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,23 @@
import { useEffect, useState } from "react";
import Api from "../services/backend";
import { ProgressBar } from "primereact/progressbar";
import React from "react";
import { Pie } from "react-chartjs-2";
import Chart from 'chart.js/auto';
import { useRef } from "react";
import { Dropdown } from 'primereact/dropdown';
import { Card } from "@nextui-org/react";
import "../css/Graphics.css";
// eslint-disable-next-line
import Chart from 'chart.js/auto';

const Graphics = () => {
const [time, setTime] = useState(Date.now());
const [errorConection, setErrorConection] = useState(null);
const [state, setState] = useState({
data: "{}",
});
const formRef = React.useRef();
const [id, setId] = useState(1);
const messages = useRef(null);

function deleteErrorMessage() {
setErrorConection(null);
}
function handleSubmit(evt) {
evt.preventDefault();
const formData = new FormData(formRef.current);
const value = Object.fromEntries(formData);
console.log(value.id)
setId(value.id)
}
useEffect(() => {
Expand All @@ -37,20 +28,9 @@ const Graphics = () => {
}, []);

useEffect(() => {
deleteErrorMessage();
Api.get_votes_chart(id)
.then((res) => setState({ data: res }))
.catch((error) => {
setErrorConection(
<div className="alert alert-dark">
<strong>Error de conexión</strong>
<ProgressBar
mode="indeterminate"
style={{ height: "6px" }}
></ProgressBar>
</div>
);
});
// eslint-disable-next-line
}, [time]);
try {
let json_raw = JSON.stringify(state.data);
Expand Down
12 changes: 5 additions & 7 deletions decide_panel/src/services/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,24 @@ const Api = {
.post(REACT_APP_URI_BACKEND + "backups/create")
.then((res) => res.status);
},

get_backups() {
return axios
.get(REACT_APP_URI_BACKEND + "backups/list")
.then((res) => res.data);
},

restore_backup(backup) {
return axios
.post(REACT_APP_URI_BACKEND + "backups/restore/" + backup)
.then((res) => res.status);
},
get_census(voting_id) {

get_votes_chart(voting_id) {
return axios
.get(REACT_APP_URI_BACKEND + "census/" + voting_id + "/")
.get(REACT_APP_URI_BACKEND + "voting/?id=" + voting_id)
.then((res) => res.data);
},
get_votes_chart(voting_id){
return axios
.get(REACT_APP_URI_BACKEND + "voting/?id=" + voting_id)
.then((res) => res.data);
}
};

export default Api;

0 comments on commit e943be3

Please sign in to comment.