From 83deb148c1442489f4b5e11b0057040cb90021b1 Mon Sep 17 00:00:00 2001 From: April Date: Sat, 9 Sep 2023 14:33:37 +0900 Subject: [PATCH] lectureGroupBlock .jsx nd shape.jsx into tsx --- ...reGroupBlock.jsx => LectureGroupBlock.tsx} | 33 ++++++++----- ...pBlockRow.jsx => LectureGroupBlockRow.tsx} | 47 +++++++++---------- ...eBlock.jsx => LectureGroupSimpleBlock.tsx} | 16 +++---- ...SimpleBlock.jsx => LectureSimpleBlock.tsx} | 39 ++++++++++----- src/shapes/model/subject/ClasstimeShape.tsx | 13 +++++ src/shapes/model/subject/ExamtimeShape.tsx | 8 ++++ src/shapes/model/subject/LectureType.tsx | 40 ++++++++++++++++ .../model/subject/NestedProfessorShape.tsx | 7 +++ 8 files changed, 146 insertions(+), 57 deletions(-) rename src/components/blocks/{LectureGroupBlock.jsx => LectureGroupBlock.tsx} (55%) rename src/components/blocks/{LectureGroupBlockRow.jsx => LectureGroupBlockRow.tsx} (82%) rename src/components/blocks/{LectureGroupSimpleBlock.jsx => LectureGroupSimpleBlock.tsx} (77%) rename src/components/blocks/{LectureSimpleBlock.jsx => LectureSimpleBlock.tsx} (53%) create mode 100644 src/shapes/model/subject/ClasstimeShape.tsx create mode 100644 src/shapes/model/subject/ExamtimeShape.tsx create mode 100644 src/shapes/model/subject/LectureType.tsx create mode 100644 src/shapes/model/subject/NestedProfessorShape.tsx 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 (