feat: listPage에서 나오는 시간 형식 통일

This commit is contained in:
minwucho 2024-08-09 14:46:22 +09:00
parent 591cfa1e30
commit 11cc9c55ea
4 changed files with 4 additions and 25 deletions

View File

@ -8,7 +8,6 @@ export default function NoticeListPage() {
const { data } = useFreeboards(lectureId);
const notices = data?.data;
console.log(notices);
return (
<ArticleBoard
title="자유게시판"
@ -18,7 +17,7 @@ export default function NoticeListPage() {
<ArticleLink
key={`${notice.id}`}
title={notice.title}
sub={`${notice.createdAt[0]}. ${notice.createdAt[1]}. ${notice.createdAt[2]}. ${notice.createdAt[3]}:${notice.createdAt[4]}`}
sub={`${new Date(notice.createdAt).toLocaleDateString()} ${new Date(notice.createdAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
to={`${notice.id}`}
/>
))}

View File

@ -20,9 +20,7 @@ export default function NoticeListPage() {
<ArticleLink
key={`${notice.id}`}
title={notice.title}
//Todo: createdAt Q&A .
// + Q&A .
sub={`${notice.createdAt[0]}. ${notice.createdAt[1]}. ${notice.createdAt[2]}. ${notice.createdAt[3]}:${notice.createdAt[4]}`}
sub={`${new Date(notice.createdAt).toLocaleDateString()} ${new Date(notice.createdAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
to={`${notice.id}`}
/>
))}

View File

@ -8,14 +8,6 @@ export default function TeacherReportsetDetailPage() {
const { data } = useReportSetDetail(reportsetId);
const reports = data?.data;
const formatDate = (dateArray) => {
const date = new Date(...dateArray.slice(0, 6));
return date.toLocaleString('ko-KR', {
hour12: true,
timeZone: 'Asia/Seoul',
});
};
return (
<ArticleBoard
title="퀴즈 조회"
@ -23,7 +15,6 @@ export default function TeacherReportsetDetailPage() {
>
{reports.length &&
reports.map?.((report) => {
const formattedDate = formatDate(report.date);
return (
<ArticleLink
key={`${report.reportId}`}
@ -32,7 +23,7 @@ export default function TeacherReportsetDetailPage() {
? `${report.name} - 미응시`
: `${report.name} - ${report.title} 점수: ${report.correctCount}/${report.allCount}`
}
sub={`${formattedDate}`}
sub={`${new Date(report.testAt).toLocaleDateString()} ${new Date(report.testAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
to={`../report/${report.reportId}`}
/>
);

View File

@ -8,26 +8,17 @@ export default function TeacherReportsetPage() {
const { data } = useReportSets(lectureId);
const reports = data?.data;
const formatDate = (dateArray) => {
const date = new Date(...dateArray.slice(0, 6));
return date.toLocaleString('ko-KR', {
hour12: true,
timeZone: 'Asia/Seoul',
});
};
return (
<ArticleBoard
title="퀴즈 성적 목록"
canCreate={false}
>
{reports.map?.((report) => {
const formattedDate = formatDate(report.testAt);
return (
<ArticleLink
key={`${report.reportSetId}`}
title={`${report.quizSetTitle}`}
sub={formattedDate}
sub={`${new Date(report.testAt).toLocaleDateString()} ${new Date(report.testAt).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`}
to={`${report.reportSetId}`}
/>
);