Skip to content

Commit

Permalink
Merge pull request #128 from boocam-project/feature/resume
Browse files Browse the repository at this point in the history
Feat: 스터디 및 자기소개서 API 연결
  • Loading branch information
Gaoridang authored Jun 19, 2024
2 parents c34c4bf + 2ec7535 commit 8c401dc
Show file tree
Hide file tree
Showing 44 changed files with 3,491 additions and 67 deletions.
2,000 changes: 1,990 additions & 10 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
"@tiptap/extension-underline": "^2.2.1",
"@tiptap/react": "^2.1.11",
"@tiptap/starter-kit": "^2.1.11",
"@uiw/react-md-editor": "^4.0.4",
"aws-sdk": "^2.1532.0",
"axios": "^1.5.0",
"classnames": "^2.3.2",
"cors": "^2.8.5",
"date-fns": "^3.6.0",
"dayjs": "^1.11.10",
"firebase": "^10.4.0",
"html-react-parser": "^4.2.2",
"react": "^18.2.0",
"react-day-picker": "^8.10.1",
"react-dom": "^18.2.0",
"react-error-boundary": "^4.0.12",
"react-hook-form": "^7.46.1",
Expand Down
3 changes: 3 additions & 0 deletions src/api/apiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ export const ENDPOINTS = {
report: `/api/v1/report`,
like: `/api/v1/article-like`,
reviews: `${API_VERSION}/reviews`,
resume: `${API_VERSION}/resumes`,
studies: `${API_VERSION}/studies`,
categories: `${API_VERSION}/categories`,
};
12 changes: 8 additions & 4 deletions src/api/authApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ const authInstance = axios.create({
});

export const getNewAccessToken = async (accessToken: string, refreshToken: string) => {
const response = await authInstance.post<RefreshTokenResponse>(`${ENDPOINTS.refreshToken}`, {
accessToken,
refreshToken,
});
const response = await authInstance.post<RefreshTokenResponse>(
`${ENDPOINTS.refreshToken}`,
{ accessToken, refreshToken },
{
headers: { Authorization: `Bearer ${accessToken}` },
}
);

return response.data;
};

Expand Down
61 changes: 61 additions & 0 deletions src/api/resumeService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { ENDPOINTS } from './apiConfig';
import { instance } from './client';

export interface Resume {
id: number;
title: string;
content: string;
writer: string;
likeCount: number;
viewCount: number;
createdAt: string | null;
lastModifiedAt: string | null;
deletedAt: string | null;
}

export interface CreateResumeData {
title: string;
content: string;
}

class ResumeService {
private endpoint = ENDPOINTS.resume;

getResumes = async () => {
const response = await instance.get<{ data: Resume[] }>(`${this.endpoint}`);

return response.data.data;
};

getResume = async (id: number) => {
const response = await instance.get<{ data: Resume }>(`${this.endpoint}/${id}`);

return response.data.data;
};

update = async (resume: CreateResumeData, id: number) => {
const response = await instance.put(`${this.endpoint}/${id}`, resume);

return response.data;
};

delete = async (id: number) => {
const response = await instance.delete(`${this.endpoint}/${id}`);

return response.data;
};

create = async (resume: CreateResumeData) => {
const response = await instance.post(`${this.endpoint}`, resume);

return response.data;
};

like = async (id: number) => {
const response = await instance.post(`${this.endpoint}/${id}/like`);

return response.data;
};
}

export default new ResumeService();
169 changes: 169 additions & 0 deletions src/api/studyService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import { ENDPOINTS } from './apiConfig';
import { instance } from './client';

interface getStudiesParams {
page?: number;
pageSize?: number;
orderBy?: string;
}

interface StudyResponse {
code: number;
message: string;
data: {
totalPages: number;
isLastPage: boolean;
totalStudies: number;
studies: Study[];
};
}

interface Study {
id: number;
title: string;
content: string;
skill: string;
total: number;
current: number;
applicant: number;
recruitmentStart: string;
recruitmentEnd: string;
progressStart: string;
progressEnd: string;
contact: string;
nickname: string;
categories: number[];
}

export interface CreateStudyData {
title: string;
content: string;
skill: string;
total: number;
recruitmentEnd: string;
progressStart: string;
progressEnd: string;
contact: string;
categoryIds: number[];
}
export interface StudyApplication {
id: number;
status: string;
studyId: number;
applicantId: number;
nickname: string;
message: string;
createdAt: string;
updatedAt: string | null;
deletedAt: string | null;
}

