Files
Syed Ali Abbas Zaidi 8480dbc228 chore: apply amnesty on existing not fixable issues (#32215)
* fix: eslint operator-linebreak issue

* fix: eslint quotes issue

* fix: react jsx indent and props issues

* fix: eslint trailing spaces issues

* fix: eslint line around directives issue

* fix: eslint semi rule

* fix: eslint newline per chain rule

* fix: eslint space infix ops rule

* fix: eslint space-in-parens issue

* fix: eslint space before function paren issue

* fix: eslint space before blocks issue

* fix: eslint arrow body style issue

* fix: eslint dot-location issue

* fix: eslint quotes issue

* fix: eslint quote props issue

* fix: eslint operator assignment issue

* fix: eslint new line after import issue

* fix: indent issues

* fix: operator assignment issue

* fix: all autofixable eslint issues

* fix: all react related fixable issues

* fix: autofixable eslint issues

* chore: remove all template literals

* fix: remaining autofixable issues

* chore: apply amnesty on all existing issues

* fix: failing xss-lint issues

* refactor: apply amnesty on remaining issues

* refactor: apply amnesty on new issues

* fix: remove file level suppressions

* refactor: apply amnesty on new issues
2023-08-07 19:13:19 +05:00

89 lines
2.7 KiB
JavaScript

import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
const exGrades = [
{
assignment_type: 'Exam',
total_possible: 6.0,
total_earned: 3.0
},
{
assignment_type: 'Homework',
total_possible: 5.0,
},
{
assignment_type: 'Homework',
total_possible: 11.0,
total_earned: 0.0
}
];
class GradeTable extends React.Component {
// eslint-disable-next-line no-useless-constructor
constructor(props) {
super(props);
}
getTableGroup(type, groupIndex) {
const {grades} = this.props;
// eslint-disable-next-line array-callback-return
const groupData = grades.filter(value => {
if (value.assignment_type === type) {
return value;
}
});
const multipleAssignments = groupData.length > 1;
const rows = groupData.map(({
assignment_type, total_possible, total_earned, passing_grade
}, index) => {
const label = multipleAssignments ? `${assignment_type} ${index + 1}` : assignment_type;
return (
// eslint-disable-next-line react/no-array-index-key
<tr key={index}>
<td>{label}</td>
<td>{passing_grade}/{total_possible}</td>
<td>{total_earned}/{total_possible}</td>
</tr>
);
});
return rows.length ? <tbody className="type-group" key={groupIndex}>{rows}</tbody> : false;
}
render() {
const {assignmentTypes, passingGrade, percentGrade} = this.props;
return (
<table className="table grade-table">
<thead className="table-head">
<tr>
<th>Assignment</th>
<th>Passing</th>
<th>You</th>
</tr>
</thead>
{assignmentTypes.map((type, index) => this.getTableGroup(type, index))}
<tfoot>
<tr className="totals">
<td className="footer-label">Total</td>
<td>{passingGrade}%</td>
<td>*{percentGrade}%</td>
</tr>
</tfoot>
</table>
);
}
}
GradeTable.propTypes = {
// eslint-disable-next-line react/forbid-prop-types
assignmentTypes: PropTypes.array.isRequired,
// eslint-disable-next-line react/forbid-prop-types
grades: PropTypes.array.isRequired,
passingGrade: PropTypes.number.isRequired,
percentGrade: PropTypes.number.isRequired
};
export default GradeTable;