import { Pressable, View } from 'react-native' import { Card, Avatar, Text } from 'react-native-paper' import { classroomDateTimeToISO } from '@/lib/clients/classroom' import { CourseWorkMaterialUserProfile, CourseWorkUserProfile, } from '@/lib/types/Classroom' import { useRouter } from 'expo-router' export default function CourseWorkCard(props: Props) { const router = useRouter() const getIcon = () => { if (props.isCWM) return 'file-document-outline' return 'clipboard-text-outline' } const getDateString = () => { if (!props.isCWM && props.data.dueDate) { const date = new Date( classroomDateTimeToISO(props.data.dueDate, props.data.dueTime!), ) return `Due ${date.toLocaleDateString()}` } return 'No due date' } return ( router.push( `/drawer/courses/courseWork${props.isCWM ? 'Material' : ''}/${props.data.courseId}/${props.data.id}`, ) } > ( )} right={(ip) => !props.isCWM && props.data.maxPoints && ( {props.data.maxPoints} points ) } /> ) } type Props = | { isCWM: true; data: CourseWorkMaterialUserProfile } | { isCWM: false; data: CourseWorkUserProfile }