Skip to content

Commit

Permalink
πŸ”€ :: μ§€μ›ν•˜κΈ°
Browse files Browse the repository at this point in the history
  • Loading branch information
KANGYONGSU23 authored Nov 28, 2023
2 parents 9a46df6 + e2d20be commit 3fc467e
Show file tree
Hide file tree
Showing 48 changed files with 783 additions and 117 deletions.
3 changes: 3 additions & 0 deletions public/Clip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/Loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions src/apis/applications/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { useMutation } from "@tanstack/react-query";
import { useToastStore } from "@team-return/design-system";
import { AxiosError } from "axios";
import { useRouter } from "next/navigation";
import { instance } from "../axios";
import { ApplyRequestItmeType } from "./type";

const router = "/applications";

export default function useApplyToCompany(recruitmentId: string) {
const navigator = useRouter();
const { append } = useToastStore();
return useMutation(
async function (body: ApplyRequestItmeType[]) {
return await instance.post(`${router}/${recruitmentId}`, {
attachments: body,
});
},
{
onSuccess: () => {
navigator.push("/mypage");
},
onError: (error: AxiosError) => {
switch (error.response?.status) {
case 401:
append({
title: "",
message: "3학년이 μ•„λ‹Œ 학생은 지원할 수 μ—†μŠ΅λ‹ˆλ‹€.",
type: "RED",
});
break;
case 404:
append({
title: "",
message: "λͺ¨μ§‘μ˜λ’°μ„œκ°€ μ‘΄μž¬ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.",
type: "RED",
});
break;
case 409:
append({
title: "",
message:
"이미 ν•΄λ‹Ή λͺ¨μ§‘μ˜λ’°μ— μ§€μ›ν–ˆκ±°λ‚˜ 승인된 μ§€μ›μš”μ²­μ΄ μ‘΄μž¬ν•©λ‹ˆλ‹€.",
type: "RED",
});

default:
break;
}
},
}
);
}
10 changes: 10 additions & 0 deletions src/apis/applications/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type AttachmentsType = "FILE" | "URL";

export interface ApplyRequestItmeType {
url: string;
type: AttachmentsType;
}

export interface ApplyRequestBody {
attachments: ApplyRequestItmeType[];
}
6 changes: 3 additions & 3 deletions src/apis/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AuthCode, IAuthorizationResponse, SendAuthCodeType } from "./type";

const router = "/auth";

