Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 3 additions & 9 deletions src/pages/Admin/ReportList/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { WaveLoading } from '@/components/WaveLoading';
import { paths } from '@/const/paths';
import { SimpleReport } from '@/interface/report';
import { getFormattedLocaleString } from '@/utils/DateFormat';
import { formatTimeToHoursAndMinutes } from '@/utils/formatTimeToHoursAndMinutes';
import { ChevronRight, Clock } from 'lucide-react';
import { useMemo } from 'react';
import { useQuery } from 'react-query';
Expand All @@ -23,13 +24,6 @@ export default function ReportListAdminPage() {
});
};

// 시간을 시간과 분으로 포맷팅하는 함수
const formatStudyTime = (minutes: number) => {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours}시간 ${mins}분`;
};

const reports = useMemo(() => {
if (!data) return [];
return data.reports;
Expand Down Expand Up @@ -87,14 +81,14 @@ export default function ReportListAdminPage() {
<div className="font-medium">{report.title}</div>
<div className="md:hidden text-xs text-muted-foreground flex items-left mt-1">
<Clock className="h-3 w-3 mr-1" />
{formatStudyTime(report.totalMinutes)}
{formatTimeToHoursAndMinutes(report.totalMinutes)}
</div>
</div>
</TableCell>
<TableCell>
<div className="flex items-center">
<Clock className="h-4 w-4 text-muted-foreground mr-2" />
{formatStudyTime(report.totalMinutes)}
{formatTimeToHoursAndMinutes(report.totalMinutes)}
</div>
</TableCell>

Expand Down
12 changes: 3 additions & 9 deletions src/pages/Admin/ReportList/components/GroupReportListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Table, TableBody, TableCell, TableRow } from '@/components/ui/table';
import { paths } from '@/const/paths';
import { Report } from '@/interface/report';
import { getFormattedLocaleString } from '@/utils/DateFormat';
import { formatTimeToHoursAndMinutes } from '@/utils/formatTimeToHoursAndMinutes';
import { ChevronRight, Clock, Users } from 'lucide-react';
import { useNavigate } from 'react-router-dom';

Expand All @@ -20,13 +21,6 @@ export default function GroupReportListUserView({ reports }: GroupReportListView
});
};

// 시간을 시간과 분으로 포맷팅하는 함수
const formatStudyTime = (minutes: number) => {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours}시간 ${mins}분`;
};

return (
<Card className="py-0">
<CardContent className="p-0">
Expand Down Expand Up @@ -73,7 +67,7 @@ export default function GroupReportListUserView({ reports }: GroupReportListView
<div className="font-medium">{report.title}</div>
<div className="md:hidden text-xs text-muted-foreground flex items-left mt-1">
<Clock className="h-3 w-3 mr-1" />
{formatStudyTime(report.totalMinutes)}
{formatTimeToHoursAndMinutes(report.totalMinutes)}
</div>
<div className="sm:hidden text-xs text-muted-foreground flex items-center mt-1">
<Users className="h-3 w-3 mr-1" />
Expand All @@ -84,7 +78,7 @@ export default function GroupReportListUserView({ reports }: GroupReportListView
<TableCell className="hidden md:table-cell">
<div className="flex items-center">
<Clock className="h-4 w-4 text-muted-foreground mr-2" />
{formatStudyTime(report.totalMinutes)}
{formatTimeToHoursAndMinutes(report.totalMinutes)}
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Expand Down
9 changes: 2 additions & 7 deletions src/pages/ReportDetail/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Report } from '@/interface/report';
import { SimpleUser } from '@/interface/user';
import { roleState } from '@/store/HISAtom';
import { getFormattedLocaleString } from '@/utils/DateFormat';
import { formatTimeToHoursAndMinutes } from '@/utils/formatTimeToHoursAndMinutes';
import { addImagePrefix } from '@/utils/imagePrefix';
import { ArrowLeft, BookOpen, Calendar, Clock, Edit, ImageIcon, Trash2, Users } from 'lucide-react';
import { useMemo } from 'react';
Expand Down Expand Up @@ -73,12 +74,6 @@ export default function ReportDetailPage() {
}
navigate(paths.reports.edit(report.id.toString()), { state: state });
};
// 시간을 시간과 분으로 포맷팅하는 함수
const formatStudyTime = (minutes: number) => {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours}시간 ${mins}분`;
};

if (isLoading) {
return <WaveLoading />;
Expand Down Expand Up @@ -145,7 +140,7 @@ export default function ReportDetailPage() {
<span className="text-muted-foreground flex items-center gap-1.5">
<Clock className="h-3.5 w-3.5" />총 스터디 시간
</span>
<span className="font-medium">{formatStudyTime(report?.totalMinutes || 0)}</span>
<span className="font-medium">{formatTimeToHoursAndMinutes(report?.totalMinutes || 0)}</span>
</div>
<div className="flex items-center justify-between text-sm">
<span className="text-muted-foreground">작성일</span>
Expand Down
11 changes: 3 additions & 8 deletions src/pages/ReportList/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { WaveLoading } from '@/components/WaveLoading';
import { paths } from '@/const/paths';
import { Report } from '@/interface/report';
import { getFormattedLocaleString } from '@/utils/DateFormat';
import { formatTimeToHoursAndMinutes } from '@/utils/formatTimeToHoursAndMinutes';
import { ChevronRight, Clock, PlusCircle, Users } from 'lucide-react';
import { useMemo } from 'react';
import { useQuery } from 'react-query';
Expand All @@ -24,12 +25,6 @@ export default function ReportListUserPage() {
});
};

const formatStudyTime = (minutes: number) => {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours}시간 ${mins}분`;
};

const reports = useMemo(() => {
if (!data) return [];
return data.reports;
Expand Down Expand Up @@ -95,7 +90,7 @@ export default function ReportListUserPage() {
<div className="font-medium">{report.title}</div>
<div className="md:hidden text-xs text-muted-foreground flex items-left mt-1">
<Clock className="h-3 w-3 mr-1" />
{formatStudyTime(report.totalMinutes)}
{formatTimeToHoursAndMinutes(report.totalMinutes)}
</div>
<div className="sm:hidden text-xs text-muted-foreground flex items-center mt-1">
<Users className="h-3 w-3 mr-1" />
Expand All @@ -106,7 +101,7 @@ export default function ReportListUserPage() {
<TableCell className="hidden md:table-cell">
<div className="flex items-center">
<Clock className="h-4 w-4 text-muted-foreground mr-2" />
{formatStudyTime(report.totalMinutes)}
{formatTimeToHoursAndMinutes(report.totalMinutes)}
</div>
</TableCell>
<TableCell className="hidden sm:table-cell">
Expand Down
5 changes: 5 additions & 0 deletions src/utils/formatTimeToHoursAndMinutes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export function formatTimeToHoursAndMinutes(minutes: number) {
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

Add JSDoc documentation to describe the function's purpose, parameter, and return value. For example: /** Formats minutes into Korean time string format (e.g., '3시간 45분') */

Copilot uses AI. Check for mistakes.
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
return `${hours}시간 ${mins}분`;
}
Comment on lines +1 to +5
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

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

The function does not validate input. Consider adding a guard clause to handle negative numbers or non-integer values, e.g., if (minutes < 0 || !Number.isFinite(minutes)) throw new Error('Invalid minutes value');

Copilot uses AI. Check for mistakes.