Skip to content

Commit

Permalink
fix(my-info): 카드 추가 UI 오류 수정 (#91)
Browse files Browse the repository at this point in the history
* Fix

* fix

* remove
  • Loading branch information
Collection50 authored Sep 14, 2024
1 parent 4d2b715 commit 7fdab03
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions src/app/(sidebar)/(my-info)/components/AddInfoCardDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Icon } from '@/system/components';
import { Dialog, DialogClose, DialogContent, DialogTitle, DialogTrigger } from '@/system/components/Dialog/Dialog';
import { TagType, InfoType, INFO_TYPES } from '@/types/info';
import { PropsWithChildren, useState } from 'react';
import { PropsWithChildren, useEffect, useState } from 'react';
import { TagSelector } from '../../write/[id]/components/TagSelector/TagSelector';
import { If } from '@/system/utils/If';
import { cn } from '@/utils/tailwind-util';
Expand All @@ -12,11 +12,14 @@ import { TouchButton } from '@/components/TouchButton';
import { useRouter } from 'next/navigation';
import { motion } from 'framer-motion';

export function AddInfoCardDialog({ children }: PropsWithChildren) {
export function AddInfoCardDialog({
children,
currentCardType = '경험_정리',
}: PropsWithChildren<{ currentCardType?: InfoType }>) {
const router = useRouter();

const [selectedTagList, setSelectedTagList] = useState<TagType[]>([]);
const [selectedType, setSelectedType] = useState<InfoType | null>(null);
const [selectedType, setSelectedType] = useState<InfoType | null>(currentCardType || null);

const [isOpenTagSelector, setIsOpenTagSelector] = useState(false);
const [isOpenTypeSelector, setIsOpenTypeSelector] = useState(false);
Expand All @@ -38,6 +41,10 @@ export function AddInfoCardDialog({ children }: PropsWithChildren) {
router.push(`/write/${res.cardId}`);
};

useEffect(() => {
setSelectedType(currentCardType);
}, [currentCardType]);

return (
<Dialog
onOpenChange={(open) => {
Expand Down Expand Up @@ -102,7 +109,7 @@ export function AddInfoCardDialog({ children }: PropsWithChildren) {
{abilityTagList.map((tag) => (
<TagSelector.Tag
key={tag.id}
className="text-blue-blue-text-1 bg-blue-blue-bg-1"
className="text-blue-text-1 bg-blue-bg-1"
onClick={() => {
if (selectedTagList.length < 3 && !selectedTagList.find(({ id }) => id === tag.id)) {
setSelectedTagList((prev) => [...prev, tag]);
Expand All @@ -119,7 +126,7 @@ export function AddInfoCardDialog({ children }: PropsWithChildren) {
{personalityTagList.map((tag) => (
<TagSelector.Tag
key={tag.id}
className="text-blue-purple-text-1 bg-blue-purple-bg-1"
className="text-purple-text-1 bg-purple-bg-1"
onClick={() => {
if (selectedTagList.length < 3 && !selectedTagList.find(({ id }) => id === tag.id)) {
setSelectedTagList((prev) => [...prev, tag]);
Expand Down
2 changes: 1 addition & 1 deletion src/app/(sidebar)/(my-info)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function MyInfo() {
))}
</div>
</If>
<AddInfoCardDialog>
<AddInfoCardDialog currentCardType={currentCardType}>
<TouchButton layout>
<motion.div
initial={{ padding: '8px 16px' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export function DeleteMemoDialog({

<DialogContent className="border-1 w-460 h-232 p-32 pt-24 flex flex-col gap-36">
<div className="mt-36 text-20 font-bold text-center flex flex-col items-center justify-center">
<div className="flex">
<div className="flex w-fit gap-5">
<span>'</span>
<p className="w-370 overflow-hidden text-ellipsis whitespace-nowrap">{memo}</p>
<p className="max-w-370 w-fit overflow-hidden text-ellipsis whitespace-nowrap">{memo}</p>
<span>'</span>
</div>
<p>메모를 정말 삭제하시겠습니까?</p>
Expand Down

0 comments on commit 7fdab03

Please sign in to comment.