Skip to content

Commit 236973e

Browse files
authored
Merge pull request #172 from D3vPals/feat/#148
2 parents e0c016e + 495ddbc commit 236973e

File tree

19 files changed

+212
-164
lines changed

19 files changed

+212
-164
lines changed

src/api/joinProject.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const getProjectData = async (
1010
return response.data;
1111
};
1212

13-
export const createProject = async (formData: FormData) => {
13+
export const postProject = async (formData: FormData) => {
1414
const response = await httpClient.post(`/project`, formData);
1515
return response.status;
1616
};

src/components/applyComponents/careersComponent/CareersComponent.styled.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const CareerContainer = styled.div`
1111
width: 100%;
1212
margin-bottom: 10px;
1313
14-
@media (max-width: 963px) {
14+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
1515
flex-direction: column;
1616
gap: 10px;
1717
}

src/components/applyComponents/careersComponent/careersInputComponent/CareersComponentInput.styled.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const dateStyle = css`
1313
export const CareerInput = styled.input`
1414
${basicStyle}
1515
padding: 10px;
16-
font-size: 18px;
16+
font-size: 16px;
1717
1818
&:focus {
1919
outline: none;
@@ -40,18 +40,19 @@ export const CareerInput = styled.input`
4040
font-size: ${({ theme }) => theme.heading.small.fontSize};
4141
}
4242
43-
@media (max-width: 963px) {
44-
width: 100%;
43+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
4544
flex: 1;
4645
margin-bottom: 10px;
4746
4847
&:nth-child(1),
4948
&:nth-child(4) {
49+
width: 60%;
5050
flex: 1;
5151
}
5252
5353
&:nth-child(2),
5454
&:nth-child(3) {
55+
width: 20%;
5556
flex: 1;
5657
}
5758
}

src/components/applyComponents/phoneComponent/PhoneComponent.styled.ts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,6 @@ export const PhoneInputContainer = styled.div`
88
position: relative;
99
`;
1010

11-
export const PhoneInput = styled.input<{ name: string }>`
12-
width: 60px;
13-
padding: 10px;
14-
border: 1px solid ${({ theme }) => theme.color.border};
15-
border-radius: ${({ theme }) => theme.borderRadius.primary};
16-
text-align: center;
17-
font-size: 18px;
18-
19-
&:focus {
20-
outline: none;
21-
border-color: #888;
22-
}
23-
`;
24-
2511
export const Dash = styled.span`
2612
align-self: center;
2713
font-size: 25px;
@@ -30,7 +16,7 @@ export const Dash = styled.span`
3016