export const ReissueToken = async (refresh_token: string) => {
export const useReissueToken = async (refresh_token: string) => {
const response = await axios.put<IAuthorizationResponse>(
`${process.env.NEXT_PUBLIC_BASE_URL}${router}/reissue`,
null,
Expand All @@ -18,7 +18,7 @@ export const ReissueToken = async (refresh_token: string) => {
return response.data;
};

export const SendAuthCode = () => {
export const useSendAuthCode = () => {
const { append } = useToastStore();

return useMutation(
Expand Down Expand Up @@ -67,7 +67,7 @@ export const SendAuthCode = () => {
);
};

export const CheckAuthCode = (
export const useCheckAuthCode = (
query_string: AuthCode,
options?: Omit<
UseMutationOptions<any, AxiosError<unknown, any>, void, unknown>,
Expand Down
7 changes: 3 additions & 4 deletions src/apis/axios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, { AxiosError } from "axios";
import { Cookies } from "react-cookie";
import { ReissueToken } from "./auth";
import { useReissueToken } from "./auth";

export const instance = axios.create({
baseURL: process.env.NEXT_PUBLIC_BASE_URL,
Expand Down Expand Up @@ -28,6 +28,7 @@ instance.interceptors.response.use(
if (axios.isAxiosError(error) && error.response) {
const { config } = error;
const refreshToken = cookies.get("refresh_token");

if (
(error.response.data.message === "Invalid Token" ||
error.response.data.message === "Token Expired" ||
Expand All @@ -37,7 +38,7 @@ instance.interceptors.response.use(
if (!isRefreshing) {
cookies.remove("access_token");
isRefreshing = true;
ReissueToken(refreshToken)
useReissueToken(refreshToken)
.then((res) => {
isRefreshing = false;
cookies.remove("refresh_token");
Expand All @@ -61,8 +62,6 @@ instance.interceptors.response.use(
window.location.href = "/account/login";
});
}
} else {
window.location.href = "/account/login";
}
}
return Promise.reject(error);
Expand Down
4 changes: 2 additions & 2 deletions src/apis/bookmarks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { instance } from "../axios";

const router = "/bookmarks";

export const GetBookmarks = () => {
export const useGetBookmarks = () => {
return useQuery(["GetBookmarks"], async () => {
const { data } = await instance.get(`${router}`);
return data;
});
};

export const SetBookmarks = () => {
export const useSetBookmarks = () => {
const queryClient = useQueryClient();
return useMutation(
async (recruitmentId: number) => {
Expand Down
2 changes: 1 addition & 1 deletion src/apis/code/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from "axios";

const router = "/codes";

export const GetCode = (
export const useGetCode = (
type: CodeType,
keyword?: string,
parent_code?: number
Expand Down
6 changes: 3 additions & 3 deletions src/apis/companies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CompaniesDetailsType, CompaniesListResponseType } from "./type";

const router = "/companies";

export const GetCompaniesList = (queryString: string) => {
export const useGetCompaniesList = (queryString: string) => {
const { append } = useToastStore();
return useQuery(
["companiesList", queryString],
Expand All @@ -27,7 +27,7 @@ export const GetCompaniesList = (queryString: string) => {
);
};

export const GetCompaniesDetail = (id: string) => {
export const useGetCompaniesDetail = (id: string) => {
const { append } = useToastStore();
return useQuery(
["companiesDetails"],
Expand All @@ -45,7 +45,7 @@ export const GetCompaniesDetail = (id: string) => {
);
};

export const GetNumberOfCompaniesListPages = (queryString: string) => {
export const useGetNumberOfCompaniesListPages = (queryString: string) => {
const { data } = useQuery(
["getNumberOfCompaniesListPages", queryString],
async () =>
Expand Down
34 changes: 34 additions & 0 deletions src/apis/file/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useMutation } from "@tanstack/react-query";
import { useToastStore } from "@team-return/design-system";
import { AxiosError } from "axios";
import { instance } from "../axios";
import { UploadFileResponse } from "./type";

const router = "/files";

export const useFileUpload = () => {
const { append } = useToastStore();
return useMutation(
async (files: File[]) => {
const formData = new FormData();
files.map((file) => {
formData.append("file", file);
});
const { data }: { data: UploadFileResponse } = await instance.post(
`${router}?type=EXTENSION_FILE`,
formData
);
return data;
},
{
onError: (error: AxiosError) => {
if (error.response)
append({
title: "",
message: "파일 μ—…λ‘œλ“œμ— μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.",
type: "RED",
});
},
}
);
};
3 changes: 3 additions & 0 deletions src/apis/file/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface UploadFileResponse {
urls: string[];
}
13 changes: 9 additions & 4 deletions src/apis/recruitments/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

const router = "/recruitments";

export const GetRecruitmentsList = (queryString: string) => {
export const useGetRecruitmentsList = (queryString: string) => {
const { append } = useToastStore();
return useQuery(
["getRecruitmentsList", queryString],
Expand All @@ -31,11 +31,16 @@ export const GetRecruitmentsList = (queryString: string) => {
);
};

export const GetRecruitmentsDetail = (id: string) => {
export const useGetRecruitmentsDetail = (id: string) => {
const { append } = useToastStore();
return useQuery(
["getRecruitmentsDetail", id],
async () => await instance.get<RecruitmentsDetailType>(`${router}/${id}`),
async () => {
const { data } = await instance.get<RecruitmentsDetailType>(
`${router}/${id}`
);
return data;
},
{
refetchOnWindowFocus: false,
onError: () => {
Expand All @@ -49,7 +54,7 @@ export const GetRecruitmentsDetail = (id: string) => {
);
};

export const GetNumberOfRecruitmentRequestListPages = (queryString: string) => {
export const useGetNumberOfRecruitmentRequestListPages = (queryString: string) => {
const { data } = useQuery(
["getNumberOfRecruitmentRequestListPages", queryString],
async () =>
Expand Down
4 changes: 2 additions & 2 deletions src/apis/reviews/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {

const router = "/reviews";

export const GetReviewList = (companiesId: string) => {
export const useGetReviewList = (companiesId: string) => {
return useQuery(["getReviewList", companiesId], async () => {
const { data } = await instance.get<getReviewListResponseProps>(
`${router}/${companiesId}`
Expand All @@ -16,7 +16,7 @@ export const GetReviewList = (companiesId: string) => {
});
};

export const getReviewDetails = (reviewId: string) => {
export const useGetReviewDetails = (reviewId: string) => {
return useQuery(["getReviewDetails", reviewId], async () => {
const { data } = await instance.get<getReviewDetailResponseProps>(
`${router}/details/${reviewId}`
Expand Down
4 changes: 2 additions & 2 deletions src/apis/students/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { MyProfileProps, RequestBody } from "./type";

const router = "/students";

export const Signup = () => {
export const useSignup = () => {
const [, setCookie] = useCookies();
const navigator = useRouter();
const { append } = useToastStore();
Expand Down Expand Up @@ -69,7 +69,7 @@ export const Signup = () => {
);
};

export const MyProfile = () => {
export const useMyProfile = () => {
return useQuery(
["myProfile"],
async () => await instance.get<MyProfileProps>(`${router}/my`),
Expand Down
2 changes: 1 addition & 1 deletion src/apis/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import axios, { AxiosError } from "axios";

const router = "/users";

export const Login = (body: RequestBody, checkBoxValue: boolean) => {
export const useLogin = (body: RequestBody, checkBoxValue: boolean) => {
const [, setCookie, removeCookie] = useCookies();
const navigator = useRouter();
const { append } = useToastStore();
Expand Down
4 changes: 2 additions & 2 deletions src/app/companies/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import { useRouter, useSearchParams } from "next/navigation";
import { useToastStore } from "@team-return/design-system";
import CompanyTable from "@/components/company/CompanyTable";
import CompanyTitle from "@/components/company/CompanyTitle";
import { GetCompaniesDetail } from "@/apis/companies";
import { useGetCompaniesDetail } from "@/apis/companies";
import { business_number_regex } from "@/util/regex";

export default function CompanyDetailPage() {
const navigator = useRouter();
const params = useSearchParams();
const { append } = useToastStore();

const { data } = GetCompaniesDetail(params.get("id")!);
const { data } = useGetCompaniesDetail(params.get("id")!);

if (data) {
const {
Expand Down
12 changes: 6 additions & 6 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
}
.skeltonUi {
@apply bg-[#f7f7f7] relative;
}
.drag {
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
}

Expand Down Expand Up @@ -51,12 +57,6 @@ input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
}

.drag {
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}

table {
width: 100%;
Expand Down
Loading

0 comments on commit 3fc467e

Please sign in to comment.