From 7df9348b91866d0d689b5718e8dc2ea4822a4b41 Mon Sep 17 00:00:00 2001 From: "Efrain A. Davila" <105945226+EfrainAD@users.noreply.github.com> Date: Fri, 13 Oct 2023 18:25:48 -0400 Subject: [PATCH] feature: Integrate the SurveyLink component to handle seeing completed surveys 1. Replace the survey link button with the SurveyLink component. 2. Remove handleSurveyLink since the component now handles that. 3. useGetHomesQuery was removed since since the assignment homes array now have the desired survey ids --- .../pages/Admin/assignment/AssignProfile.js | 25 +++++-------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/frontend/front/src/pages/Admin/assignment/AssignProfile.js b/frontend/front/src/pages/Admin/assignment/AssignProfile.js index 7344691c..13aaf32e 100644 --- a/frontend/front/src/pages/Admin/assignment/AssignProfile.js +++ b/frontend/front/src/pages/Admin/assignment/AssignProfile.js @@ -1,7 +1,6 @@ import { Box, Button, Stack, Typography } from "@mui/material"; import { useGetAssignmentQuery, - useGetHomesQuery, useGetSurveyorsQuery, } from "../../../api/apiSlice"; import { @@ -15,17 +14,17 @@ import { DataGrid } from "@mui/x-data-grid"; import Loader from "../../../components/Loader"; import React from "react"; import { getAddress } from "../home/HomeTable"; -import { useNavigate, useParams } from "react-router-dom"; +import { useParams } from "react-router-dom"; import { adminAssignmentProfile, ADMIN_ASSIGNMENT, withAdminPrefix, } from "../../../routing/routes"; +import SurveyLink from "../../../components/SurveyLink"; const AssignProfile = () => { const { aid } = useParams(); const goToBreadcrumb = useGoToBreadcrumb(); - const navigate = useNavigate(); useInitBreadcrumbs([ { url: withAdminPrefix(ADMIN_ASSIGNMENT), description: "assignments" }, @@ -47,23 +46,12 @@ const AssignProfile = () => { isLoading: isSurveyorsDataLoading, } = useGetSurveyorsQuery(); - const { data: homesData } = useGetHomesQuery(); - const surveyors = surveyorsData ? surveyorsData.filter((surveyor) => assignmentData?.surveyor_ids.includes(surveyor.id) ) : "Unassigned"; - const handleSurveyLink = (home) => { - const homeData = homesData.find((homeData) => homeData.id === home.id); - const surveyVisitIds = - homeData.survey_visit_ids.length > 0 - ? homeData.survey_visit_ids[0] - : null; - - navigate(`/admin/survey/visit/${surveyVisitIds}`); - }; const handleUserLink = (user) => goToBreadcrumb("user", user); const handleHomeLink = (home) => { goToBreadcrumb("home", home); @@ -118,15 +106,14 @@ const AssignProfile = () => { maxWidth: 80, renderCell: (params) => params.row.completed ? ( - + /> ) : null, }, {