Skip to content
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

fix(my-info): 카드 추가 UI 오류 수정 #91

Merged
merged 3 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading