Skip to content

Commit

Permalink
feat :: 리뷰 작성 가능 기업
Browse files Browse the repository at this point in the history
  • Loading branch information
KANGYONGSU23 committed Apr 4, 2024
1 parent a71d7f7 commit 29ed3a6
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 12 deletions.
12 changes: 11 additions & 1 deletion src/apis/companies/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from "@tanstack/react-query";
import { useToastStore } from "@team-return/design-system";
import { instance } from "../axios";
import { GetNumberOfPagesType } from "../recruitments/type";
import { CompaniesDetailsType, CompaniesListResponseType } from "./type";
import { CompaniesDetailsType, CompaniesListResponseType, GetCompaniesForReviewingResponse } from "./type";

const router = "/companies";

Expand Down Expand Up @@ -56,3 +56,13 @@ export const useGetNumberOfCompaniesListPages = (queryString: string) => {
);
return data;
};

export const useGetCompaniesForReviewing = () => {
return useQuery(
["getCompaniesForReviewing"],
async () => {
const {data} = await instance.get<GetCompaniesForReviewingResponse>(`${router}/review`);
return data;
}
)
}
11 changes: 10 additions & 1 deletion src/apis/companies/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,13 @@ export interface CompaniesDetailsTable {
attachments: any[];
service_name: string;
business_area: string;
}
}

export interface CompaniesForReviewType {
id: number,
name: string,
}

export interface GetCompaniesForReviewingResponse {
companies : CompaniesForReviewType[]
}
27 changes: 17 additions & 10 deletions src/apis/reviews/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,24 @@ export const useCreateReviews = (options: Omit<UseMutationOptions<AxiosResponse<
break;
}
case 404: {
if (
(response as AxiosResponse<{ message: string }>).data.message ===
"Code Not Found"
) {
append({
title: "",
message: "질문 분야가 누락되었습니다.",
type: "RED",
});
switch ((response as AxiosResponse<{ message: string }>).data.message) {
case "Code Not Found": {
append({
title: "",
message: "질문 분야가 누락되었습니다.",
type: "RED",
});
break;
}
case 'ApplicationEntity Not Found': {
append({
title: '',
message: '해당 기업에는 후기를 작성할 수 없습니다.',
type: 'RED',
})
}
}
break;

}
}
},
Expand Down
2 changes: 2 additions & 0 deletions src/app/mypage/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import AppliedCompaniesList from "@/components/mypage/AppliedCompaniesList";
import DetailProfile from "@/components/mypage/DetailProfile";
import CompaniesForReviewing from "@/components/mypage/CompaniesForReviewing";

export default function MyPage() {
return (
<div className="py-[56px] mx-[9vw]">
<DetailProfile />
<CompaniesForReviewing />
<AppliedCompaniesList />
</div>
);
Expand Down
36 changes: 36 additions & 0 deletions src/components/mypage/CompaniesForReviewing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
'use client'

import { useGetCompaniesForReviewing } from "@/apis/companies"
import { useRouter } from "next/navigation"

export default function CompaniesForReviewing() {
const { data: response, isLoading } = useGetCompaniesForReviewing();
const router = useRouter();

if(response?.companies.length === 0 || isLoading) {
return (
<></>
)
}

return (
<section className="my-10 bg-[#F0F7FF] rounded-[8px] py-4 px-5 flex justify-between">
<p className="text-b2 leading-[150%] font-m text-[#333333]">면접은 어땠나요? 후기 작성하기 </p>
<div className="mt-1">
{
response.companies.map(({id, name})=>(
<p className="text-right text-b3 leading-b3 font-r text-[#333333]">👉{' '}
<span
className="underline decoration-black decoration-[#333333] cursor-pointer"
onClick={()=>{
router.push(`/companies/reviews/create/?id=${id}`)
}}>
{name}
</span>
</p>
))
}
</div>
</section>
)
}

0 comments on commit 29ed3a6

Please sign in to comment.