Skip to content

Commit

Permalink
chore: 修一些 constants 或是參數 (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark86092 authored Dec 6, 2024
1 parent c03a911 commit 8d21f23
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 56 deletions.
3 changes: 1 addition & 2 deletions src/components/CompanyAndJobTitle/IndexPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ import {
pageTypeTranslation,
generatePageURL,
generateIndexURL,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import styles from './CompanyAndJobTitleIndex.module.css';
import { isFetched } from 'utils/fetchBox';
import { formatTitle, formatCanonicalPath } from 'utils/helmetHelper';
import { SITE_NAME } from 'constants/helmetData';

const PAGE_SIZE = 10;

const IndexHelmet = ({ pageType, page }) => {
const title = `所有${pageTypeTranslation[pageType]}資料 - 第${page}頁`;

Expand Down
6 changes: 3 additions & 3 deletions src/components/CompanyAndJobTitle/Overview/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ const Overview = ({

Overview.propTypes = {
averageWeekWorkTime: PropTypes.number.isRequired,
interviewExperiences: PropTypes.arrayOf(PropTypes.object),
interviewExperiences: PropTypes.arrayOf(PropTypes.object).isRequired,
interviewExperiencesCount: PropTypes.number.isRequired,
jobAverageSalaries: PropTypes.array,
overtimeFrequencyCount: PropTypes.object.isRequired,
pageName: PropTypes.string.isRequired,
pageType: PropTypes.string.isRequired,
salaryDistribution: PropTypes.array,
salaryWorkTimes: PropTypes.arrayOf(PropTypes.object),
salaryWorkTimes: PropTypes.arrayOf(PropTypes.object).isRequired,
salaryWorkTimesCount: PropTypes.number.isRequired,
workExperiences: PropTypes.arrayOf(PropTypes.object),
workExperiences: PropTypes.arrayOf(PropTypes.object).isRequired,
workExperiencesCount: PropTypes.number.isRequired,
};

Expand Down
4 changes: 1 addition & 3 deletions src/components/CompanyAndJobTitle/Overview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BoxStatusRenderer } from '../StatusRenderer';
import OverviewSection from './Overview';
import Helmet from './Helmet';

const Overview = ({ pageType, pageName, tabType, overviewBox, page }) => (
const Overview = ({ pageType, pageName, tabType, overviewBox }) => (
<CompanyAndJobTitleWrapper
pageType={pageType}
pageName={pageName}
Expand Down Expand Up @@ -40,7 +40,6 @@ const Overview = ({ pageType, pageName, tabType, overviewBox, page }) => (
jobAverageSalaries={data.jobAverageSalaries}
averageWeekWorkTime={data.averageWeekWorkTime}
overtimeFrequencyCount={data.overtimeFrequencyCount}
page={page}
/>
</Fragment>
);
Expand All @@ -66,7 +65,6 @@ Overview.propTypes = {
error: PropTypes.any,
status: PropTypes.string.isRequired,
}).isRequired,
page: PropTypes.number.isRequired,
pageName: PropTypes.string.isRequired,
pageType: PropTypes.string.isRequired,
tabType: PropTypes.string.isRequired,
Expand Down
7 changes: 3 additions & 4 deletions src/components/CompanyAndJobTitle/TimeAndSalary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const TimeAndSalary = ({
pageName={pageName}
tabType={tabType}
salaryWorkTimes={salaryWorkTimes}
salaryWorkTimeStatistics={salaryWorkTimeStatistics}
page={page}
pageSize={pageSize}
totalCount={totalCount}
Expand All @@ -57,12 +56,12 @@ const TimeAndSalary = ({

TimeAndSalary.propTypes = {
page: PropTypes.number.isRequired,
pageName: PropTypes.string,
pageName: PropTypes.string.isRequired,
pageSize: PropTypes.number.isRequired,
pageType: PropTypes.string,
pageType: PropTypes.string.isRequired,
salaryWorkTimeStatistics: PropTypes.object.isRequired,
salaryWorkTimes: PropTypes.array,
tabType: PropTypes.string,
tabType: PropTypes.string.isRequired,
totalCount: PropTypes.number.isRequired,
};

Expand Down
2 changes: 2 additions & 0 deletions src/constants/companyJobTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,5 @@ export const generateIndexURL = ({ pageType }) =>
generatePath('/:pageTypeURL', {
pageTypeURL: pageTypeURLMap[pageType],
});

export const PAGE_SIZE = 10;
7 changes: 2 additions & 5 deletions src/pages/Company/CompanyIndexProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { querySelector } from 'common/routing/selectors';
import { pageFromQuerySelector } from 'selectors/routing/page';
import CompanyAndJobTitleIndexPage from 'components/CompanyAndJobTitle/IndexPage';
import usePagination from 'components/CompanyAndJobTitle/IndexPage/usePagination';
import { pageType } from 'constants/companyJobTitle';
import { pageType as PAGE_TYPE, PAGE_SIZE } from 'constants/companyJobTitle';
import { fetchCompanyNames } from 'actions/company';
import {
companyIndexesBoxSelectorAtPage,
companiesCountSelector,
} from 'selectors/companyAndJobTitle';

const PAGE_SIZE = 10;

const CompanyIndexProvider = () => {
const [page, getPageLink] = usePagination();
const selector = useMemo(() => companyIndexesBoxSelectorAtPage(page), [page]);
Expand All @@ -27,8 +25,7 @@ const CompanyIndexProvider = () => {
return (
<CompanyAndJobTitleIndexPage
totalCount={totalCount}
pageType={pageType.COMPANY}
status={companyIndexesBox.status}
pageType={PAGE_TYPE.COMPANY}
indexesBox={companyIndexesBox}
page={page}
getPageLink={getPageLink}
Expand Down
10 changes: 6 additions & 4 deletions src/pages/Company/CompanyInterviewExperiencesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import InterviewExperiences from 'components/CompanyAndJobTitle/InterviewExperie
import { paramsSelector, querySelector } from 'common/routing/selectors';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import {
queryCompanyInterviewExperiences,
queryRatingStatistics,
Expand Down Expand Up @@ -39,8 +43,6 @@ const useInterviewExperiencesBox = pageName => {
return useSelector(selector);
};

const PAGE_SIZE = 10;

const CompanyInterviewExperiencesProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.COMPANY;
Expand Down Expand Up @@ -83,7 +85,7 @@ const CompanyInterviewExperiencesProvider = () => {
page={page}
pageSize={PAGE_SIZE}
totalCount={interviewExperiencesCount}
tabType={tabType.INTERVIEW_EXPERIENCE}
tabType={TAB_TYPE.INTERVIEW_EXPERIENCE}
status={status}
interviewExperiences={interviewExperiences}
/>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Company/CompanyOverviewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useCallback, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import Overview from 'components/CompanyAndJobTitle/Overview';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
} from 'constants/companyJobTitle';
import { queryCompanyOverview, queryRatingStatistics } from 'actions/company';
import {
jobAverageSalaries,
Expand Down Expand Up @@ -42,7 +44,6 @@ const CompanyOverviewProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.COMPANY;
const pageName = usePageName();
const page = usePage();

useEffect(() => {
dispatch(queryRatingStatistics(pageName));
Expand All @@ -63,9 +64,8 @@ const CompanyOverviewProvider = () => {
<Overview
pageType={pageType}
pageName={pageName}
tabType={tabType.OVERVIEW}
tabType={TAB_TYPE.OVERVIEW}
overviewBox={overviewBox}
page={page}
/>
);
};
Expand Down
10 changes: 6 additions & 4 deletions src/pages/Company/CompanyTimeAndSalaryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useSelector, useDispatch } from 'react-redux';
import TimeAndSalary from 'components/CompanyAndJobTitle/TimeAndSalary';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import {
queryCompanyTimeAndSalary,
queryCompanyTimeAndSalaryStatistics,
Expand Down Expand Up @@ -52,8 +56,6 @@ const useTimeAndSalaryBox = pageName => {
return useSelector(selector);
};

const PAGE_SIZE = 10;

const CompanyTimeAndSalaryProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.COMPANY;
Expand Down Expand Up @@ -104,7 +106,7 @@ const CompanyTimeAndSalaryProvider = () => {
page={page}
pageSize={PAGE_SIZE}
totalCount={salaryWorkTimesCount}
tabType={tabType.TIME_AND_SALARY}
tabType={TAB_TYPE.TIME_AND_SALARY}
status={status}
salaryWorkTimes={salaryWorkTimes}
salaryWorkTimeStatistics={salaryWorkTimeStatistics}
Expand Down
10 changes: 6 additions & 4 deletions src/pages/Company/CompanyWorkExperiencesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useSelector, useDispatch } from 'react-redux';
import WorkExperiences from 'components/CompanyAndJobTitle/WorkExperiences';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import {
queryCompanyWorkExperiences,
queryRatingStatistics,
Expand Down Expand Up @@ -38,8 +42,6 @@ const useWorkExperiencesBox = pageName => {
return useSelector(selector);
};

const PAGE_SIZE = 10;

const CompanyWorkExperiencesProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.COMPANY;
Expand Down Expand Up @@ -82,7 +84,7 @@ const CompanyWorkExperiencesProvider = () => {
page={page}
pageSize={PAGE_SIZE}
totalCount={workExperiencesCount}
tabType={tabType.WORK_EXPERIENCE}
tabType={TAB_TYPE.WORK_EXPERIENCE}
status={status}
workExperiences={workExperiences}
/>
Expand Down
7 changes: 2 additions & 5 deletions src/pages/JobTitle/JobTitleIndexProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import { querySelector } from 'common/routing/selectors';
import { pageFromQuerySelector } from 'selectors/routing/page';
import CompanyAndJobTitleIndexPage from 'components/CompanyAndJobTitle/IndexPage';
import usePagination from 'components/CompanyAndJobTitle/IndexPage/usePagination';
import { pageType } from 'constants/companyJobTitle';
import { pageType as PAGE_TYPE, PAGE_SIZE } from 'constants/companyJobTitle';
import { fetchJobTitles } from 'actions/jobTitle';
import {
jobTitleIndexesBoxSelectorAtPage,
jobTitlesCountSelector,
} from 'selectors/companyAndJobTitle';

const PAGE_SIZE = 10;

const JobTitleIndexProvider = () => {
const [page, getPageLink] = usePagination();
const selector = useMemo(() => jobTitleIndexesBoxSelectorAtPage(page), [
Expand All @@ -29,8 +27,7 @@ const JobTitleIndexProvider = () => {
return (
<CompanyAndJobTitleIndexPage
totalCount={totalCount}
pageType={pageType.JOB_TITLE}
status={jobTitleIndexesBox.status}
pageType={PAGE_TYPE.JOB_TITLE}
indexesBox={jobTitleIndexesBox}
page={page}
getPageLink={getPageLink}
Expand Down
10 changes: 6 additions & 4 deletions src/pages/JobTitle/JobTitleInterviewExperiencesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useSelector, useDispatch } from 'react-redux';
import InterviewExperiences from 'components/CompanyAndJobTitle/InterviewExperiences';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import { queryJobTitleInterviewExperiences } from 'actions/jobTitle';
import {
interviewExperiences as interviewExperiencesSelector,
Expand Down Expand Up @@ -37,8 +41,6 @@ const useInterviewExperiencesBox = pageName => {
return useSelector(selector);
};

const PAGE_SIZE = 10;

const JobTitleTimeAndSalaryProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.JOB_TITLE;
Expand Down Expand Up @@ -77,7 +79,7 @@ const JobTitleTimeAndSalaryProvider = () => {
page={page}
pageSize={PAGE_SIZE}
totalCount={interviewExperiencesCount}
tabType={tabType.INTERVIEW_EXPERIENCE}
tabType={TAB_TYPE.INTERVIEW_EXPERIENCE}
status={status}
interviewExperiences={interviewExperiences}
/>
Expand Down
10 changes: 5 additions & 5 deletions src/pages/JobTitle/JobTitleOverviewProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { useCallback, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import Overview from 'components/CompanyAndJobTitle/Overview';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
} from 'constants/companyJobTitle';
import { queryJobTitleOverview } from 'actions/jobTitle';
import {
salaryDistribution,
Expand Down Expand Up @@ -42,7 +44,6 @@ const JobTitleOverviewProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.JOB_TITLE;
const pageName = usePageName();
const page = usePage();

useEffect(() => {
dispatch(queryJobTitleOverview(pageName));
Expand All @@ -59,9 +60,8 @@ const JobTitleOverviewProvider = () => {
<Overview
pageType={pageType}
pageName={pageName}
tabType={tabType.OVERVIEW}
tabType={TAB_TYPE.OVERVIEW}
overviewBox={overviewBox}
page={page}
/>
);
};
Expand Down
10 changes: 6 additions & 4 deletions src/pages/JobTitle/JobTitleTimeAndSalaryProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useSelector, useDispatch } from 'react-redux';
import TimeAndSalary from 'components/CompanyAndJobTitle/TimeAndSalary';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import {
queryJobTitleTimeAndSalary,
queryJobTitleTimeAndSalaryStatistics,
Expand Down Expand Up @@ -54,8 +58,6 @@ const useTimeAndSalaryBox = pageName => {
return useSelector(selector);
};

const PAGE_SIZE = 10;

const JobTitleTimeAndSalaryProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.JOB_TITLE;
Expand Down Expand Up @@ -102,7 +104,7 @@ const JobTitleTimeAndSalaryProvider = () => {
page={page}
pageSize={PAGE_SIZE}
totalCount={salaryWorkTimesCount}
tabType={tabType.TIME_AND_SALARY}
tabType={TAB_TYPE.TIME_AND_SALARY}
status={status}
salaryWorkTimes={salaryWorkTimes}
salaryWorkTimeStatistics={salaryWorkTimeStatistics}
Expand Down
10 changes: 6 additions & 4 deletions src/pages/JobTitle/JobTitleWorkExperiencesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { useSelector, useDispatch } from 'react-redux';
import WorkExperiences from 'components/CompanyAndJobTitle/WorkExperiences';
import usePermission from 'hooks/usePermission';
import { usePage } from 'hooks/routing/page';
import { tabType, pageType as PAGE_TYPE } from 'constants/companyJobTitle';
import {
tabType as TAB_TYPE,
pageType as PAGE_TYPE,
PAGE_SIZE,
} from 'constants/companyJobTitle';
import { queryJobTitleWorkExperiences } from 'actions/jobTitle';
import {
workExperiences as workExperiencesSelector,
Expand Down Expand Up @@ -35,8 +39,6 @@ const useWorkExperiencesBox = pageName => {
return useSelector(selector);
};

const PAGE_SIZE = 10;

const JobTitleWorkExperiencesProvider = () => {
const dispatch = useDispatch();
const pageType = PAGE_TYPE.JOB_TITLE;
Expand Down Expand Up @@ -75,7 +77,7 @@ const JobTitleWorkExperiencesProvider = () => {
page={page}
pageSize={PAGE_SIZE}
totalCount={workExperiencesCount}
tabType={tabType.WORK_EXPERIENCE}
tabType={TAB_TYPE.WORK_EXPERIENCE}
status={status}
workExperiences={workExperiences}
/>
Expand Down

0 comments on commit 8d21f23

Please sign in to comment.