@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
22import { useAuth } from '../contexts/AuthContext' ;
33import { getFunctions , httpsCallable } from 'firebase/functions' ;
44import { getFirestore , collection , doc , getDoc , getDocs , onSnapshot , query , orderBy , limit } from 'firebase/firestore' ;
5+ import DOCUMENT_TYPES , { DocumentType } from '../constants/documentTypes' ;
56
67interface Document {
78 id : string ;
@@ -19,7 +20,7 @@ interface Prediction {
1920const DocumentUploader : React . FC = ( ) => {
2021 const { currentUser } = useAuth ( ) ;
2122 const [ file , setFile ] = useState < File | null > ( null ) ;
22- const [ documentType , setDocumentType ] = useState < string > ( 'syllabus' ) ;
23+ const [ documentType , setDocumentType ] = useState < string > ( DOCUMENT_TYPES . SYLLABUS ) ;
2324 const [ uploadProgress , setUploadProgress ] = useState < number > ( 0 ) ;
2425 const [ isUploading , setIsUploading ] = useState < boolean > ( false ) ;
2526 const [ documents , setDocuments ] = useState < Document [ ] > ( [ ] ) ;
@@ -37,7 +38,7 @@ const DocumentUploader: React.FC = () => {
3738 // Get user's documents
3839 const getUserDocuments = async ( ) => {
3940 try {
40- const getUserDocumentsFunction = httpsCallable ( functions , 'get_user_documents ' ) ;
41+ const getUserDocumentsFunction = httpsCallable ( functions , 'getUserDocuments ' ) ;
4142 const result = await getUserDocumentsFunction ( { } ) ;
4243 if ( result . data && ( result . data as any ) . success ) {
4344 setDocuments ( ( result . data as any ) . documents || [ ] ) ;
@@ -94,8 +95,8 @@ const DocumentUploader: React.FC = () => {
9495 const base64String = fileReader . result as string ;
9596
9697 try {
97- // Call upload_and_process_document cloud function
98- const uploadAndProcessDocument = httpsCallable ( functions , 'upload_and_process_document ' ) ;
98+ // Call uploadDocument cloud function
99+ const uploadAndProcessDocument = httpsCallable ( functions , 'uploadDocument ' ) ;
99100 const result = await uploadAndProcessDocument ( {
100101 documentType : documentType ,
101102 documentBase64 : base64String
@@ -224,8 +225,8 @@ const DocumentUploader: React.FC = () => {
224225 credit_hours : syllabusData . credit_hours || '3'
225226 } ;
226227
227- // Call predict_final_grade cloud function
228- const predictFinalGrade = httpsCallable ( functions , 'predict_final_grade ' ) ;
228+ // Call predictFinalGrade cloud function
229+ const predictFinalGrade = httpsCallable ( functions , 'predictFinalGrade ' ) ;
229230 const result = await predictFinalGrade ( { courseData } ) ;
230231
231232 const data = result . data as any ;
@@ -236,7 +237,7 @@ const DocumentUploader: React.FC = () => {
236237 setIsUploading ( false ) ;
237238
238239 // Refresh documents list
239- const getUserDocuments = httpsCallable ( functions , 'get_user_documents ' ) ;
240+ const getUserDocuments = httpsCallable ( functions , 'getUserDocuments ' ) ;
240241 const docsResult = await getUserDocuments ( { } ) ;
241242 if ( docsResult . data && ( docsResult . data as any ) . success ) {
242243 setDocuments ( ( docsResult . data as any ) . documents || [ ] ) ;
@@ -295,8 +296,10 @@ const DocumentUploader: React.FC = () => {
295296 style = { styles . select }
296297 disabled = { isUploading }
297298 >
298- < option value = "syllabus" > Syllabus</ option >
299- < option value = "transcript" > Transcript</ option >
299+ < option value = { DOCUMENT_TYPES . SYLLABUS } > Syllabus</ option >
300+ < option value = { DOCUMENT_TYPES . TRANSCRIPT } > Transcript</ option >
301+ < option value = { DOCUMENT_TYPES . GRADES } > Grades</ option >
302+ < option value = { DOCUMENT_TYPES . OTHER } > Other</ option >
300303 </ select >
301304 </ div >
302305
0 commit comments