Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored some code to resolve many of the eslint errors. #343

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Frontend/src/components/AdminSettings/AdminContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import AuthContext from '../../AuthContext';
import { MenuTabs } from '../globalStyles/MenuTabs';
import UserProfilesContainer from './UserProfilesContainer';
import AdminSettings from './AdminSettings';
import ideaLABlogo from '../globalStyles/img/ideaLabLogo.png';

const AdminContainer = () => {
const [adminView, setView] = useState('settings');
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/components/AdminSettings/AdminSettings.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import React from 'react';
import { ToastProvider } from 'react-toast-notifications';
import './AdminSettings.css';
import ColorAvailability from './components/ColorAvailability';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import './ColorAvailability.css';

const ColorAvailability = () => {
const [allColors, setAllColors] = useState([]);
const [hexList, setHexList] = useState([]);

const onSuccess = index => {
const colorIndex = index - 1;
Expand Down Expand Up @@ -38,33 +37,28 @@ const ColorAvailability = () => {
};

useEffect(() => {
let colorList = [];
let hexArray = [];
RequestService.getAllColors(
response => {
const data = response.data.data;
data.map((color, i) => {
colorList.push({
const colorList = data.map((color, i) => {
return {
hue: color.color,
available: color.available,
id: i,
});
hexArray.push(color.color);
};
});
setAllColors(colorList);
setHexList(hexArray);
},
error => console.error(error),
);
}, [allColors]);

const renderCircles = () => {
let circleRender = [];
allColors.map((color, i) => {
const circleRender = allColors.map((color, i) => {
const colorRectStyle = {
backgroundColor: `${color.hue}`,
};
circleRender.push(
return (
<div className="customCircle" key={i}>
<div className="availRectDisplay" style={colorRectStyle} />
<div className="checkbox-wrapper">
Expand All @@ -77,7 +71,7 @@ const ColorAvailability = () => {
onChange={event => updateColorAvail(event)}
></input>
</div>
</div>,
</div>
);
});
return circleRender;
Expand Down
19 changes: 10 additions & 9 deletions Frontend/src/components/AdminSettings/components/EmailMessage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ import './EmailMessage.css';
* that is sent via email. It requires the status.
* @param {status} props
*/

const EmailMessage = props => {
const [message, setMessage] = useState('');
const [updatedMessage, setUpdatedMessage] = useState('');

const { addToast } = useToasts();

useEffect(() => {
const fetchData = () => {
RequestService.getEmailMessage(
props.status,
getEmailMessageSuccess,
changeEmailMessageFailure,
);
};

fetchData();
}, []);
});

const getEmailMessageSuccess = data => {
setMessage(data.data.data.emailMessage);
Expand Down Expand Up @@ -50,14 +59,6 @@ const EmailMessage = props => {
}
};

const fetchData = () => {
RequestService.getEmailMessage(
props.status,
getEmailMessageSuccess,
changeEmailMessageFailure,
);
};

return (
<div>
<div className="emailStatusTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const UserProfilesContainer = props => {
const [passwordChange, setPasswordChange] = useState(false);

const { username, firstName, lastName, role } = props.userData;
const [loading, setLoading] = useState(false);
const [error, setError] = useState(false);
const [success, setSuccess] = useState(false);

Expand All @@ -24,7 +23,6 @@ const UserProfilesContainer = props => {
};

const updateUserRole = newRole => {
setLoading(true);
setError(false);
setSuccess(false);
RequestService.updateUsers(
Expand All @@ -41,7 +39,6 @@ const UserProfilesContainer = props => {
setError(true);
},
);
setLoading(false);
};

const changeModal = (
Expand Down
1 change: 0 additions & 1 deletion Frontend/src/components/Analysis/AnalysisContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import AnalysisGraph from './components/AnalysisGraph';
const AnalysisContainer = () => {
const [loading, setLoading] = useState(false);
const [graphData, setGraphData] = useState([]);
const sampleGraphData = require('./sampleGraphData.json');

useEffect(() => {
setLoading(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const AnalysisGraph = props => {
labels.push(key);
for (var colorKey in props.graphData[key]) {
if (props.graphData[key].hasOwnProperty(colorKey)) {
if (datasets[colorKey] != undefined) {
if (datasets[colorKey] !== undefined) {
datasets[colorKey].push(props.graphData[key][colorKey]);
} else {
datasets[colorKey] = [props.graphData[key][colorKey]];
Expand Down
68 changes: 35 additions & 33 deletions Frontend/src/components/Queue/QueueContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,41 @@ const QueueContainer = () => {
}, []);

useEffect(() => {
const fetchQueueData = () => {
//TO DO: GET PRINT JOBS BASED ON STATUS, NOT ALL AT ONCE
RequestService.getPrintJobs(
response => {
const activeCards = response.data.data.filter(card => {
if (
statusView === 'DONE' &&
returnCardStatus(card.status) === 'DONE'
) {
return card;
} else if (
statusView === 'PENDING_REVIEW' &&
returnCardStatus(card.status) === 'PENDING_REVIEW'
) {
return card;
} else if (
statusView === 'PRINTING' &&
returnCardStatus(card.status) === 'PRINTING'
) {
return card;
} else if (
statusView === 'FAILED' &&
returnCardStatus(card.status) === 'FAILED'
) {
return card;
} else {
return null;
}
});
setFilteredData(activeCards);
},
error => console.error(error),
);
};

//Load initial data and set the loading only on first load
setLoading(true);
fetchQueueData();
Expand Down Expand Up @@ -107,39 +142,6 @@ const QueueContainer = () => {
</ToastProvider>
);

const fetchQueueData = () => {
//TO DO: GET PRINT JOBS BASED ON STATUS, NOT ALL AT ONCE
RequestService.getPrintJobs(
response => {
const activeCards = response.data.data.filter(card => {
if (
statusView === 'DONE' &&
returnCardStatus(card.status) === 'DONE'
) {
return card;
} else if (
statusView === 'PENDING_REVIEW' &&
returnCardStatus(card.status) === 'PENDING_REVIEW'
) {
return card;
} else if (
statusView === 'PRINTING' &&
returnCardStatus(card.status) === 'PRINTING'
) {
return card;
} else if (
statusView === 'FAILED' &&
returnCardStatus(card.status) === 'FAILED'
) {
return card;
}
});
setFilteredData(activeCards);
},
error => console.error(error),
);
};

const setStatus = view => {
setStatusView(view);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import ColorPickerContainer from './ColorPickerContainer';
import './PrintCardContainer.css';
import PrintDateAdded from './PrintDateAdded';
import StatusDropdown from './StatusDropdown';
import Backdrop from '../../globalStyles/Backdrop/Backdrop';
import SendEmailModal from './SendEmailModal';

const PrintCardContainer = props => {
const [isToggled, setIsToggled] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/components/globalStyles/StyledDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';

const StyledDropdown = props => {
const [currentVal, updateValue] = useState(props.value);
const { value, dropdownOptions, saveDropdownChange } = props;
const { dropdownOptions, saveDropdownChange } = props;
const dropdownUpdated = event => {
updateValue(event.target.value);
saveDropdownChange(event.target.value);
Expand Down
2 changes: 1 addition & 1 deletion Frontend/src/util/ColorUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const processActiveColors = () => {
response => {
const data = response.data.data;
data.map(color => {
activeColorList.push(color.color);
return activeColorList.push(color.color);
});
},
error => console.error(error),
Expand Down