Skip to content

Commit

Permalink
Merge pull request #89 from YIMSEBIN/Weekly
Browse files Browse the repository at this point in the history
Feat: i18n ๋ฒˆ์—ญ ๋ฐ์ดํ„ฐ ์ž‘์„ฑ, ํด๋” ๋ฐ ์ฝ”๋“œ ๊ตฌ์กฐ ๋ฆฌํŒฉํ† ๋ง
  • Loading branch information
YIMSEBIN authored Nov 1, 2024
2 parents c4383b3 + 17c16c9 commit 11e6f78
Show file tree
Hide file tree
Showing 31 changed files with 435 additions and 256 deletions.
13 changes: 8 additions & 5 deletions src/apis/apiPath.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
const BASE_URL = '/api';

export const APIPath = {
postNotice: '/api/recruitments',
allApplication: '/api/application/all',
signEmployeeContract: '/api/contract',
makeEmployerContract: '/api/categories',
downloadContract: '/api/contract/:applyId/download',
postNotice: `${BASE_URL}/recruitments`,
allApplication: `${BASE_URL}/application/all`,
signEmployeeContract: `${BASE_URL}/contract/employee`,
makeContract: `${BASE_URL}/contract`,
getContract: `${BASE_URL}/contract/:applyId`,
downloadContract: `${BASE_URL}/contract/:applyId/download`,
registerSign: '/api/sign',
getMyCompanies: `${BASE_URL}/company`,
getMyRecruitments: `${BASE_URL}/recruitments/company/:companyId`,
getMyApplicants: `${BASE_URL}/application/:recruitmentId`,
getForeigner: `${BASE_URL}/visa/:userId`,
registerVisa: `${BASE_URL}/visa`,
registerCompany: `${BASE_URL}/company`,
apply: '/api/application/',
recruitmentsDetail: '/api/recruitments/:postId',
};

export const getDynamicAPIPath = {
downloadContract: (applyId: number) => APIPath.downloadContract.replace(':applyId', applyId.toString()),
getContract: (applyId: number) => APIPath.getContract.replace(':applyId', applyId.toString()),
getMyRecruitments: (companyId: number) => APIPath.getMyRecruitments.replace(':companyId', companyId.toString()),
getMyApplicants: (recruitmentId: number) =>
APIPath.getMyApplicants.replace(':recruitmentId', recruitmentId.toString()),
Expand Down
15 changes: 15 additions & 0 deletions src/apis/contract/hooks/useGetMyContract.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getDynamicAPIPath } from '@/apis/apiPath';
import { clientInstance } from '@/apis/instance';
import { useQuery } from '@tanstack/react-query';

export const getMyContractPath = (applyId: number) => `${getDynamicAPIPath.getContract(applyId)}`;
const getMyContract = async (applyId: number) => {
const res = await clientInstance.get(getMyContractPath(applyId));
return res.data;
};

export const useGetMyContract = (applyId: number) =>
useQuery({
queryKey: [getMyContractPath],
queryFn: () => getMyContract(applyId),
});
26 changes: 26 additions & 0 deletions src/apis/contract/hooks/usePostContract.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { APIPath } from '@/apis/apiPath';
import { clientInstance } from '@/apis/instance';
import { useMutation } from '@tanstack/react-query';

export type ContractRequestData = {
salary?: string;
workingHours?: string;
dayOff?: string;
annualPaidLeave?: string;
workingPlace?: string;
responsibilities?: string;
rule?: string;
applyId?: number;
};

export const getPostContractPath = () => `${APIPath.makeContract}`;

export const postContract = async (req: ContractRequestData) => {
const response = await clientInstance.post(getPostContractPath(), req);
return response.data;
};

export const useFetchPostContract = () =>
useMutation({
mutationFn: postContract,
});
19 changes: 19 additions & 0 deletions src/apis/contract/hooks/usePostEmployeeSign.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { APIPath } from '@/apis/apiPath';
import { clientInstance } from '@/apis/instance';
import { useMutation } from '@tanstack/react-query';

export type SignEmployeeContractRequestData = {
applyId?: number;
};

export const getPostSignEmployeeContractPath = () => `${APIPath.signEmployeeContract}`;

export const postSignEmployeeContract = async (req: SignEmployeeContractRequestData) => {
const response = await clientInstance.post(getPostSignEmployeeContractPath(), req);
return response.data;
};

export const useFetchPostContract = () =>
useMutation({
mutationFn: postSignEmployeeContract,
});
28 changes: 28 additions & 0 deletions src/apis/contract/mock/contract.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { http, HttpResponse } from 'msw';
import { getPostContractPath } from '../hooks/usePostContract';
import { getMyContractPath } from '../hooks/useGetMyContract';
import { getPostSignEmployeeContractPath } from '../hooks/usePostEmployeeSign';

