-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
169 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { instance } from "../axios"; | ||
import { | ||
getReviewDetailResponseProps, | ||
getReviewListResponseProps, | ||
} from "./type"; | ||
|
||
const router = "/reviews"; | ||
|
||
export const GetReviewList = (companiesId: string) => { | ||
return useQuery(["getReviewList", companiesId], async () => { | ||
const { data } = await instance.get<getReviewListResponseProps>( | ||
`${router}/${companiesId}` | ||
); | ||
return data; | ||
}); | ||
}; | ||
|
||
export const getReviewDetails = (reviewId: string) => { | ||
return useQuery(["getReviewDetails", reviewId], async () => { | ||
const { data } = await instance.get<getReviewDetailResponseProps>( | ||
`${router}/details/${reviewId}` | ||
); | ||
return data; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export interface getReviewListResponseProps { | ||
reviews: getReviewListProps[]; | ||
} | ||
|
||
export interface getReviewListProps { | ||
review_id: string; | ||
year: number; | ||
writer: string; | ||
date: string; | ||
} | ||
|
||
export interface getReviewDetailResponseProps { | ||
qna_responses: getReviewDetailProps[]; | ||
} | ||
|
||
export interface getReviewDetailProps { | ||
question: string; | ||
answer: string; | ||
area: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ReviewList from "@/components/company/ReviewList"; | ||
|
||
export default function Reviews() { | ||
return ( | ||
<div className="w-2/3 mx-auto my-5"> | ||
<p className="py-12 leading-10 text-center text-h4 font-b text-primaryBlue03"> | ||
λ©΄μ νκΈ° | ||
</p> | ||
<hr className="border-[#135C9D]" /> | ||
<ReviewList /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { getReviewDetailProps } from "@/apis/reviews/type"; | ||
import { Icon } from "@team-return/design-system"; | ||
import { useState } from "react"; | ||
|
||
export default function ReviewItem({ | ||
item, | ||
writer, | ||
date, | ||
}: { | ||
item: getReviewDetailProps; | ||
writer: string; | ||
date: string; | ||
}) { | ||
const [isOpen, setIsOpen] = useState<boolean>(false); | ||
return ( | ||
<> | ||
<div | ||
className="w-full px-3 py-5 border-b border-[#e5e5e5] flex justify-between cursor-pointer hover:bg-[#fcfcfc]" | ||
onClick={() => setIsOpen((prev) => !prev)} | ||
> | ||
<p className="leading-6 text-b3 font-r text-primaryBlue03"> | ||
{item.question} | ||
</p> | ||
<Icon | ||
icon="Chevron" | ||
direction={isOpen ? "top" : "bottom"} | ||
color="liteBlue" | ||
/> | ||
</div> | ||
{isOpen && ( | ||
<div className="p-4 bg-[#fafafa] w-full flex relative min-h-[100px] pb-10 gap-1"> | ||
<p className="text-b3 font-r leading-b3 text-[#444444] flex-1 whitespace-pre-line"> | ||
{item.answer} | ||
</p> | ||
<div className="text-caption font-r leading-caption text-[#4F95D4] px-2 py-1 bg-white rounded-[8px] h-[26px]"> | ||
{item.area} | ||
</div> | ||
<p className="text-caption font-r leading-caption text-[#7f7f7f] absolute bottom-4 right-4"> | ||
{date} Β· {writer} | ||
</p> | ||
</div> | ||
)} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use client"; | ||
|
||
import { getReviewDetails, GetReviewList } from "@/apis/reviews"; | ||
import { getReviewListProps } from "@/apis/reviews/type"; | ||
import { useSearchParams } from "next/navigation"; | ||
import ReviewItem from "./ReviewItem"; | ||
|
||
export default function ReviewList() { | ||
const params = useSearchParams(); | ||
const { data: reviewList, isLoading } = GetReviewList(params.get("id")!); | ||
|
||
if (isLoading) | ||
return ( | ||
<div className="w-full text-center text-b2 font-m leading-b2 text-[#7f7f7f] mt-[200px]"> | ||
Loading... | ||
</div> | ||
); | ||
|
||
if (reviewList?.reviews.length === 0) | ||
return ( | ||
<div className="w-full text-center text-b2 font-m leading-b2 text-[#7f7f7f] mt-[200px]"> | ||
μμ§ νκΈ°κ° μμ΄μ | ||
</div> | ||
); | ||
|
||
return ( | ||
<> | ||
{reviewList!.reviews.map((item, idx) => ( | ||
<ReviewContainers key={idx} {...item} /> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
function ReviewContainers({ review_id, writer, date }: getReviewListProps) { | ||
const { data: reviewDetails } = getReviewDetails(review_id); | ||
return ( | ||
<> | ||
{reviewDetails?.qna_responses.map((item, idx) => ( | ||
<ReviewItem key={idx} item={item} writer={writer} date={date} /> | ||
))} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters