From 422468f1001132d9714171641b1db50f43f07ef6 Mon Sep 17 00:00:00 2001 From: konokono <1845519693@qq.com> Date: Mon, 26 Feb 2024 22:12:33 +0800 Subject: [PATCH] fix: fixed year bugs --- src/pages/Review/Review.tsx | 7 ++++--- .../components/ReviewYear/ReviewYear.tsx | 18 ++++++++++-------- src/utils/GetYearSeason/getReviewYear.ts | 3 ++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/pages/Review/Review.tsx b/src/pages/Review/Review.tsx index 596b713..7ee859c 100644 --- a/src/pages/Review/Review.tsx +++ b/src/pages/Review/Review.tsx @@ -3,20 +3,21 @@ import { useEffect, useState } from 'react'; import { post } from '../../fetch.ts'; import { ReviewList, ReviewRow } from './ReviewList.ts'; import ReviewYear from './components/ReviewYear/ReviewYear.tsx'; -import { Group, ReviewFilter, Season, Year, YearSeason } from './ReviewFitler.ts'; +import { Group, ReviewFilter, Season, YearSeason } from './ReviewFitler.ts'; import ReviewGroupSelect from './components/ReviewGroupSelect/ReviewGroupSelect.tsx'; import ReviewTable from './components/ReviewTable/ReviewTable.tsx'; import { message } from 'antd'; import { useNavigate } from 'react-router-dom'; +import { getCurrentSeason } from '../../utils/GetYearSeason/getReviewYear.ts'; const Review = () => { const [reviewFilter, setReviewFilter] = useState({ grade: '', group: Group.Product, school: '', - season: Season.Autumn, + season: getCurrentSeason(), status: '', - year: Year.Y2023, + year: new Date().getFullYear(), }); const changeYear = (value: YearSeason) => { diff --git a/src/pages/Review/components/ReviewYear/ReviewYear.tsx b/src/pages/Review/components/ReviewYear/ReviewYear.tsx index dd6c291..17fa37c 100644 --- a/src/pages/Review/components/ReviewYear/ReviewYear.tsx +++ b/src/pages/Review/components/ReviewYear/ReviewYear.tsx @@ -28,14 +28,16 @@ const ReviewYear: React.FC = ({ changeYear }) => { return (
- { + handleChange(value as YearSeason); + }} + options={years} + /> + )}
); }; diff --git a/src/utils/GetYearSeason/getReviewYear.ts b/src/utils/GetYearSeason/getReviewYear.ts index 10b0ca3..7e0f196 100644 --- a/src/utils/GetYearSeason/getReviewYear.ts +++ b/src/utils/GetYearSeason/getReviewYear.ts @@ -1,6 +1,7 @@ import { Season } from '../../pages/Review/ReviewFitler.ts'; const getSeason = (month: number) => (month < 9 ? Season.Spring : Season.Autumn); +export const getCurrentSeason = () => getSeason(new Date().getMonth() + 1); const chineseSeasons = { [Season.Spring]: '春招', @@ -13,7 +14,7 @@ const geneYearObject = (year: number, season: Season.Spring | Season.Autumn) => }); export const generateYears = () => { const currentYear = new Date().getFullYear(); - const currentSeason = getSeason(new Date().getMonth() + 1); + const currentSeason = getCurrentSeason(); let years: { value: string; label: string }[] = []; for (let year = 2022; year < currentYear; year++) { years = years.concat([