Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,7 @@ function ReviewSection({
key={review.id}
userName={review.user.nickname}
avatarSrc={review.user.profileImageUrl}
date={new Date(review.createdAt).toLocaleDateString('ko-KR', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
})}
date={review.createdAt.slice(0, 10).replace(/-/g, '.')}
reviewText={review.content}
Comment on lines +62 to 63
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

날짜 포맷팅 방식 견고성 부족

slice(0, 10).replace(/-/g, '.') 는 ISO-8601 형식이 아닐 경우 깨질 수 있습니다.
dayjs, date-fns 등의 라이브러리 사용을 권장합니다.

- date={review.createdAt.slice(0, 10).replace(/-/g, '.')}
+ import dayjs from 'dayjs';
+ ...
+ date={dayjs(review.createdAt).format('YYYY.MM.DD')}
🤖 Prompt for AI Agents
In src/app/(with-header)/activities/[id]/components/ReviewSection.tsx around
lines 62 to 63, the current date formatting uses slice and replace on
review.createdAt, which is fragile if the date is not in ISO-8601 format.
Replace this manual string manipulation with a robust date formatting method by
importing and using a library like dayjs or date-fns to parse and format the
date safely.

/>
));
Expand Down
23 changes: 21 additions & 2 deletions src/app/(with-header)/myactivity/[id]/hooks/useEditActivityForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,29 @@ export const useEditActivityForm = () => {
}

const newSchedules = dates.filter((d) => !d.id);

const scheduleIdsToRemove = originalSchedules
.filter((orig) => !dates.some((d) => d.id === orig.id))
.map((d) => d.id)
.filter((id): id is number => id !== undefined);
.map((d) => d.id!)
.filter(Boolean);
Comment on lines +147 to +148
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

타입 안전성 개선 제안

d.id!의 non-null assertion 사용은 런타임 에러 위험이 있습니다. 더 안전한 타입 가드를 사용하는 것을 권장합니다.

다음과 같이 수정하세요:

-        .map((d) => d.id!)
-        .filter(Boolean);
+        .map((d) => d.id)
+        .filter((id): id is number => id !== undefined);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.map((d) => d.id!)
.filter(Boolean);
.map((d) => d.id)
.filter((id): id is number => id !== undefined);
🤖 Prompt for AI Agents
In src/app/(with-header)/myactivity/[id]/hooks/useEditActivityForm.ts at lines
147-148, the use of non-null assertion `d.id!` can cause runtime errors if `id`
is null or undefined. Replace the non-null assertion with a type-safe guard by
filtering out items where `d.id` is falsy before mapping, or use a conditional
check within the map to ensure only defined `id`s are processed. This will
improve type safety and prevent potential runtime exceptions.


originalSchedules.forEach((orig) => {
const matched = dates.find((d) => d.id === orig.id);
if (
matched &&
(matched.date !== orig.date ||
matched.startTime !== orig.startTime ||
matched.endTime !== orig.endTime)
) {
newSchedules.push({
date: matched.date,
startTime: matched.startTime,
endTime: matched.endTime,
});

scheduleIdsToRemove.push(orig.id!);
}
});

const parsedPrice = parseInt(price, 10);
if (isNaN(parsedPrice) || parsedPrice <= 0) {
Expand Down