fix(date): UTC 기반 날짜를 로컬 타임존으로 변경
- 공통 날짜 유틸리티 함수 추가 (src/utils/date.ts)
- getLocalDateString(): 로컬 타임존 YYYY-MM-DD 포맷
- getTodayString(): 오늘 날짜 반환
- getDateAfterDays(): N일 후 날짜 계산
- formatDateForInput(): API 응답 → input 포맷 변환
- toISOString().split('T')[0] 패턴을 공통 함수로 교체
- 견적: QuoteRegistration, QuoteRegistrationV2, types
- 건설: contract, site-briefings, estimates, bidding types
- 건설: IssueDetailForm, ConstructionDetailClient, ProjectEndDialog
- 자재: InspectionCreate, ReceivingReceiptContent, StockStatus/mockData
- 품질: InspectionManagement/mockData
- 기타: PricingFormClient, ShipmentCreate, PurchaseOrderDocument
- 기타: MainDashboard, attendance/actions, dev/generators
문제: toISOString()은 UTC 기준이라 한국(UTC+9)에서 오전 9시 이전에
전날 날짜가 표시되는 버그 발생
해결: 로컬 타임존 기반 날짜 포맷 함수로 통일
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
import { useState, useCallback, useMemo, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Calendar } from 'lucide-react';
|
||||
import { getTodayString } from '@/utils/date';
|
||||
import { IntegratedDetailTemplate } from '@/components/templates/IntegratedDetailTemplate';
|
||||
import { materialInspectionCreateConfig } from './inspectionConfig';
|
||||
import { ContentSkeleton } from '@/components/ui/skeleton';
|
||||
@@ -66,10 +67,7 @@ export function InspectionCreate({ id }: Props) {
|
||||
const [selectedTargetId, setSelectedTargetId] = useState<string>(id || '');
|
||||
|
||||
// 검사 정보
|
||||
const [inspectionDate, setInspectionDate] = useState(() => {
|
||||
const today = new Date();
|
||||
return today.toISOString().split('T')[0];
|
||||
});
|
||||
const [inspectionDate, setInspectionDate] = useState(() => getTodayString());
|
||||
const [inspector, setInspector] = useState('');
|
||||
const [lotNo, setLotNo] = useState(() => generateLotNo());
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
import type { ReceivingDetail } from './types';
|
||||
import { DocumentHeader } from '@/components/document-system';
|
||||
import { getTodayString } from '@/utils/date';
|
||||
|
||||
interface ReceivingReceiptContentProps {
|
||||
data: ReceivingDetail;
|
||||
@@ -38,7 +39,7 @@ export function ReceivingReceiptContent({ data: detail }: ReceivingReceiptConten
|
||||
<span className="text-muted-foreground">입고번호</span>
|
||||
<span className="font-medium">{detail.orderNo}</span>
|
||||
<span className="text-muted-foreground">입고일자</span>
|
||||
<span>{detail.receivingDate || today.toISOString().split('T')[0]}</span>
|
||||
<span>{detail.receivingDate || getTodayString()}</span>
|
||||
<span className="text-muted-foreground">발주번호</span>
|
||||
<span>{detail.orderNo}</span>
|
||||
<span className="text-muted-foreground">입고LOT</span>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import type { StockItem, StockDetail, StockStats, FilterTab } from './types';
|
||||
import { getLocalDateString } from '@/utils/date';
|
||||
|
||||
// 재고 상태 결정 함수
|
||||
function getStockStatus(stockQty: number, safetyStock: number): 'normal' | 'low' | 'out' {
|
||||
@@ -418,7 +419,7 @@ export function generateStockDetail(item: StockItem): StockDetail {
|
||||
const daysAgo = seededInt(lotSeed, 5, 60);
|
||||
const date = new Date('2025-12-23'); // 고정 날짜 사용
|
||||
date.setDate(date.getDate() - daysAgo);
|
||||
const dateStr = date.toISOString().split('T')[0];
|
||||
const dateStr = getLocalDateString(date);
|
||||
const lotDate = dateStr.replace(/-/g, '').slice(2);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user