-
Notifications
You must be signed in to change notification settings - Fork 1
feat: show detail score #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4f42a74
feat: get score
bae080311 e2c546b
feat: score type
bae080311 e2387b5
feat: score modal
bae080311 1b75c3a
fix: title optional
bae080311 8341ad1
feat: cursor pointer
bae080311 4ddcef0
fix: show category name
bae080311 1da1ea6
fix: return null
bae080311 ec79075
fix: use function
bae080311 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,18 @@ | ||
| import instance from "@repo/api"; | ||
| import { AxiosError } from "axios"; | ||
| import { toast } from "sonner"; | ||
| import type { ScoreResponse } from "../model/score"; | ||
|
|
||
| export const getScore = async ( | ||
| id: string | ||
| ): Promise<ScoreResponse | undefined> => { | ||
| try { | ||
| const res = await instance.get(`/score/${id}`); | ||
| return res.data as ScoreResponse; | ||
| } catch (error) { | ||
| if (error instanceof AxiosError) { | ||
| toast.error("์ ์ ์ ๋ณด๋ฅผ ๋ถ๋ฌ์ค๋๋ฐ ์คํจํ์ต๋๋ค"); | ||
| } | ||
| } | ||
| return undefined; | ||
| }; | ||
This file contains hidden or 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,9 @@ | ||
| export interface ScoreResponse { | ||
| totalScore: number; | ||
| scores: Score[]; | ||
| } | ||
|
|
||
| export interface Score { | ||
| categoryName: string; | ||
| value: number; | ||
| } |
This file contains hidden or 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,11 @@ | ||
| import { useQuery } from "@tanstack/react-query"; | ||
| import { getScore } from "../api/getScore"; | ||
| import type { ScoreResponse } from "./score"; | ||
|
|
||
| export const useGetScore = (id: string) => { | ||
| return useQuery<ScoreResponse | undefined>({ | ||
| queryKey: ["score", id], | ||
| queryFn: () => getScore(id), | ||
| enabled: !!id, | ||
| }); | ||
| }; |
This file contains hidden or 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,46 @@ | ||
| "use client"; | ||
|
|
||
| import { Button } from "@repo/shared/button"; | ||
| import Card from "@repo/shared/card"; | ||
| import List from "@repo/shared/list"; | ||
| import { useGetScore } from "../model/useGetScore"; | ||
| import { getCategoryName } from "@repo/utils/handleCategory"; | ||
|
|
||
| interface ScoreModalProps { | ||
| close: () => void; | ||
| show: boolean; | ||
| id: string; | ||
| } | ||
|
|
||
| export default function ScoreModal({ show, close, id }: ScoreModalProps) { | ||
| const { data } = useGetScore(id as string); | ||
| if (!show) return null; | ||
| return ( | ||
| <div className="fixed inset-0 z-10 bg-[rgba(17,17,17,0.2)] flex items-center justify-center"> | ||
| <div className="gap-6 flex flex-col bg-white z-20 rounded-[1.25rem] px-[2.45rem] py-[2.25rem] max-sm:w-[20.5rem]"> | ||
| <h3 className="text-tropicalblue-700 text-titleSmall">๋ถ๋ถ์ ์</h3> | ||
| <List className="p-0"> | ||
| {data && | ||
| data?.scores.map((v) => { | ||
| return ( | ||
| <Card | ||
| key={v.categoryName} | ||
| front={ | ||
| (() => { | ||
| const transformedCategoryName = getCategoryName(v.categoryName).replace(/^[^-]*-/, ""); | ||
| return transformedCategoryName.length > 20 | ||
| ? transformedCategoryName.slice(0, 20) + "..." | ||
| : transformedCategoryName; | ||
| })() | ||
| } | ||
| id={v.categoryName} | ||
| back={v.value} | ||
| /> | ||
| ); | ||
| })} | ||
| </List> | ||
| <Button variant="skyblue" onClick={close} label="๋ค๋ก๊ฐ๊ธฐ" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.