Skip to content

Commit ed2bcc0

Browse files
authored
Merge pull request #94 from Nexters/feat#92
Feat#92 리뷰 모달 연결 및 리뷰 post api 연결
2 parents decf559 + b1c019a commit ed2bcc0

File tree

6 files changed

+466
-8
lines changed

6 files changed

+466
-8
lines changed

src/shared/components/RootLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
1212
height: 100%;
1313
display: flex;
1414
flex-direction: column;
15+
overflow-x: hidden;
1516
`}
1617
>
1718
{children}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import apiClient from "@/shared/lib/axios/apiClient";
2+
3+
enum ReviewScore {
4+
BAD = "0",
5+
NOT_BAD = "1",
6+
GOOD = "2",
7+
}
8+
export const createTarotReview = async (grade: ReviewScore, resultId: number) => {
9+
return apiClient
10+
.post(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/v1/review/create`, {
11+
grade: grade,
12+
tarotResultId: resultId,
13+
})
14+
.then((res) => res.data)
15+
.catch((error) => {
16+
console.error(error);
17+
throw error;
18+
});
19+
};

src/tarot/apis/getReviewExist.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import apiClient from "@/shared/lib/axios/apiClient";
2+
import { z } from "zod";
3+
4+
type serverResponse = {
5+
hasReviewed: boolean;
6+
};
7+
8+
const schema = z.object({
9+
hasReviewed: z.boolean(),
10+
});
11+
12+
export type TarotFollowQuestion = z.infer<typeof schema>;
13+
14+
const validate = (data: serverResponse): TarotFollowQuestion => {
15+
const validatedData = schema.parse(data);
16+
return validatedData;
17+
};
18+
19+
export const getReviewExist = (resultId: number): Promise<TarotFollowQuestion> => {
20+
return apiClient
21+
.get<serverResponse>(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/v1/review/exist/${resultId}`)
22+
.then((res) => validate(res.data))
23+
.catch((error) => {
24+
console.error(error);
25+
throw error;
26+
});
27+
};

0 commit comments

Comments
 (0)