Skip to content
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
43 changes: 26 additions & 17 deletions src/app/(protected)/goals/[goalId]/_components/GoalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useUpdateGoalMutation } from "@/hooks/queries/goals/useUpdateGoalMutati
import { useGoalDetail } from "@/hooks/queries/goals/useGoalDetail";
import { useDropdown } from "@/hooks/useDropdown";
import { EllipsisVerticalIcon } from "@heroicons/react/24/outline";
import { useState } from "react";
import { useEffect, useRef, useState } from "react";
import TextButton from "@/components/common/button/TextButton";
import { useDeleteGoalMutation } from "@/hooks/queries/goals/useDeleteGoalMutation";
import ConfirmModal from "@/components/common/popup-modal/ConfirmModal";
Expand All @@ -19,12 +19,18 @@ type GoalHeaderProps = {

export default function GoalHeader({ goalId }: GoalHeaderProps) {
const numericGoalId = Number(goalId);
const inputRef = useRef<HTMLInputElement>(null);
const router = useRouter();

const { data: goal } = useGoalDetail(numericGoalId);
const [confirmOpen, setConfirmOpen] = useState(false);

const [isEditing, setIsEditing] = useState(false);
useEffect(() => {
if (isEditing && inputRef.current) {
inputRef.current.focus();
}
}, [isEditing]);
const [editTitle, setEditTitle] = useState("");

const { mutate: updateGoal } = useUpdateGoalMutation(numericGoalId);
Expand All @@ -42,7 +48,7 @@ export default function GoalHeader({ goalId }: GoalHeaderProps) {
text: "์ˆ˜์ •ํ•˜๊ธฐ",
onClick: () => {
closeDropdown();
setEditTitle("");
setEditTitle(goal?.title ?? "");
setIsEditing(true);
},
},
Expand Down Expand Up @@ -92,21 +98,24 @@ export default function GoalHeader({ goalId }: GoalHeaderProps) {
<h3 className="truncate text-base font-semibold">{goal?.title}</h3>
) : (
<div className="flex w-full gap-2">
<BaseInput
id="goal-title-edit"
className="w-[70%] sm:w-[80%]"
value={editTitle}
type="text"
onChange={(e) => setEditTitle(e.target.value)}
placeholder="์ˆ˜์ •ํ•  ๋ชฉํ‘œ๋ฅผ ์ ์–ด์ฃผ์„ธ์š”."
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleSave();
}
}}
/>

<div className="relative w-full">
<input
ref={inputRef}
name="goal-title-edit"
id="goal-title-edit"
className="focus-visible:ring-none w-[70%] outline-none focus:outline-none sm:w-[80%]"
value={editTitle}
type="text"
onChange={(e) => setEditTitle(e.target.value)}
placeholder="์ˆ˜์ •ํ•  ๋ชฉํ‘œ๋ฅผ ์ ์–ด์ฃผ์„ธ์š”."
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleSave();
}
}}
/>
</div>
<TextButton
onClick={handleSave}
className="w-[20%] sm:w-[10%]">
Expand Down
12 changes: 6 additions & 6 deletions src/app/(protected)/goals/[goalId]/_components/GoalNotesCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ type GoalNotesCardProps = {

export default function GoalNotesCard({ goalId, todoId }: GoalNotesCardProps) {
return (
<div className="transition-al l mt-4 flex h-40 items-end rounded-4xl bg-blue-200 bg-[url('/images/goals/obj-note.png')] bg-size-[98px_auto] bg-position-[right_14px_top_14px] bg-no-repeat px-10 py-7.5 text-white shadow-[0_10px_40px_0_rgba(0,212,190,0.24)] sm:mt-0 sm:h-auto sm:bg-position-[right_4px_top_14px] lg:h-31.25 lg:py-4 xl:h-auto xl:py-7.5">
<Link
href={`/notes?goalId=${goalId}`}
className="flex items-center gap-1 text-2xl font-bold break-keep sm:text-xl lg:text-2xl">
<Link
href={`/notes?goalId=${goalId}`}
className="transition-al l mt-4 flex h-40 items-end rounded-4xl bg-blue-200 bg-[url('/images/goals/obj-note.png')] bg-size-[98px_auto] bg-position-[right_14px_top_14px] bg-no-repeat px-10 py-7.5 text-white shadow-[0_10px_40px_0_rgba(0,212,190,0.24)] sm:mt-0 sm:h-auto sm:bg-position-[right_4px_top_14px] lg:h-31.25 lg:py-4 xl:h-auto xl:py-7.5">
<div className="flex items-center gap-1 text-2xl font-bold break-keep sm:text-xl lg:text-2xl">
๋…ธํŠธ ๋ชจ์•„๋ณด๊ธฐ
<ChevronRightIcon className="ml-0.5 w-5 sm:w-3.5 lg:w-5" />
</Link>
</div>
</div>
</Link>
);
}