Skip to content

Commit

Permalink
fix: fixed year bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
konodioda727 committed Feb 26, 2024
1 parent a8a65d7 commit 422468f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/pages/Review/Review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReviewFilter>({
grade: '',
group: Group.Product,
school: '',
season: Season.Autumn,
season: getCurrentSeason(),
status: '',
year: Year.Y2023,
year: new Date().getFullYear(),
});

const changeYear = (value: YearSeason) => {
Expand Down
18 changes: 10 additions & 8 deletions src/pages/Review/components/ReviewYear/ReviewYear.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ const ReviewYear: React.FC<ReviewYearProps> = ({ changeYear }) => {

return (
<div className="reviewYear">
<Select
defaultValue="2023年秋招"
style={{ width: '80%' }}
onSelect={(value: string) => {
handleChange(value as YearSeason);
}}
options={years}
/>
{years && (
<Select
defaultValue={years[years.length - 1].label}
style={{ width: '80%' }}
onSelect={(value: string) => {
handleChange(value as YearSeason);
}}
options={years}
/>
)}
</div>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/utils/GetYearSeason/getReviewYear.ts
Original file line number Diff line number Diff line change
@@ -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]: '春招',
Expand All @@ -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([
Expand Down

0 comments on commit 422468f

Please sign in to comment.