diff --git a/src/backend/app/submissions/submission_crud.py b/src/backend/app/submissions/submission_crud.py index 682ed019d7..56f35d4b07 100644 --- a/src/backend/app/submissions/submission_crud.py +++ b/src/backend/app/submissions/submission_crud.py @@ -820,3 +820,28 @@ async def get_submission_by_task( count = data.get("@odata.count", 0) return submissions, count + + +async def get_submission_detail( + project: db_models.DbProject, + task_id: int, + submission_id: str, + db: Session, +): + """Get the details of a submission. + + Args: + project: The project object representing the project. + task_id: The ID of the task associated with the submission. + submission_id: The ID of the submission. + db: The database session. + + Returns: + The details of the submission as a JSON object. + """ + odk_credentials = await project_deps.get_odk_credentials(db, project.id) + odk_form = get_odk_form(odk_credentials) + xform = f"{project.project_name_prefix}_task_{task_id}" + submission = odk_form.getSubmissions(project.odkid, xform, submission_id) + + return json.loads(submission) diff --git a/src/backend/app/submissions/submission_routes.py b/src/backend/app/submissions/submission_routes.py index dcc69fdeed..3946ea2ff5 100644 --- a/src/backend/app/submissions/submission_routes.py +++ b/src/backend/app/submissions/submission_routes.py @@ -413,6 +413,7 @@ async def task_submissions( project: db_models.DbProject = Depends(project_deps.get_project_by_id), page: int = Query(1, ge=1), limit: int = Query(13, le=100), + submission_id: Optional[str] = None, submitted_by: Optional[str] = None, review_state: Optional[str] = None, submitted_date: Optional[str] = Query( @@ -463,4 +464,10 @@ async def task_submissions( results=data, pagination=submission_schemas.PaginationInfo(**pagination.model_dump()), ) + if submission_id: + submission_detail = await submission_crud.get_submission_detail( + project, task_id, submission_id, db + ) + response = submission_detail.get("value", [])[0] + return response diff --git a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx index de2e793dd4..481541fdef 100644 --- a/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx +++ b/src/frontend/src/components/ProjectSubmissions/SubmissionsTable.tsx @@ -59,8 +59,6 @@ const SubmissionsTable = ({ toggleView }) => { const [paginationPage, setPaginationPage] = useState(1); const [submittedBy, setSubmittedBy] = useState(null); - const encodedTaskId = environment.encode(3468); - useEffect(() => { let count = 0; const filters = Object.keys(filter); @@ -436,7 +434,7 @@ const SubmissionsTable = ({ toggleView }) => { { - navigate(`/project/${encodedId}/tasks/${encodedTaskId}/submission/${row?.meta?.instanceID}`); + navigate(`/project/${encodedId}/tasks/${row?.phonenumber}/submission/${row?.meta?.instanceID}`); }} />{' '} {' '} diff --git a/src/frontend/src/views/SubmissionDetails.tsx b/src/frontend/src/views/SubmissionDetails.tsx index c115a3ef13..97d1b5838d 100644 --- a/src/frontend/src/views/SubmissionDetails.tsx +++ b/src/frontend/src/views/SubmissionDetails.tsx @@ -9,8 +9,7 @@ const SubmissionDetails = () => { const params = CoreModules.useParams(); const encodedProjectId = params.projectId; const decodedProjectId = environment.decode(encodedProjectId); - const encodedTaskId = params.taskId; - const decodedTaskId = environment.decode(encodedTaskId); + const taskId = params.taskId; const paramsInstanceId = params.instanceId; const submissionDetails = useAppSelector((state) => state.submission.submissionDetails); @@ -20,10 +19,10 @@ const SubmissionDetails = () => { SubmissionService( `${ import.meta.env.VITE_API_URL - }/central/submission?project_id=${decodedProjectId}&xmlFormId=${decodedTaskId}&submission_id=${paramsInstanceId}`, + }/submission/task_submissions/${decodedProjectId}?task_id=${taskId}&submission_id=${paramsInstanceId}`, ), ); - }, []); + }, [decodedProjectId, taskId, paramsInstanceId]); function removeNullValues(obj) { const newObj = {};