import { useAssignmentSubmission } from '@components/Contexts/Assignments/AssignmentSubmissionContext' import { BookPlus, BookUser, EllipsisVertical, FileUp, Forward, InfoIcon, ListTodo, Save, Type } from 'lucide-react' import React, { useEffect } from 'react' import { useLHSession } from '@components/Contexts/LHSessionContext' type AssignmentBoxProps = { type: 'quiz' | 'file' | 'form' view?: 'teacher' | 'student' | 'grading' | 'custom-grading' maxPoints?: number currentPoints?: number saveFC?: () => void submitFC?: () => void gradeFC?: () => void gradeCustomFC?: (grade: number) => void showSavingDisclaimer?: boolean children: React.ReactNode } function AssignmentBoxUI({ type, view, currentPoints, maxPoints, saveFC, submitFC, gradeFC, gradeCustomFC, showSavingDisclaimer, children }: AssignmentBoxProps) { const [customGrade, setCustomGrade] = React.useState(0) const submission = useAssignmentSubmission() as any const session = useLHSession() as any useEffect(() => { console.log(submission) }, [submission]) // Check if user is authenticated const isAuthenticated = session?.status === 'authenticated' return (
{/* Left side with type and badges */}
{type === 'quiz' &&

Quiz

} {type === 'file' &&

File Submission

} {type === 'form' &&

Form

}
{view === 'teacher' &&

Teacher view

} {maxPoints &&

{maxPoints} points

}
{/* Right side with buttons and actions */}
{showSavingDisclaimer &&

Don't forget to save your progress

} {/* Teacher button */} {view === 'teacher' &&
saveFC && saveFC()} className='flex px-2 py-1 cursor-pointer rounded-md space-x-2 items-center bg-linear-to-bl text-emerald-700 bg-emerald-300/20 hover:bg-emerald-300/10 hover:outline-offset-4 active:outline-offset-1 linear transition-all outline-offset-2 outline-dashed outline-emerald-500/60'>

Save

} {/* Student button - only show if authenticated */} {view === 'student' && isAuthenticated && submission && submission.length <= 0 &&
submitFC && submitFC()} className='flex px-2 py-1 cursor-pointer rounded-md space-x-2 items-center justify-center mx-auto w-full sm:w-auto bg-linear-to-bl text-emerald-700 bg-emerald-300/20 hover:bg-emerald-300/10 hover:outline-offset-4 active:outline-offset-1 linear transition-all outline-offset-2 outline-dashed outline-emerald-500/60'>

Save your progress

} {/* Grading button */} {view === 'grading' &&

Current points: {currentPoints}

gradeFC && gradeFC()} className='bg-linear-to-bl text-orange-700 bg-orange-300/20 hover:bg-orange-300/10 items-center flex rounded-md px-2 py-1 space-x-2 ml-auto'>

Grade

} {/* CustomGrading button */} {view === 'custom-grading' && maxPoints &&

Current points: {currentPoints}

setCustomGrade(parseInt(e.target.value))} placeholder={maxPoints.toString()} className='w-full sm:w-[100px] light-shadow text-sm py-0.5 outline outline-gray-200 rounded-lg px-2' type="number" />
gradeCustomFC && gradeCustomFC(customGrade)} className='bg-linear-to-bl text-orange-700 bg-orange-300/20 hover:bg-orange-300/10 items-center flex rounded-md px-2 py-1 space-x-2 whitespace-nowrap'>

Grade

}
{children}
) } export default AssignmentBoxUI