diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index b27049d..cd28e0a 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -18,7 +18,13 @@ import { useNavigate } from 'react-router-dom'; import { deleteModeration, getModerationList, ModerationType, postModeration, putModeration } from '@/api/moderation'; import { ModerationList } from './components/moderationList'; -import { dateToAmPmTimeFormat, getFirstDateOfMonth, getLastDateOfMonth, isSameDate } from '@/utils/date'; +import { + dateToAmPmTimeFormat, + getFirstDateOfMonth, + getLastDateOfMonth, + isSameDate, + isTwoHourPassing, +} from '@/utils/date'; export default function HomePage() { const [selectedDate, setSelectedDate] = useState(new Date()); @@ -318,12 +324,14 @@ export default function HomePage() { > 삭제 - + {selectedModeration && !isTwoHourPassing(selectedModeration.regDtm) ? ( + + ) : null} { return `${year}.${month}.${day}`; }; + +export const isTwoHourPassing = (date: string) => { + const newDate = new Date(date).getTime(); + if (isNaN(newDate)) { + throw new Error('Invalid date string'); + } + const currentTime = new Date().getTime(); + const twoHoursInMilliseconds = 2 * 60 * 60 * 1000; + + return currentTime - newDate >= twoHoursInMilliseconds; +};