Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthrough문서에 TanStack Query 사용 예시와 레거시 axios 예시를 추가하고, 그룹 스터디 폼에 날짜 검증(superRefine)을 도입했으며 UI에서 한국 시간 기준으로 날짜 최소값을 내일로 변경했습니다. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/features/study/group/model/group-study-form.schema.ts`:
- Around line 105-139: The validation wrongly parses YYYY-MM-DD into local Date
via parseDate causing timezone drift; replace the date arithmetic with pure
string comparisons using KST-based reference strings: import getKoreaDate (and
use the same format function used by the UI, e.g., formatKoreaYMD) to compute
tomorrowKstYmd, then for the startDate check (ISO_DATE_REGEX and data.startDate)
compare data.startDate < tomorrowKstYmd and call ctx.addIssue if true; likewise,
for the endDate vs startDate check (ISO_DATE_REGEX on both) compare data.endDate
< data.startDate and call ctx.addIssue if true, removing reliance on
parseDate/new Date for validation.
| const parseDate = (s: string) => { | ||
| const [y, m, d] = s.split('-').map(Number); | ||
|
|
||
| return new Date(y, m - 1, d); | ||
| }; | ||
|
|
||
| if (ISO_DATE_REGEX.test(data.startDate)) { | ||
| const start = parseDate(data.startDate); | ||
| const today = new Date(); | ||
| const tomorrow = new Date( | ||
| today.getFullYear(), | ||
| today.getMonth(), | ||
| today.getDate() + 1, | ||
| ); | ||
|
|
||
| if (start < tomorrow) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message: '스터디 시작일은 내일부터 설정할 수 있습니다.', | ||
| path: ['startDate'], | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| // 종료일은 시작일과 같거나 이후여야 함 | ||
| if (ISO_DATE_REGEX.test(data.startDate) && ISO_DATE_REGEX.test(data.endDate)) { | ||
| const start = parseDate(data.startDate); | ||
| const end = parseDate(data.endDate); | ||
| if (end < start) { | ||
| ctx.addIssue({ | ||
| code: z.ZodIssueCode.custom, | ||
| message: '종료일은 시작일과 같거나 이후여야 합니다.', | ||
| path: ['endDate'], | ||
| }); | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, let's examine the actual schema file
cat -n src/features/study/group/model/group-study-form.schema.ts | head -150Repository: code-zero-to-one/study-platform-client
Length of output: 5392
🏁 Script executed:
# Check if getKoreaDate utility exists and how it's implemented
fd -t f "time" src/utils --exec cat -n {} \;Repository: code-zero-to-one/study-platform-client
Length of output: 5638
🏁 Script executed:
# Search for getKoreaDate usage in the UI
rg "getKoreaDate|formatKoreaYMD" src/features/study/group -B 2 -A 2Repository: code-zero-to-one/study-platform-client
Length of output: 1441
🏁 Script executed:
# Check the full schema file to understand context
wc -l src/features/study/group/model/group-study-form.schema.tsRepository: code-zero-to-one/study-platform-client
Length of output: 143
🏁 Script executed:
# Verify the endDate comparison logic in the proposed fix
rg "endDate.*startDate" src/features/study/group -B 3 -A 3Repository: code-zero-to-one/study-platform-client
Length of output: 64
스키마의 로컬 타임존 해석으로 인한 KST 검증 불일치 해결 필요
UI에서 formatKoreaYMD(addDays(getKoreaDate(), 1))로 KST 기준 내일 날짜를 min 속성으로 설정하지만, 스키마의 parseDate()는 new Date(y, m-1, d)로 브라우저의 로컬 타임존으로 해석합니다. 따라서 KST가 아닌 다른 타임존의 사용자에게서는 검증 결과가 어긋납니다.
YYYY-MM-DD 문자열 직접 비교로 타임존 해석을 완전히 제거하는 것이 안전합니다.
권장 수정안
if (ISO_DATE_REGEX.test(data.startDate)) {
- const start = parseDate(data.startDate);
- const today = new Date();
- const tomorrow = new Date(
- today.getFullYear(),
- today.getMonth(),
- today.getDate() + 1,
- );
-
- if (start < tomorrow) {
+ const todayKst = getKoreaDate();
+ const tomorrow = new Date(todayKst);
+ tomorrow.setDate(todayKst.getDate() + 1);
+ const toYmd = (d: Date) =>
+ `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(
+ d.getDate(),
+ ).padStart(2, '0')}`;
+ const tomorrowYmd = toYmd(tomorrow);
+
+ if (data.startDate < tomorrowYmd) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: '스터디 시작일은 내일부터 설정할 수 있습니다.',
path: ['startDate'],
});
}
}
// 종료일은 시작일과 같거나 이후여야 함
if (ISO_DATE_REGEX.test(data.startDate) && ISO_DATE_REGEX.test(data.endDate)) {
- const start = parseDate(data.startDate);
- const end = parseDate(data.endDate);
- if (end < start) {
+ if (data.endDate < data.startDate) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: '종료일은 시작일과 같거나 이후여야 합니다.',
path: ['endDate'],
});
}
}상단에 import { getKoreaDate } from '@/utils/time'; 추가 필요.
🤖 Prompt for AI Agents
In `@src/features/study/group/model/group-study-form.schema.ts` around lines 105 -
139, The validation wrongly parses YYYY-MM-DD into local Date via parseDate
causing timezone drift; replace the date arithmetic with pure string comparisons
using KST-based reference strings: import getKoreaDate (and use the same format
function used by the UI, e.g., formatKoreaYMD) to compute tomorrowKstYmd, then
for the startDate check (ISO_DATE_REGEX and data.startDate) compare
data.startDate < tomorrowKstYmd and call ctx.addIssue if true; likewise, for the
endDate vs startDate check (ISO_DATE_REGEX on both) compare data.endDate <
data.startDate and call ctx.addIssue if true, removing reliance on parseDate/new
Date for validation.
🌱 연관된 이슈
☘️ 작업 내용
🍀 참고사항
스크린샷 (선택)
Summary by CodeRabbit
버그 수정 및 개선사항
문서