3117
export const FormError = styled.p`
3218
margin-top: 0.3px;
33-
font-size: 1rem;
19+
font-size: 0.9rem;
3420
color: ${({ theme }) => theme.color.red};
3521
position: absolute;
3622
top: 115%;

src/components/applyComponents/phoneComponent/phoneComponentInput/PhoneComponentInput.styled.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,9 @@ export const PhoneInput = styled.input`
66
border: 1px solid ${({ theme }) => theme.color.border};
77
border-radius: ${({ theme }) => theme.borderRadius.primary};
88
text-align: center;
9-
font-size: 19px;
9+
font-size: 17px;
1010
11-
&:focus {
12-
outline: none;
13-
border-color: #888;
11+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
12+
font-size: 15px;
1413
}
1514
`;
16-
17-
export const FormError = styled.p`
18-
margin-top: 0.3px;
19-
font-size: 1rem;
20-
color: ${({ theme }) => theme.color.red};
21-
position: absolute;
22-
top: 100%;
23-
left: 0;
24-
white-space: nowrap;
25-
`;

src/components/common/modal/Modal.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
import { useRef, useState } from 'react';
1+
import { useState } from 'react';
22
import { createPortal } from 'react-dom';
33
import { XMarkIcon, CheckCircleIcon } from '@heroicons/react/24/outline';
44
import * as S from './Modal.styled';
55
import ScrollPreventor from './ScrollPreventor';
6+
import { useOutsideClick } from '../../../hooks/useOutsideClick';
7+
68
interface ModalProps {
79
children: React.ReactNode;
810
isOpen: boolean;
911
onClose: () => void;
1012
}
1113

1214
const Modal = ({ children, isOpen, onClose }: ModalProps) => {
13-
const modalRef = useRef<HTMLDivElement | null>(null);
15+
const modalRefs = useOutsideClick(() => handleClose());
1416
const [isFadingOut, setIsFadingOut] = useState(false);
1517

1618
const handleClose = () => {
1719
setIsFadingOut(true);
1820
};
1921

20-
const handleOverlayClick = (e: React.MouseEvent) => {
21-
if (modalRef.current && !modalRef.current.contains(e.target as Node)) {
22-
handleClose();
23-
}
24-
};
25-
2622
const handleAnimationEnd = () => {
2723
if (isFadingOut) {
2824
onClose();
@@ -36,10 +32,9 @@ const Modal = ({ children, isOpen, onClose }: ModalProps) => {
3632
<ScrollPreventor>
3733
<S.ModalContainer
3834
className={isFadingOut ? 'fade-out' : 'fade-in'}
39-
onClick={handleOverlayClick}
4035
onAnimationEnd={handleAnimationEnd}
4136
>
42-
<S.ModalBody ref={modalRef}>
37+
<S.ModalBody ref={modalRefs}>
4338
<S.ModalCloseButton onClick={handleClose}>
4439
<XMarkIcon />
4540
</S.ModalCloseButton>

src/components/projectFormComponents/inputComponent/inputComponent.styled.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const InputStyle = styled.input<{ type?: string }>`
1010
padding: 10px;
1111
border: 1px solid ${({ theme }) => theme.color.border};
1212
border-radius: ${({ theme }) => theme.borderRadius.primary};
13-
font-size: ${({ theme }) => theme.heading.semiSmall.fontSize};
13+
font-size: ${({ theme }) => theme.heading.small.fontSize};
1414
1515
${({ type }) => {
1616
switch (type) {
@@ -24,7 +24,6 @@ export const InputStyle = styled.input<{ type?: string }>`
2424
flex: 0.1;
2525
background-color: #ffffff;
2626
color: #aaa;
27-
font-family: 'Arial', sans-serif;
2827
2928
&::placeholder {
3029
color: #aaa;
@@ -74,7 +73,7 @@ export const InputInfoStyle = styled.input<{ type?: string }>`
7473

7574
export const FormError = styled.p`
7675
margin-top: 0.3px;
77-
font-size: 1rem;
76+
font-size: 0.9rem;
7877
color: ${({ theme }) => theme.color.red};
7978
position: absolute;
8079
top: 115%;

src/components/projectFormComponents/projectInformationText/ProjectInformation.styled.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const SectionInput = styled.div`
66
flex-direction: column;
77
gap: 1px;
88
9-
@media (max-width: 1024px) {
9+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
1010
margin-bottom: 25px;
1111
}
1212
`;
@@ -25,9 +25,9 @@ export const InfoRow = styled.div`
2525
margin-right: 10px;
2626
}
2727
28-
@media (max-width: 1024px) {
29-
margin-bottom: 15px;
30-
}
28+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
29+
align-items: flex-start;
30+
margin-bottom: 15px;
3131
`;
3232

3333
export const InfoLabel = styled.label`
@@ -39,7 +39,7 @@ export const InfoLabel = styled.label`
3939
margin-right: 15px;
4040
white-space: nowrap;
4141
42-
@media (max-width: 1024px) {
42+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
4343
margin-right: 30px;
4444
margin-bottom: 8px;
4545
font-size: 0.9rem;
@@ -53,7 +53,7 @@ export const InfoText = styled.p`
5353
flex: 0.8;
5454
text-align: left;
5555
56-
@media (max-width: 1024px) {
56+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
5757
font-size: 0.95rem;
5858
flex: 1;
5959
}
@@ -65,7 +65,7 @@ export const SkillTagContainer = styled.div`
6565
gap: 10px;
6666
flex: 0.9;
6767
68-
@media (max-width: 1024px) {
68+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
6969
grid-template-columns: repeat(6, 1fr);
7070
gap: 8px;
7171
width: 100%;
@@ -94,7 +94,7 @@ export const SkillTagImage = styled.div`
9494
margin-top: 2px;
9595
}
9696
97-
@media (max-width: 1024px) {
97+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
9898
img {
9999
width: 35px;
100100
height: 35px;
@@ -116,7 +116,7 @@ export const BeginnerIcon = styled.img`
116116
object-fit: contain;
117117
margin-bottom: 15px;
118118
119-
@media (max-width: 1024px) {
119+
@media screen and ${({ theme }) => theme.mediaQuery.tablet} {
120120
width: 18px;
121121
height: 18px;
122122
margin-bottom: 10px;

src/constants/modalMessage.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,10 @@ export const MODAL_MESSAGE = {
1616
myProfileFail: '프로필 수정에 실패했습니다.',
1717
profileImgSuccess: '프로필 이미지가 업로드 되었습니다.',
1818
profileImgFail: '이미지는 5MB 이하, .png.jpg.jpeg.svg 형식만 가능합니다.',
19+
ModifyProjectSuccess: '공고 수정이 정상적으로 완료 되었습니다.',
20+
ModifyProjectFail: '공고 수정을 실패 했습니다.',
21+
createProjectSuccess: '공고 생성을 완료 했습니다.',
22+
createProjectFail: '공고 생성을 실패 했습니다.',
23+
applyProjectSuccess: '해당 공고에 지원을 완료 되었습니다.',
24+
applyProjectFail: '해당 공고에 지원을 실패 되었습니다.',
1925
} as const;

src/hooks/useApplyProject.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { useMutation } from '@tanstack/react-query';
2+
import { MODAL_MESSAGE } from '../constants/modalMessage';
3+
import { postApplicantProject } from '../api/joinProject.api';
4+
import { ROUTES } from '../constants/routes';
5+
import { useNavigate } from 'react-router-dom';
6+
import { joinProject } from '../models/joinProject';
7+
8+
interface UseApplyProjectProps {
9+
id: number;
10+
handleModalOpen: (newMessage: string) => void;
11+
}
12+
13+
const useApplyProject = ({ id, handleModalOpen }: UseApplyProjectProps) => {
14+
const navigate = useNavigate();
15+
16+
const mutation = useMutation({
17+
mutationFn: (formData: joinProject) => postApplicantProject(formData, id),
18+
onSuccess: () => {
19+
handleModalOpen(MODAL_MESSAGE.applyProjectSuccess);
20+
21+
setTimeout(() => {
22+
navigate(ROUTES.main);
23+
}, 3000);
24+
},
25+
onError: (error) => {
26+
console.log(error);
27+
handleModalOpen(MODAL_MESSAGE.applyProjectFail);
28+
},
29+
});
30+
31+
const applyProject = async (formData: joinProject) => {
32+
mutation.mutate(formData);
33+
};
34+
35+
return {
36+
applyProject,
37+
isLoading: mutation.isPending,
38+
isError: mutation.isError,
39+
error: mutation.error,
40+
isSuccess: mutation.isSuccess,
41+
};
42+
};
43+
44+
export default useApplyProject;

0 commit comments

Comments
 (0)