-
Notifications
You must be signed in to change notification settings - Fork 1
Feat(client): card edit delete #83
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
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,9 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| import { Badge, Card } from '@pinback/design-system/ui'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { useState } from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { Badge, Card } from '@pinback/design-system/ui'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import CardEditModal from '@shared/components/cardEditModal/CardEditModal'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import OptionsMenuPortal from '@shared/components/sidebar/OptionsMenuPortal'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { useAnchoredMenu } from '@shared/hooks/useAnchoredMenu'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { belowOf } from '@shared/utils/anchorPosition'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { REMIND_MOCK_DATA } from './constants'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
+7
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. REMIND_MOCK_DATA ์ ๊ฑฐ ๋ฐ ์นดํ ๊ณ ๋ฆฌ ์ด๋ฆ์ ์ค์ ์๋ต์ผ๋ก ๋งคํํ์ธ์. ์ด ํ์ผ์์๋ ๋ฉ๋ด๊ฐ ์นดํ
๊ณ ๋ฆฌ ๊ธฐ์ค์ผ๋ก ์ด๋ฆฌ๋ฏ๋ก, ๋ชฉ์
์ โ์์ดํ
idโ๋ก ์ ๋ชฉ์ ์ฐพ๋ ํ ๊ตฌํ์ ๋ถ์ผ์น์
๋๋ค. ์๋ต์ -import { Badge, Card } from '@pinback/design-system/ui';
+import { Badge, Card } from '@pinback/design-system/ui';
@@
-import { REMIND_MOCK_DATA } from './constants';- const getItemTitle = (id: number | null) =>
- id == null ? '' : (REMIND_MOCK_DATA.find((d) => d.id === id)?.title ?? '');
+ const getCategoryName = (id: number | null) =>
+ id == null ? '' : (categoryNameById.get(id) ?? '');์ถ๊ฐ๋ก ์๋ ๋งคํ์ ์ ์ธํ์ธ์: // ์ถ๊ฐ ์ฝ๋ (์ ํํ ์์น์ ์ฝ์
)
import { useMemo } from 'react';
const categoryNameById = useMemo(() => {
const m = new Map<number, string>();
data?.articles?.forEach((a) => m.set(a.category.categoryId, a.category.categoryName));
return m;
}, [data?.articles]);๊ทธ๋ฆฌ๊ณ Portal prop ์ด๋ฆ๊ณผ ํธ์ถ๋ถ๋ฅผ ๋ง์ถฐ ์ฃผ์ธ์: - getCategoryName={getItemTitle}
+ getCategoryName={getCategoryName}๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| import { useGetRemindArticles } from './apis/queries'; | ||||||||||||||||||||||||||||||||||||||||||||||
| import { formatLocalDateTime } from '@shared/utils/formatDateTime'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const Remind = () => { | ||||||||||||||||||||||||||||||||||||||||||||||
| const [isEditOpen, setIsEditOpen] = useState(false); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||
| state: menu, | ||||||||||||||||||||||||||||||||||||||||||||||
| open: openMenu, | ||||||||||||||||||||||||||||||||||||||||||||||
| close: closeMenu, | ||||||||||||||||||||||||||||||||||||||||||||||
| style, | ||||||||||||||||||||||||||||||||||||||||||||||
| containerRef, | ||||||||||||||||||||||||||||||||||||||||||||||
| } = useAnchoredMenu((anchor) => belowOf(anchor, 8)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| const getItemTitle = (id: number | null) => | ||||||||||||||||||||||||||||||||||||||||||||||
| id == null ? '' : (REMIND_MOCK_DATA.find((d) => d.id === id)?.title ?? ''); | ||||||||||||||||||||||||||||||||||||||||||||||
| const [activeBadge, setActiveBadge] = useState('notRead'); | ||||||||||||||||||||||||||||||||||||||||||||||
| const formattedDate = formatLocalDateTime(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -46,9 +63,41 @@ const Remind = () => { | |||||||||||||||||||||||||||||||||||||||||||||
| content={article.memo} | ||||||||||||||||||||||||||||||||||||||||||||||
| timeRemaining={article.remindAt} | ||||||||||||||||||||||||||||||||||||||||||||||
| category={article.category.categoryName} | ||||||||||||||||||||||||||||||||||||||||||||||
| onOptionsClick={(e) => | ||||||||||||||||||||||||||||||||||||||||||||||
| openMenu(article.category.categoryId, e.currentTarget) | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||
| ))} | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| <OptionsMenuPortal | ||||||||||||||||||||||||||||||||||||||||||||||
| open={menu.open} | ||||||||||||||||||||||||||||||||||||||||||||||
| style={style ?? undefined} | ||||||||||||||||||||||||||||||||||||||||||||||
| containerRef={containerRef} | ||||||||||||||||||||||||||||||||||||||||||||||
| categoryId={menu.categoryId} | ||||||||||||||||||||||||||||||||||||||||||||||
| getCategoryName={getItemTitle} | ||||||||||||||||||||||||||||||||||||||||||||||
| onEdit={() => { | ||||||||||||||||||||||||||||||||||||||||||||||
| setIsEditOpen(true); | ||||||||||||||||||||||||||||||||||||||||||||||
| closeMenu(); | ||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||
| onDelete={(id) => { | ||||||||||||||||||||||||||||||||||||||||||||||
| console.log('delete', id); | ||||||||||||||||||||||||||||||||||||||||||||||
| closeMenu(); | ||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||
| onClose={closeMenu} | ||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| {isEditOpen && ( | ||||||||||||||||||||||||||||||||||||||||||||||
| <div className="fixed inset-0 z-[1000]" aria-modal="true" role="dialog"> | ||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||
| className="absolute inset-0 bg-black/60 backdrop-blur-[2px]" | ||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => setIsEditOpen(false)} | ||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||
| <div className="absolute inset-0 flex items-center justify-center p-4"> | ||||||||||||||||||||||||||||||||||||||||||||||
| <CardEditModal onClose={() => setIsEditOpen(false)} /> | ||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+90
to
100
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. ๐ ๏ธ Refactor suggestion ๋ชจ๋ฌ z-index ์ํฅ Portal์ด zIndex 10000์ด๋ฏ๋ก ๋ชจ๋ฌ ๋ํผ๋ฅผ ๊ทธ๋ณด๋ค ๋๊ฒ ์ก์ ๋๋ ํธ์ด ์์ ํฉ๋๋ค. - <div className="fixed inset-0 z-[1000]" aria-modal="true" role="dialog">
+ <div className="fixed inset-0 z-[11000]" aria-modal="true" role="dialog">๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ interface MyBookmarkCardProps { | |
| category?: string; | ||
| imageUrl?: string; | ||
| date: string; | ||
| onClick?: () => void; | ||
| onOptionsClick?: (e: React.MouseEvent<HTMLButtonElement>) => void; | ||
|
Comment on lines
+11
to
+12
Member
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. ์ ๊ฐ ํด๋น ์ต์
ํด๋ฆญ ์ธํฐํ์ด์ค๋ฅผ ๋์ณค๋ค์..๊ฐ์ฌํฉ๋๋ค!!
Collaborator
Author
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 MyBookmarkCard = ({ | ||
|
|
@@ -16,6 +18,7 @@ const MyBookmarkCard = ({ | |
| category, | ||
| imageUrl, | ||
| date, | ||
| onOptionsClick, | ||
| }: MyBookmarkCardProps) => { | ||
| return ( | ||
| <BaseCard> | ||
|
|
@@ -38,6 +41,7 @@ const MyBookmarkCard = ({ | |
| type="button" | ||
| aria-label="์นดํ ๊ณ ๋ฆฌ ์์ธ" | ||
| className="cursor-pointer self-start" | ||
| onClick={(e) => onOptionsClick?.(e)} | ||
| > | ||
| <Icon name="ic_details_category" /> | ||
| </button> | ||
|
|
||
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.
REMIND_MOCK_DATA ์์กด ์ ๊ฑฐ ๋ฐ ๋ถ๋งํฌ ๋ฐ์ดํฐ๋ก ์ด๋ฆ/ํ์ดํ ๋งคํํ์ธ์.
๋ถ๋งํฌ ํ์ด์ง์์ ๋ฆฌ๋ง์ธ๋ ๋ชฉ์ ์ ์ฐธ์กฐํ๋ฉด ์๋ชป๋ ํ ์คํธ๊ฐ ๋ ธ์ถ๋ ์ ์์ต๋๋ค. ์ค์ ๋ถ๋งํฌ API ์๋ต(articles)์ articleIdโํ์ ๋ฌธ์์ด(URL/์ ๋ชฉ) ๋งคํ์ ๊ตฌ์ฑํด ์ฌ์ฉํ์ธ์.
์ ์ฉ ์:
์ถ๊ฐ๋ก ์๋ ๋งคํ์ ํ์ผ ๋ด ์ ์ ํ ์์น์ ์ ์ธํ์ธ์(์: ์ฟผ๋ฆฌ ํ ์๋):
๐ค Prompt for AI Agents