add date.ts for global formatting, remove redundant pill completed : in progress from viewAssignmentDetails.tsx

This commit is contained in:
Fhj0607
2026-04-29 11:37:27 +02:00
parent 473eb0efbb
commit 67c625f42c
3 changed files with 35 additions and 47 deletions

View File

@@ -1,3 +1,4 @@
import { formatDate, formatDateTime } from '@/lib/date';
import { CheckSubjectCompletion } from '@/lib/progress';
import { SUBJECT_COLORS, type SubjectColor } from '@/lib/subjectColors';
import { supabase } from '@/lib/supabase';
@@ -17,37 +18,6 @@ export type Subject = {
color: SubjectColor;
};
const formatDate = (value?: string | null) => {
if (!value) return 'No date';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return value;
return date.toLocaleDateString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
});
};
const formatDateTime = (value?: string | null) => {
if (!value) return 'Unknown';
const date = new Date(value);
if (Number.isNaN(date.getTime())) return value;
return date.toLocaleString(undefined, {
year: 'numeric',
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
});
};
export default function ViewDetailsSubject() {
const { sId } = useLocalSearchParams<{ sId: string }>();
const [subject, SetSubject] = useState<Subject | null>(null);