diff --git a/src/components/blocks/LectureGroupBlock.jsx b/src/components/blocks/LectureGroupBlock.tsx similarity index 55% rename from src/components/blocks/LectureGroupBlock.jsx rename to src/components/blocks/LectureGroupBlock.tsx index a596f40..1e50321 100644 --- a/src/components/blocks/LectureGroupBlock.jsx +++ b/src/components/blocks/LectureGroupBlock.tsx @@ -1,12 +1,26 @@ import React from 'react'; -import PropTypes from 'prop-types'; -import { withTranslation } from 'react-i18next'; - +import { useTranslation } from 'react-i18next'; import { appBoundClassNames as classNames } from '../../common/boundClassNames'; -import lectureShape from '../../shapes/model/subject/LectureShape'; +import lectureType from '../../shapes/model/subject/LectureType'; + +interface LectureGroupBlockProps { + lectureGroup: lectureType[]; + isRaised: boolean; + isDimmed: boolean; + isTaken: boolean; + children?: React.ReactNode; +} + +const LectureGroupBlock: React.FC = ({ + lectureGroup, + isRaised, + isDimmed, + isTaken, + children, +}) => { + const { t } = useTranslation(); -const LectureGroupBlock = ({ t, lectureGroup, isRaised, isDimmed, isTaken, children }) => { return (
void; + addToTable: (lecture: lectureType) => void; + deleteFromCart: (lecture: lectureType) => void; + onMouseOver?: (lecture: lectureType) => void; + onMouseOut?: (lecture: lectureType) => void; + onClick?: (lecture: lectureType) => void; +} + +const LectureGroupBlockRow: React.FC = ({ lecture, isHighlighted, inTimetable, @@ -22,6 +35,7 @@ const LectureGroupBlockRow = ({ onMouseOut, onClick, }) => { + const { t } = useTranslation(); const getClass = (lec) => { switch (lec.class_title.length) { case 1: @@ -37,17 +51,17 @@ const LectureGroupBlockRow = ({ ? (event) => { onMouseOver(lecture); } - : null; + : undefined; const handleMouseOut = onMouseOut ? (event) => { onMouseOut(lecture); } - : null; + : undefined; const handleClick = onClick ? (event) => { onClick(lecture); } - : null; + : undefined; const handleDeleteFromCartClick = (event) => { event.stopPropagation(); deleteFromCart(lecture); @@ -133,19 +147,4 @@ const LectureGroupBlockRow = ({ ); }; -LectureGroupBlockRow.propTypes = { - lecture: lectureShape.isRequired, - isHighlighted: PropTypes.bool.isRequired, - inTimetable: PropTypes.bool.isRequired, - isTimetableReadonly: PropTypes.bool.isRequired, - inCart: PropTypes.bool.isRequired, - fromCart: PropTypes.bool.isRequired, - addToCart: PropTypes.func.isRequired, - addToTable: PropTypes.func.isRequired, - deleteFromCart: PropTypes.func.isRequired, - onMouseOver: PropTypes.func, - onMouseOut: PropTypes.func, - onClick: PropTypes.func, -}; - -export default withTranslation()(React.memo(LectureGroupBlockRow)); +export default React.memo(LectureGroupBlockRow); diff --git a/src/components/blocks/LectureGroupSimpleBlock.jsx b/src/components/blocks/LectureGroupSimpleBlock.tsx similarity index 77% rename from src/components/blocks/LectureGroupSimpleBlock.jsx rename to src/components/blocks/LectureGroupSimpleBlock.tsx index 088c876..36ad61c 100644 --- a/src/components/blocks/LectureGroupSimpleBlock.jsx +++ b/src/components/blocks/LectureGroupSimpleBlock.tsx @@ -1,13 +1,17 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import { appBoundClassNames as classNames } from '../../common/boundClassNames'; import { getProfessorsShortStr } from '../../utils/lectureUtils'; +import lectureType from '../../shapes/model/subject/LectureType'; -import lectureShape from '../../shapes/model/subject/LectureShape'; +interface LectureGroupSimpleBlockProps { + lectures: lectureType[]; +} -const LectureGroupSimpleBlock = ({ t, lectures }) => { +const LectureGroupSimpleBlock: React.FC = ({ lectures }) => { + const { t } = useTranslation(); const getClass = (lecture) => { if (!lecture.class_title) { return classNames(''); @@ -37,8 +41,4 @@ const LectureGroupSimpleBlock = ({ t, lectures }) => { ); }; -LectureGroupSimpleBlock.propTypes = { - lectures: PropTypes.arrayOf(lectureShape).isRequired, -}; - -export default withTranslation()(React.memo(LectureGroupSimpleBlock)); +export default React.memo(LectureGroupSimpleBlock); diff --git a/src/components/blocks/LectureSimpleBlock.jsx b/src/components/blocks/LectureSimpleBlock.tsx similarity index 53% rename from src/components/blocks/LectureSimpleBlock.jsx rename to src/components/blocks/LectureSimpleBlock.tsx index 6acb06c..dcdee22 100644 --- a/src/components/blocks/LectureSimpleBlock.jsx +++ b/src/components/blocks/LectureSimpleBlock.tsx @@ -1,17 +1,32 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { withTranslation } from 'react-i18next'; +import { useTranslation } from 'react-i18next'; import { appBoundClassNames as classNames } from '../../common/boundClassNames'; -import lectureShape from '../../shapes/model/subject/LectureShape'; +import lectureType from '@/shapes/model/subject/LectureType'; + +interface LectureSimpleBlockProps { + lecture: lectureType; + isRaised: boolean; + isDimmed: boolean; + hasReview: boolean; + onClick?: (lecture: lectureType) => void; /// +} +const LectureSimpleBlock: React.FC = ({ + lecture, + isRaised, + isDimmed, + hasReview, + onClick, +}) => { + const { t } = useTranslation(); -const LectureSimpleBlock = ({ t, lecture, isRaised, isDimmed, hasReview, onClick }) => { const handleClick = onClick ? (event) => { onClick(lecture); } - : null; + : undefined; return (