chore: lint-format-docs-tests-bugfixes (#105)
* docs: add jsdoc * feat: change enums to as const objects * chore(test): add themeColors.test.ts * fix: fix tests and bugs with strings.ts util * fix: path alias imports and tsconfig file bug * fix: remove --max-warnings 0
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
/* eslint-disable no-nested-ternary */
|
||||
import { Course, Semester } from '@shared/types/Course';
|
||||
import { Distribution, LetterGrade } from '@shared/types/Distribution';
|
||||
import Highcharts from 'highcharts';
|
||||
import HighchartsReact from 'highcharts-react-official';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import type { Course, Semester } from '@shared/types/Course';
|
||||
import type { Distribution, LetterGrade } from '@shared/types/Distribution';
|
||||
import Card from '@views/components/common/Card/Card';
|
||||
import Icon from '@views/components/common/Icon/Icon';
|
||||
import Spinner from '@views/components/common/Spinner/Spinner';
|
||||
@@ -14,20 +10,26 @@ import {
|
||||
querySemesterDistribution,
|
||||
} from '@views/lib/database/queryDistribution';
|
||||
import colors from '@views/styles/colors.module.scss';
|
||||
import Highcharts from 'highcharts';
|
||||
import HighchartsReact from 'highcharts-react-official';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
|
||||
import styles from './GradeDistribution.module.scss';
|
||||
|
||||
enum DataStatus {
|
||||
LOADING = 'LOADING',
|
||||
FOUND = 'FOUND',
|
||||
NOT_FOUND = 'NOT_FOUND',
|
||||
ERROR = 'ERROR',
|
||||
}
|
||||
const DataStatus = {
|
||||
LOADING: 'LOADING',
|
||||
FOUND: 'FOUND',
|
||||
NOT_FOUND: 'NOT_FOUND',
|
||||
ERROR: 'ERROR',
|
||||
} as const;
|
||||
|
||||
type DataStatusType = (typeof DataStatus)[keyof typeof DataStatus];
|
||||
|
||||
interface Props {
|
||||
course: Course;
|
||||
}
|
||||
|
||||
const GRADE_COLORS: Record<LetterGrade, string> = {
|
||||
const GRADE_COLORS = {
|
||||
A: colors.turtle_pond,
|
||||
'A-': colors.turtle_pond,
|
||||
'B+': colors.cactus,
|
||||
@@ -40,7 +42,7 @@ const GRADE_COLORS: Record<LetterGrade, string> = {
|
||||
D: colors.tangerine,
|
||||
'D-': colors.tangerine,
|
||||
F: colors.speedway_brick,
|
||||
};
|
||||
} as const satisfies Record<LetterGrade, string>;
|
||||
|
||||
/**
|
||||
* A chart to fetch and display the grade distribution for a course
|
||||
@@ -51,7 +53,7 @@ export default function GradeDistribution({ course }: Props) {
|
||||
const [semesters, setSemesters] = useState<Semester[]>([]);
|
||||
const [selectedSemester, setSelectedSemester] = useState<Semester | null>(null);
|
||||
const [distribution, setDistribution] = useState<Distribution | null>(null);
|
||||
const [status, setStatus] = useState<DataStatus>(DataStatus.LOADING);
|
||||
const [status, setStatus] = useState<DataStatusType>(DataStatus.LOADING);
|
||||
|
||||
const [chartOptions, setChartOptions] = useState<Highcharts.Options>({
|
||||
title: {
|
||||
@@ -206,7 +208,7 @@ export default function GradeDistribution({ course }: Props) {
|
||||
<Text color='speedway_brick' /* size='medium' weight='semi_bold' */>
|
||||
There was an error fetching the grade distribution data
|
||||
</Text>
|
||||
<Icon color='speedway_brick' /* size='large' */ name='sentiment_dissatisfied' />
|
||||
<Icon color='speedway_brick' /* size='large' */ name='sentiment_dissatisfied' />
|
||||
</Card>
|
||||
)}
|
||||
{status === DataStatus.NOT_FOUND && (
|
||||
|
||||
Reference in New Issue
Block a user