export const contractsMockHandler = [
http.post(getPostContractPath(), async ({ request }) => {
const req = await request.json();
return HttpResponse.json(req, { status: 201 });
}),

http.get(getMyContractPath(1), () => HttpResponse.json(CONTRACT_DATA)),

http.post(getPostSignEmployeeContractPath(), async ({ request }) => {
const req = await request.json();
return HttpResponse.json(req, { status: 201 });
}),
];

const CONTRACT_DATA = {
salary: '์›” 2๋ฐฑ๋งŒ์›',
workingHours: '์›”ํ™”์ˆ˜ 10:00 ~ 15:00, ๋ชฉ๊ธˆ 12:00 ~ 16:00',
dayOff: '๋งค์›” ๋งˆ์ง€๋ง‰์ฃผ ํ™”์š”์ผ',
annualPaidLeave: 'ํ†ต์ƒ๊ทผ๋กœ์ž์˜ ๊ทผ๋กœ์‹œ๊ฐ„์— ๋น„๋ก€ํ•˜์—ฌ ์—ฐ์ฐจ์œ ๊ธ‰ํœด๊ฐ€๋ฅผ ๋ถ€์—ฌํ•œ๋‹ค.',
workingPlace: '๋Œ€์ „ ์œ ์„ฑ๊ตฌ ๊ถ๋™ ๋Œ€ํ•™๋กœ99',
responsibilities: '๊ฐœ๋ฐœํ•˜๊ธฐ',
rule: '์—ด์‹ฌํžˆ ์ผํ•˜๊ธฐ!',
};
2 changes: 1 addition & 1 deletion src/apis/employee/mock/getMyApplication.mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { http, HttpResponse } from 'msw';
import { getMyApplicationPath } from '../hooks/useGetMyApplication';
import { myRecruitList } from '@/pages/employee/myPage/data/index.mock';
import { myRecruitList } from '@/pages/myPage/employee/data/index.mock';

