Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 회사등록 이미지입력 및 근로자 마이페이지버튼 status 수정 #138

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/apis/employee/mock/myApplicationList.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const myApplicationList: MyRecruitListProps[] = [
'https://img.freepik.com/free-photo/low-angle-view-of-skyscrapers_1359-1105.jpg?size=626&ext=jpg&ga=GA1.1.1297763733.1727740800&semt=ais_hybrid',
title: '제목',
area: '대전광역시 유성구',
state: 'SIGNING_EMPLOYMENT_CONTRACT',
status: '근로계약서 서명하기',
applyId: 1,
},
{
Expand All @@ -16,7 +16,7 @@ export const myApplicationList: MyRecruitListProps[] = [
'https://img.freepik.com/free-photo/low-angle-view-of-skyscrapers_1359-1105.jpg?size=626&ext=jpg&ga=GA1.1.1297763733.1727740800&semt=ais_hybrid',
title: '제목2',
area: '대전광역시 유성구',
state: 'HIRING_CLOSED',
status: '채용마감',
applyId: 2,
},
{
Expand All @@ -25,7 +25,7 @@ export const myApplicationList: MyRecruitListProps[] = [
'https://img.freepik.com/free-photo/low-angle-view-of-skyscrapers_1359-1105.jpg?size=626&ext=jpg&ga=GA1.1.1297763733.1727740800&semt=ais_hybrid',
title: '제목3',
area: '대전광역시 유성구',
state: 'REVIEWING_APPLICATION',
status: '지원서 검토중',
applyId: 3,
},
{
Expand All @@ -34,7 +34,7 @@ export const myApplicationList: MyRecruitListProps[] = [
'https://img.freepik.com/free-photo/low-angle-view-of-skyscrapers_1359-1105.jpg?size=626&ext=jpg&ga=GA1.1.1297763733.1727740800&semt=ais_hybrid',
title: '제목4',
area: '대전광역시 유성구',
state: 'HIRED',
status: '채용완료',
applyId: 4,
},
];
2 changes: 1 addition & 1 deletion src/apis/registerCompany/mocks/registerCompany.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getPostCompanyPath } from '../hooks/useRegisterCompany';

export const registerCompanyMockHandler = [
http.post(getPostCompanyPath(), async ({ request }) => {
const req = await request.json();
const req = await request.formData();
return HttpResponse.json(req, { status: 201 });
}),
];
25 changes: 13 additions & 12 deletions src/features/employee/myPage/MyRecruitCard.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { Card, Image, Typo, Button } from '@/components/common';
import styled from '@emotion/styled';
import { MyRecruitListProps, StateProps, TextProps } from '@/types';
import { MyRecruitListProps, StateProps } from '@/types';
import { useNavigate } from 'react-router-dom';
import ROUTE_PATH from '@/routes/path';
import { useGetContractImg } from '@/apis/contract/hooks/useGetContractImg';
import React from 'react';

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

function getStateStyle(state: StateProps): DesignProps {
switch (state) {
case 'SIGNING_EMPLOYMENT_CONTRACT':
function getStateStyle(status: StateProps): DesignProps {
switch (status) {
case '근로계약서 서명하기':
return { design: 'default', text: '근로계약서 서명하기' };
case 'HIRING_CLOSED':
case '채용마감':
return { design: 'deactivate', text: '채용 마감' };
case 'REVIEWING_APPLICATION':
case '지원서 검토중':
return {
design: 'deactivate',
text: '지원서 검토중',
style: { backgroundColor: '#fff', border: '3px solid #9A9A9A' },
};
case 'HIRED':
case '채용완료':
return { design: 'outlined', text: '근로계약서 다운로드' };
default:
return { design: 'deactivate' }; // 상태가 정의되지 않은 경우
Expand All @@ -41,9 +41,10 @@ type DownloadContractProps = {
};

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

// 근로계약서 이미지 다운로드
const downloadContract = () => {
const { data: imgURLs } = useGetContractImg(applyId);
Expand Down Expand Up @@ -87,9 +88,9 @@ export default function MyRecruitCard({ myRecruit }: Props) {
design={buttonStyle.design}
style={{ width: '200px', padding: '10px 20px', ...buttonStyle.style }}
onClick={() => {
if (state == 'SIGNING_EMPLOYMENT_CONTRACT') {
if (status == '근로계약서 서명하기') {
navigate(ROUTE_PATH.CONTRACT.EMPLOYEE.replace(':applyId', applyId.toString()));
} else if (state == 'HIRED') {
} else if (status == '채용완료') {
downloadContract();
}
}}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/registerCompany/RegisterCompany.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default function RegisterCompany() {
if (!industryOccupation) newErrors.industryOccupation = '산업/직종을 입력해주세요.';
if (!brand) newErrors.brand = '브랜드명을 입력해주세요.';
if (!revenuePerYear) newErrors.revenuePerYear = '연 매출을 입력해주세요.';
if (!file) newErrors.logoImage = '로고 이미지를 업로드해주세요.';

setErrors(newErrors);

Expand All @@ -91,7 +90,10 @@ export default function RegisterCompany() {

if (file) {
formData.append('logoImage', file);
} else {
formData.append('logoImage', '');
}

mutation.mutate(formData, {
onSuccess: () => {
navigate(ROUTE_PATH.HOME);
Expand Down
13 changes: 2 additions & 11 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,14 @@ export type UserData = {
name: string;
};

// 백엔드에서 정하는 값에 따라 key 바꾸면 됨
export const State = {
SIGNING_EMPLOYMENT_CONTRACT: '근로계약서 서명하기',
HIRING_CLOSED: '채용 마감',
REVIEWING_APPLICATION: '지원서 검토중',
HIRED: '근로계약서 다운로드',
} as const;

export type StateProps = keyof typeof State;
export type TextProps = (typeof State)[StateProps];
export type StateProps = '근로계약서 서명하기' | '채용마감' | '지원서 검토중' | '채용완료';

export type MyRecruitListProps = {
id: number;
title: string;
area: string;
image: string;
state: StateProps;
status: StateProps;
applyId: number;
};

Expand Down
Loading