Skip to content

Commit

Permalink
refactor : popover 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
qkdl60 committed May 10, 2024
1 parent e741096 commit 081379d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 32 deletions.
5 changes: 1 addition & 4 deletions src/app/plans/edit/[planId]/hooks/usePlanEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useEditPlanMutation } from '@/hooks/apis/useEditPlanMutation';
import { useGetPlanQuery } from '@/hooks/apis/useGetPlanQuery';
import { useWritablePlan } from '@/hooks/useWritablePlan';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import { useEffect } from 'react';

export default function usePlanEditPage(planId: string) {
const router = useRouter();
Expand All @@ -27,7 +27,6 @@ export default function usePlanEditPage(planId: string) {
handleRemoveTag,
handleChangeIconNumber,
} = useWritablePlan(planData);
const [isSelectIconModalOpen, setIsSelectIconModalOpen] = useState(false);

const handleEditPlan = () => {
editPlan(
Expand All @@ -46,10 +45,8 @@ export default function usePlanEditPage(planId: string) {
return {
planId,
nextTextAreaRef,
isSelectIconModalOpen,
planContent,
planData,
setIsSelectIconModalOpen,
handleAddTag,
handleChangeCanAjaja,
handleChangeDescription,
Expand Down
50 changes: 22 additions & 28 deletions src/app/plans/edit/[planId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
DeletableTag,
HelpButton,
IconSwitchButton,
Modal,
ModalSelectIcon,
PlanInput,
Popover,
TagInput,
} from '@/components';
import { planIcons } from '@/constants/planIcons';
Expand All @@ -22,10 +22,8 @@ export default function EditPage({ params }: { params: { planId: string } }) {
const {
planId,
nextTextAreaRef,
isSelectIconModalOpen,
planContent,
planData,
setIsSelectIconModalOpen,
handleAddTag,
handleChangeCanAjaja,
handleChangeDescription,
Expand All @@ -48,25 +46,32 @@ export default function EditPage({ params }: { params: { planId: string } }) {
</div>
<div className="edit-plan-page__content">
<div className="edit-plan-page__icon">
<button
onClick={() => {
setIsSelectIconModalOpen(true);
}}>
<Image
src={`/animal/${planIcons[planContent.iconNumber]}.png`}
alt={`${planIcons[planContent.iconNumber]}`}
width={50}
height={50}
priority
<Popover.Main>
<Popover.Trigger>
<Image
src={`/animal/${planIcons[planContent.iconNumber]}.png`}
alt={`${planIcons[planContent.iconNumber]}`}
width={50}
height={50}
priority
/>
</Popover.Trigger>
<Popover.Content
renderModalContent={(closeModal) => (
<ModalSelectIcon
setIconNumber={handleChangeIconNumber}
closeModal={closeModal}
/>
)}
/>
</button>
</Popover.Main>
<span className="font-size-xs">
아이콘을 클랙해 변경할 수 있어요
</span>
</div>
<div className="edit-plan-page__plan">
<PlanInput
classNameList={['create-plan-content__plan--title']}
classNameList={['create-plan-page__plan--title']}
editable={true}
kind="title"
placeholder="어떤 계획을 가지고 계신가요?"
Expand All @@ -89,7 +94,7 @@ export default function EditPage({ params }: { params: { planId: string } }) {
</div>

<div className={classNames('edit-plan-page__tag')}>
<div className="edit-plan-content__tag--input">
<div className="edit-plan-page__tag--input">
<TagInput
disabled={planContent.tags.length === 5}
onSubmit={handleAddTag}
Expand Down Expand Up @@ -121,7 +126,7 @@ export default function EditPage({ params }: { params: { planId: string } }) {
/>
</div>
<div className="edit-plan-page__switches">
<div className={classNames('edit-plan-content__switches--public')}>
<div className={classNames('edit-plan-page__switches--public')}>
<IconSwitchButton
onIconName="PLAN_OPEN"
offIconName="PLAN_CLOSE"
Expand Down Expand Up @@ -175,17 +180,6 @@ export default function EditPage({ params }: { params: { planId: string } }) {
</Button>
</Link>
</div>

{isSelectIconModalOpen && (
<Modal>
<ModalSelectIcon
setIconNumber={handleChangeIconNumber}
closeModal={() => {
setIsSelectIconModalOpen(false);
}}
/>
</Modal>
)}
</div>
);
}

0 comments on commit 081379d

Please sign in to comment.