export const EmployeePageMockHandler = [
http.get(getMyApplicationPath(), () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const postNotice = async (req: NoticeRequestData) => {
return response.data;
};

export const FetchPostNotice = () =>
export const useFetchPostNotice = () =>
useMutation({
mutationFn: postNotice,
});
9 changes: 9 additions & 0 deletions src/apis/registerCompany/registerCompany.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { http, HttpResponse } from 'msw';
import { getPostCompanyPath } from './useRegisterCompany';

export const registerCompanyMockHandler = [
http.post(getPostCompanyPath(), async ({ request }) => {
const req = await request.json();
return HttpResponse.json(req, { status: 201 });
}),
];
23 changes: 23 additions & 0 deletions src/apis/registerCompany/useRegisterCompany.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { APIPath } from '@/apis/apiPath';
import { clientInstance } from '@/apis/instance';
import { useMutation } from '@tanstack/react-query';

export type CompanyRequestData = {
name?: string;
industryOccupation?: string;
brand?: string;
revenuePerYear?: number;
logoImage?: string;
};

export const getPostCompanyPath = () => `${APIPath.registerCompany}`;

export const postCompany = async (req: CompanyRequestData) => {
const response = await clientInstance.post(getPostCompanyPath(), req);
return response.data;
};

export const useFetchPostCompany = () =>
useMutation({
mutationFn: postCompany,
});
7 changes: 7 additions & 0 deletions src/assets/translator/EmployeeMyPage/ko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const EmployeeMyPage = {
UPDATE_PROFILE: 'ํ”„๋กœํ•„ ์ˆ˜์ •ํ•˜๊ธฐ',
REGISTER_RESUME: '์ด๋ ฅ์„œ ๋“ฑ๋กํ•˜๊ธฐ',
REGISTER_SIGN: '์‚ฌ์ธ ๋“ฑ๋ก',
REGISTER_VISA: '์™ธ๊ตญ์ธ ๋ฒˆํ˜ธ ๋ฐ ๋น„์ž ๋ฐœ๊ธ‰ ์ผ์ž ๋“ฑ๋ก',
MYRECRUITLIST: '๋‚ด๊ฐ€ ์ง€์›ํ•œ ๊ณต๊ณ ',
};
7 changes: 7 additions & 0 deletions src/assets/translator/EmployeeMyPage/ve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const EmployeeMyPage = {
UPDATE_PROFILE: 'Cแบญp nhแบญt hแป“ sฦก',
REGISTER_RESUME: 'ฤฤƒng kรฝ hแป“ sฦก',
REGISTER_SIGN: 'ฤฤƒng kรฝ chแปฏ kรฝ',
REGISTER_VISA: 'ฤฤƒng kรฝ sแป‘ ngฦฐแปi nฦฐแป›c ngoร i vร  ngร y cแบฅp visa',
MYRECRUITLIST: 'Cรดng viแป‡c tรดi ฤ‘รฃ แปฉng tuyแปƒn',
};
11 changes: 11 additions & 0 deletions src/assets/translator/PostNotice/ko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const PostNotice = {
TITLE: '๊ตฌ์ธ ๊ธ€ ๋“ฑ๋กํ•˜๊ธฐ',
SALARY: '๊ธ‰์—ฌ',
WORKINGDURATION: '๊ทผ๋ฌด๊ธฐ๊ฐ„',
WORKDAYS: '๊ทผ๋ฌด์š”์ผ',
WORKHOURS: '๊ทผ๋ฌด์‹œ๊ฐ„',
WORKTYPE: '๊ณ ์šฉํ˜•ํƒœ',
ELIGIBILITY_CRITERIA: '๋น„์ž์กฐ๊ฑด',
PREFERRED_CONDITIONS: '์šฐ๋Œ€์‚ฌํ•ญ',
SUBMIT: '๋“ฑ๋กํ•˜๊ธฐ',
};
11 changes: 11 additions & 0 deletions src/assets/translator/PostNotice/ve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const PostNotice = {
TITLE: 'ฤฤƒng bร i tuyแปƒn dแปฅng',
SALARY: 'Lฦฐฦกng',
WORKINGDURATION: 'Thแปi gian lร m viแป‡c',
WORKDAYS: 'Ngร y lร m viแป‡c',
WORKHOURS: 'Giแป lร m viแป‡c',
WORKTYPE: 'Hรฌnh thแปฉc lร m viแป‡c',
ELIGIBILITY_CRITERIA: 'ฤiแปu kiแป‡n visa',
PREFERRED_CONDITIONS: 'ฦฏu tiรชn',
SUBMIT: 'ฤฤƒng',
};
9 changes: 9 additions & 0 deletions src/assets/translator/RegisterCompany/ko.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const RegisterCompany = {
TITLE: 'ํšŒ์‚ฌ ๋“ฑ๋ก',
LOGOIMAGE: 'ํšŒ์‚ฌ ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ(์„ ํƒ)',
COMPANYNAME: 'ํšŒ์‚ฌ๋ช…',
INDUSTRY_OCCUPATION: '์—…์ง์ข…',
BRAND: '๋ธŒ๋žœ๋“œ',
REVENUE_PERYEAR: '์—ฐ ํ‰๊ท  ๋งค์ถœ์•ก',
SUBMIT: '๋“ฑ๋กํ•˜๊ธฐ',
};
9 changes: 9 additions & 0 deletions src/assets/translator/RegisterCompany/ve.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const RegisterCompany = {
TITLE: 'ฤฤƒng kรฝ cรดng ty',
LOGOIMAGE: 'Tแบฃi lรชn logo cรดng ty (tรนy chแปn)',
COMPANYNAME: 'Tรชn cรดng ty',
INDUSTRY_OCCUPATION: 'Ngร nh nghแป',
BRAND: 'Thฦฐฦกng hiแป‡u',
REVENUE_PERYEAR: 'Doanh thu hร ng nฤƒm',
SUBMIT: 'ฤฤƒng kรฝ',
};
7 changes: 4 additions & 3 deletions src/features/employee/myPage/CardButton.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Button } from '@/components/common';
import { ReactNode } from 'react';
import React, { ReactNode } from 'react';

type Props = {
design?: 'default' | 'outlined' | 'textbutton' | 'deactivate';
children: ReactNode;
};
} & React.ButtonHTMLAttributes<HTMLButtonElement>;

