-
Notifications
You must be signed in to change notification settings - Fork 2
develop <-- feature/dashboard_id #64
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
Changes from all commits
9169a73
80ada6f
9a8afaf
4a98898
713fa98
a685d5b
ecbdb38
e27ae3b
d9cdcac
09d3ec7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,29 @@ | ||
| import { getColor } from '@/app/shared/lib/getColor' | ||
|
|
||
| export default function Tags({ tags }: { tags: string[] }) { | ||
| //ํ๊ทธ ์ปฌ๋ฌ - ๋๋ค ๋ฐฐ์ | ||
| //์นด๋ ์์ฑ ์ - ๋์ผ ํ๊ทธ ์ ๋ ฅ ๋ถ๊ฐํ๋๋ก | ||
| const bgColors = ['#F9EEE3', '#E7F7DB', '#F7DBF0', '#DBE6F7'] | ||
| const textColors = ['#D58D49', '#86D549', '#D549B6', '#4981D5'] | ||
|
|
||
| return ( | ||
| <div className="flex gap-6"> | ||
| {tags.map((tag) => ( | ||
| <span | ||
| key={tag} | ||
| className="inline-block whitespace-nowrap rounded-4 px-9 pb-3 pt-5" | ||
| style={{ backgroundColor: '#F7DBF0', color: '#D549B6' }} | ||
| > | ||
| {tag} | ||
| </span> | ||
| ))} | ||
| <div className="flex flex-wrap gap-6"> | ||
| {tags.map((tag) => { | ||
| const colorIndex = getColor(tag, bgColors) | ||
|
|
||
| return ( | ||
| <span | ||
| key={tag} | ||
| className="inline-block whitespace-nowrap rounded-4 px-9 pb-3 pt-5" | ||
| style={{ | ||
| backgroundColor: bgColors[colorIndex], | ||
| color: textColors[colorIndex], | ||
| }} | ||
| > | ||
| {tag} | ||
| </span> | ||
| ) | ||
| })} | ||
| </div> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,10 @@ export default function Column({ column }: { column: ColumnType }) { | |
| const [isDraggingover, setDraggingover] = useState(false) | ||
| const { clearDraggingCard } = useDragStore() | ||
| const cardMutation = useCardMutation() | ||
| const [openCard, setOpenCard] = useState(false) //card.tsx | ||
| const [openCreateCard, setOpenCreateCard] = useState(false) | ||
| const [openCreateColumn, setOpenCreateColumn] = useState(false) //page.tsx | ||
| const [oepnConfigColumn, setConfigColumn] = useState(false) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ํ ๋ณ์๋ช ํ์ดํฌ ์์ ํ์
๋ค์๊ณผ ๊ฐ์ด ์์ ํ์ธ์: -const [oepnConfigColumn, setConfigColumn] = useState(false)
+const [openConfigColumn, setOpenConfigColumn] = useState(false)๊ทธ๋ฆฌ๊ณ 75๋ฒ ์ค๋ ํจ๊ป ์์ : -onClick={() => setConfigColumn(true)}
+onClick={() => setOpenConfigColumn(true)}Also applies to: 75-75 ๐ค Prompt for AI Agents |
||
|
|
||
| if (isLoading) return <p>loading...</p> | ||
| if (error) return <p>error...{error.message}</p> | ||
|
|
@@ -33,29 +37,32 @@ export default function Column({ column }: { column: ColumnType }) { | |
| e.preventDefault() | ||
| if (isDraggingover) setDraggingover(false) | ||
| const draggingCard = useDragStore.getState().draggingCard | ||
|
|
||
| if (!draggingCard) { | ||
| console.log('no dragging card') //TODO - toast ์ฒ๋ฆฌ ๐ | ||
| return | ||
| } | ||
| // ๋์ผ ์ปฌ๋ผ์ด๋ฉด ๋ฌด์ | ||
| if (draggingCard.columnId === id) { | ||
|
|
||
| if (draggingCard.cardData.columnId === id) { | ||
| clearDraggingCard() | ||
| return | ||
| } | ||
| cardMutation.mutate({ cardId: draggingCard.cardId, columnId: id }) | ||
| cardMutation.mutate({ | ||
| columnId: id, | ||
| cardData: draggingCard.cardData, | ||
| }) | ||
| }} | ||
| data-column-id={id} | ||
| className={cn( | ||
| 'BG-gray Border-column flex w-354 shrink-0 flex-col gap-16 p-20', | ||
| 'BG-gray Border-column tablet:w-584 flex w-354 shrink-0 flex-col gap-16 p-20', | ||
| { | ||
| '!border-blue-500': isDraggingover, | ||
| }, | ||
| )} | ||
| > | ||
| <div className="mb-24 flex items-center justify-between"> | ||
| <div className="flex items-center"> | ||
| <div className="mb-7 mr-8 size-8 rounded-25 bg-blue-500"></div> | ||
| <h2 className="mr-12 text-18 font-bold leading-none">{title}</h2> | ||
| <div className="BG-blue mb-7 mr-8 size-8 rounded-25"></div> | ||
| <h2 className="mb-3 mr-12 h-21 text-18 font-bold">{title}</h2> | ||
| <span className="Text-gray block size-20 rounded-4 bg-[#EEEEEE] pt-3 text-center text-12 font-medium leading-tight dark:bg-[#2E2E2E]"> | ||
| {data?.totalCount} | ||
| </span> | ||
|
|
@@ -65,9 +72,13 @@ export default function Column({ column }: { column: ColumnType }) { | |
| alt="์ปฌ๋ผ ์ค์ " | ||
| width={20} | ||
| height={20} | ||
| onClick={() => setConfigColumn(true)} | ||
| /> | ||
| </div> | ||
| <button className="BG-white Border-btn rounded-6 px-146 py-9"> | ||
| <button | ||
| className="BG-white Border-btn flex justify-center rounded-6 py-9" | ||
| onClick={() => setOpenCreateCard(true)} | ||
| > | ||
| <div className="flex h-22 w-22 items-center justify-center rounded-4 bg-blue-100"> | ||
| <Image | ||
| src={'/images/plus.svg'} | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,17 +12,22 @@ export const useCardMutation = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return useMutation({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 1. ์๋ฒ API ํธ์ถ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // cardId: ๋๋๊ทธํ ์นด๋ ์์ด๋, columnId: dragOver๋ ํ๊ฒ ์ปฌ๋ผ ์์ด๋ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mutationFn: ({ cardId, columnId }: { cardId: number; columnId: number }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updateCardColumn(cardId, columnId), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mutationFn: ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| columnId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cardData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| columnId: number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cardData: Card | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) => updateCardColumn(cardData.id, columnId), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // 2. ๋๊ด์ UI ์ฒ๋ฆฌ (์๋ฒ ์์ฒญ ์ ์ ์คํ๋จ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onMutate: async ({ cardId, columnId }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onMutate: async ({ columnId, cardData }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const currentCard = useDragStore.getState().draggingCard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await Promise.all([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryClient.cancelQueries({ queryKey: ['columnId', columnId] }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryClient.cancelQueries({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryKey: ['columnId', currentCard?.columnId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryKey: ['columnId', currentCard?.cardData.columnId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -35,47 +40,42 @@ export const useCardMutation = () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Guard return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !currentCard || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentCard.cardId !== cardId || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentCard.columnId === columnId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentCard.cardData.id !== cardData.id || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| currentCard.cardData.columnId === columnId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('no dragging card || is not a dragging card || same column') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| clearDraggingCard() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let extractedCard: Card | undefined // B. ์์ ์ฌ์ฉํ ์์ (์ถ๊ฐํ ์นด๋ ๋ฐ์ดํฐ๋ Card์ฌ์ผ ํด์) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // A. ์ด์ ์ปฌ๋ผ์์ ์นด๋ ์ ๊ฑฐ & ์นด๋ ์ถ์ถ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // setQueryData์ ์ฝ๋ฐฑํจ์์ ๋ฆฌํด๊ฐ์ด ์ฟผ๋ฆฌํค ์บ์์ ์ ์ฅ๋จ(์บ์ ์ ๋ฐ์ดํธ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryClient.setQueryData<CardResponse>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ['columnId', currentCard.columnId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ['columnId', currentCard.cardData.columnId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (oldData) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!oldData) return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const filtered = oldData.cards.filter((card) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (card.id === cardId) extractedCard = card | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return card.id !== cardId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return card.id !== cardData.id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { ...oldData, cards: filtered } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
53
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
- if (!oldData) return
+ if (!oldData) return oldData // ์บ์ ๋ณด์กด๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // B. ์ ์ปฌ๋ผ์ ์นด๋ ์ถ๊ฐ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (extractedCard) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryClient.setQueryData<CardResponse>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ['columnId', columnId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (oldData) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!oldData) return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| queryClient.setQueryData<CardResponse>( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ['columnId', columnId], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (oldData) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!oldData) return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const movedCard = { ...extractedCard!, columnId } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...oldData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cards: [...oldData.cards, movedCard], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('์นด๋๊ฐ ์ ๊ฑฐ ์ค์ undefined๊ฐ ๋จ') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const movedCard = { ...cardData, columnId: columnId } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('Cardcolumn changed', { movedCard }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...oldData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cards: [...oldData.cards, movedCard], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| clearDraggingCard() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { previousData } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐ ๏ธ Refactor suggestion
๋ฐฐ๊ฒฝ/ํ ์คํธ ์ ๋ฐฐ์ด ๊ธธ์ด ๋ถ์ผ์น ๊ฐ๋ฅ์ฑ ๋๋น
bgColors์textColors๋ฐฐ์ด ๊ธธ์ด๊ฐ ๋ฌ๋ผ์ง๋ฉดcolorIndex๊ฐtextColors๋ฒ์๋ฅผ ์ด๊ณผํดundefined๋ฅผ ๋ฐํ, ์คํ์ผ ๊ฒฝ๊ณ ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ๋ ๋ฐฐ์ด ๊ธธ์ด๋ฅผ ๊ฒ์ฆํ๊ฑฐ๋ ํ๋์ ๋ฐฐ์ด์ ๊ฐ์ฒด ํํ๋ก ๊ด๋ฆฌํ๋ ๊ฒ์ด ์์ ํฉ๋๋ค.๐ Committable suggestion
๐ค Prompt for AI Agents