export interface StudySuggestionsData {
totalPages: number;
isLastPage: boolean;
totalStudySuggestions: number;
studySuggestions: StudySuggestion[];
}

export interface StudySuggestion {
studySuggestionId: number;
status: string;
studyId: number;
memberId: number;
nickname: string;
message: string;
createdAt: string;
updatedAt: string | null;
deletedAt: string | null;
}

class StudyService {
private endpoint = ENDPOINTS.studies;

getStudies = async ({ page = 0, pageSize = 10, orderBy = 'latest' }: getStudiesParams) => {
const response = await instance.get<StudyResponse>(`${this.endpoint}`, {
params: {
page,
pageSize,
orderBy,
},
});

return response.data;
};

getStudy = async (id: number) => {
const response = await instance.get<{ data: Study }>(`${this.endpoint}/${id}`);

return response.data.data;
};

getCategories = async () => {
const response = await instance.get<{ data: { id: number; name: string }[] }>(
ENDPOINTS.categories
);

return response.data.data;
};

create = async (study: CreateStudyData) => {
const response = await instance.post<{ data: string }>(`${this.endpoint}`, study);

return response.data.data;
};

update = async (study: CreateStudyData, id: number) => {
const response = await instance.put<{ data: string }>(`${this.endpoint}/${id}`, study);

return response.data.data;
};

delete = async (studyId: number) => {
const response = await instance.delete(`${this.endpoint}/${studyId}`);

return response.data;
};

apply = async (id: number, message: string) => {
const response = await instance.post<{ data: { studyApplicationId: number } }>(
`${this.endpoint}/${id}`,
{
message,
}
);

return response.data.data;
};

getApplications = async (studyId?: number, pageSize: number = 10, page: number = 0) => {
const response = await instance.get<{ data: StudyApplication[] }>(
`${this.endpoint}/applications`,
{
params: {
studyId,
pageSize,
page,
},
}
);

return response.data.data;
};

getSuggestions = async (id?: number, pageSize: number = 10, page: number = 0) => {
const response = await instance.get<{ data: StudySuggestionsData }>(
`${this.endpoint}/suggestions`,
{
params: {
id,
pageSize,
page,
},
}
);

return response.data.data;
};
}

export default new StudyService();
15 changes: 15 additions & 0 deletions src/components/atoms/button/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
background-color: #fff;
border: 1px solid v.$black;
}

&[data-selected='selected'] {
color: v.$black;
background-color: #fff5f5;
border: 1px solid v.$black;
}
}

&.text {
Expand All @@ -38,4 +44,13 @@
color: v.$black;
}
}

&.default {
color: #020202;
background-color: #ffffff;
border: 1px v.$light-gray solid;
font-size: v.$text-xs;
font-weight: v.$font-medium;
cursor: default;
}
}
12 changes: 9 additions & 3 deletions src/components/atoms/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import { ComponentProps, ReactNode } from 'react';

type ButtonProps = ComponentProps<'button'> & {
children: ReactNode;
variant: 'primary' | 'secondary' | 'text';
variant?: 'primary' | 'secondary' | 'text' | 'default';
classNames?: string;
};

const cx = classNames.bind(styles);

const Button = ({ children, variant = 'primary', ...props }: ButtonProps) => {
const Button = ({ children, classNames, variant = 'primary', ...props }: ButtonProps) => {
return (
<button
{...props}
className={cx({ button: true, secondary: variant === 'secondary', text: variant === 'text' })}
className={cx(classNames, {
button: true,
secondary: variant === 'secondary',
text: variant === 'text',
default: variant === 'default',
})}
type="button"
>
{children}
Expand Down
4 changes: 2 additions & 2 deletions src/components/atoms/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { CiSearch } from 'react-icons/ci';
import InputIcon from './InputIcon';

interface Props extends ComponentProps<'input'> {
name: string;
label: string;
name?: string;
label?: string;
register?: UseFormRegisterReturn;
errorMessage?: any;
variant?: 'defaultInput' | 'searchInput';
Expand Down
7 changes: 7 additions & 0 deletions src/components/atoms/input/input.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
width: 100%;
height: 35px;

// 숫자 타입 화살표 제거
&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}

outline: none;
border: none;
border-bottom: 1px solid m.$light-gray;
Expand Down
Loading

0 comments on commit 8c401dc

Please sign in to comment.