Skip to content

Commit

Permalink
카드 추가 후 에디터로 이동
Browse files Browse the repository at this point in the history
  • Loading branch information
woo-jk committed Aug 24, 2024
1 parent 4f56352 commit 6f5ef65
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/app/(sidebar)/(my-info)/components/AddInfoCardDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,32 @@ import { Spacing } from '@/system/utils/Spacing';
import { useGetCardTags } from '../apis/useGetCardTags';
import { usePostCard } from '../apis/usePostCard';
import { TouchButton } from '@/components/TouchButton';

const mockTagList: TagType[] = [
{ id: 1, name: 'IT', type: '역량' },
{ id: 2, name: 'UI/UX', type: '인성' },
{ id: 3, name: '프로젝트 경험', type: '역량' },
];
import { useRouter } from 'next/navigation';

export function AddInfoCardDialog({ children }: PropsWithChildren) {
const router = useRouter();

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

const [isOpenTagSelector, setIsOpenTagSelector] = useState(false);
const [isOpenTypeSelector, setIsOpenTypeSelector] = useState(false);

const { data: tagList } = useGetCardTags();
const { mutate: mutatePostCard } = usePostCard();
const { mutateAsync: mutatePostCard } = usePostCard();

const abilityTagList = tagList?.filter((tag) => tag.type === '역량') ?? [];
const personalityTagList = tagList?.filter((tag) => tag.type === '인성') ?? [];

const handleCreateCard = () => {
const handleCreateCard = async () => {
if (!selectedType || !selectedTagList.length) return;

mutatePostCard({
const res = await mutatePostCard({
cardType: selectedType,
tagIdList: selectedTagList.map(({ id }) => id),
});

router.push(`/write/${res.id}`);
};

return (
Expand Down

0 comments on commit 6f5ef65

Please sign in to comment.