export default function CardButton({ design, children }: Props) {
export default function CardButton({ design, children, ...rest }: Props) {
return (
<Button
design={design}
Expand All @@ -17,6 +17,7 @@ export default function CardButton({ design, children }: Props) {
justifyContent: 'space-between',
padding: '10px 20px',
}}
{...rest}
>
{children}
</Button>
Expand Down
29 changes: 20 additions & 9 deletions src/features/employee/myPage/MyRecruitCard.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import { Card, Image, Typo, Button } from '@/components/common';
import styled from '@emotion/styled';
import { MyRecruitListProps, StateProps } from '@/types';
import { MyRecruitListProps, StateProps, TextProps } from '@/types';
import { useNavigate } from 'react-router-dom';
import ROUTE_PATH from '@/routes/path';

type DesignProps = {
design: 'default' | 'outlined' | 'textbutton' | 'deactivate';
text: string;
text?: TextProps;
};

function getStateStyle(state: StateProps): DesignProps {
switch (state) {
case '๊ทผ๋กœ๊ณ„์•ฝ์„œ ์„œ๋ช…ํ•˜๊ธฐ':
case 'LetsSign':
return { design: 'default', text: '๊ทผ๋กœ๊ณ„์•ฝ์„œ ์„œ๋ช…ํ•˜๊ธฐ' };
case '์ฑ„์šฉ ๋งˆ๊ฐ':
case 'Closed':
return { design: 'deactivate', text: '์ฑ„์šฉ ๋งˆ๊ฐ' };
case '์ง€์›์„œ ๊ฒ€ํ† ์ค‘':
case 'Waiting':
return { design: 'outlined', text: '์ง€์›์„œ ๊ฒ€ํ† ์ค‘' };
case '์ฑ„์šฉ ์™„๋ฃŒ':
case 'Completed':
return { design: 'deactivate', text: '์ฑ„์šฉ ์™„๋ฃŒ' };
default:
return { design: 'deactivate', text: '์•Œ ์ˆ˜ ์—†์Œ' }; // ์ƒํƒœ๊ฐ€ ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ
return { design: 'deactivate' }; // ์ƒํƒœ๊ฐ€ ์ •์˜๋˜์ง€ ์•Š์€ ๊ฒฝ์šฐ
}
}

Expand All @@ -27,8 +29,9 @@ type Props = {
};

export default function MyRecruitCard({ myRecruit }: Props) {
const { image, title, area, state } = myRecruit;
const { image, title, area, state, applyId } = myRecruit;
const buttonStyle = getStateStyle(state);
const navigate = useNavigate();

return (
<Card
Expand Down Expand Up @@ -57,7 +60,15 @@ export default function MyRecruitCard({ myRecruit }: Props) {
</Typo>
<Typo size="14px">{area}</Typo>
</TextSection>
<Button design={buttonStyle.design} style={{ width: '200px', padding: '10px 20px' }}>
<Button
design={buttonStyle.design}
style={{ width: '200px', padding: '10px 20px' }}
onClick={() => {
if (state == 'LetsSign') {
navigate(ROUTE_PATH.CONTRACT.EMPLOYEE.replace(':applyId', applyId.toString()));
}
}}
>
{buttonStyle.text}
</Button>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion src/features/employee/myPage/MyRecruitList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function MyRecruitList({ myRecruitList }: Props) {
return (
<List
items={myRecruitList}
renderItem={(myRecruit) => <MyRecruitCard myRecruit={myRecruit} key={myRecruit.id} />}
renderItem={(myRecruit) => <MyRecruitCard myRecruit={myRecruit} key={myRecruit.applyId} />}
/>
);
}
6 changes: 5 additions & 1 deletion src/mocks/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { recruitmentsMockHandler } from '@/apis/home/mocks/recruitmentsMockHandler';
import { slidesMockHandler } from '@/apis/home/mocks/slidesMockHandler';
import { EmployeePageMockHandler } from '@/apis/employee/mock/getMyApplication.mock';
import { noticesMockHandler } from '@/apis/employer/mock/postNotice.mock';
import { noticesMockHandler } from '@/apis/postNotice/mock/postNotice.mock';
import { registerSignMockHandler } from '@/apis/registerSign/registerSign.mock';
import { myCompaniesMockHandler } from '@/apis/companies/mocks/myCompaniesMockHandler';
import { myRecruitmentsMockHandler } from '@/apis/recruitments/mocks/myRecruitmentsMockHandler';
Expand All @@ -10,6 +10,8 @@ import { foreignerMockHandler } from '@/apis/applicants/mocks/foreignerMockHandl
import { visaMockHandler } from '@/apis/applicants/mocks/visaMockHandler';
import { postApplyMockHandler } from '@apis/apply/postApply.mock';
import { recruitmentsDetailMockHandler } from '@apis/recruitmentsDetail/recruitmentsDetailMockHandler';
import { registerCompanyMockHandler } from '@/apis/registerCompany/registerCompany.mock';
import { contractsMockHandler } from '@/apis/contract/mock/contract.mock';

export const handlers = [
...recruitmentsMockHandler,
Expand All @@ -24,4 +26,6 @@ export const handlers = [
...visaMockHandler,
...postApplyMockHandler,
...recruitmentsDetailMockHandler,
...registerCompanyMockHandler,
...contractsMockHandler,
];
Loading

0 comments on commit 11e6f78

Please sign in to comment.