From b7f81e8942c23accb4f4f33c16e4d901f22245d9 Mon Sep 17 00:00:00 2001 From: Connor Bechthold Date: Mon, 1 Jan 2024 16:28:44 -0500 Subject: [PATCH] fix type errors --- .../pages/HomePage/LogRecordsTable.tsx | 21 ++++++++----------- .../ResidentDirectoryTable.tsx | 4 ++-- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/frontend/src/components/pages/HomePage/LogRecordsTable.tsx b/frontend/src/components/pages/HomePage/LogRecordsTable.tsx index b18690c7..457faf8d 100644 --- a/frontend/src/components/pages/HomePage/LogRecordsTable.tsx +++ b/frontend/src/components/pages/HomePage/LogRecordsTable.tsx @@ -31,11 +31,8 @@ import ResidentAPIClient from "../../../APIClients/ResidentAPIClient"; import TagAPIClient from "../../../APIClients/TagAPIClient"; import UserAPIClient from "../../../APIClients/UserAPIClient"; import BuildingAPIClient from "../../../APIClients/BuildingAPIClient"; -import { ResidentLabel } from "../../../types/ResidentTypes"; -import { TagLabel } from "../../../types/TagTypes"; -import { UserLabel } from "../../../types/UserTypes"; -import { BuildingLabel } from "../../../types/BuildingTypes"; import ConfirmationModal from "../../common/ConfirmationModal"; +import { SelectLabel } from "../../../types/SharedTypes"; type Props = { logRecords: LogRecord[]; @@ -84,7 +81,7 @@ const LogRecordsTable = ({ const [showAlert, setShowAlert] = useState(false); - const [buildingOptions, setBuildingOptions] = useState([]); + const [buildingOptions, setBuildingOptions] = useState([]); // Menu states const [deleteOpenMap, setDeleteOpenMap] = useState<{ @@ -95,9 +92,9 @@ const LogRecordsTable = ({ ); // Dropdown option states - const [employeeOptions, setEmployeeOptions] = useState([]); - const [residentOptions, setResidentOptions] = useState([]); - const [tagOptions, setTagOptions] = useState([]); + const [employeeOptions, setEmployeeOptions] = useState([]); + const [residentOptions, setResidentOptions] = useState([]); + const [tagOptions, setTagOptions] = useState([]); // Handle delete confirmation toggle const handleDeleteToggle = (logId: number) => { @@ -123,7 +120,7 @@ const LogRecordsTable = ({ if (residentsData && residentsData.residents.length !== 0) { // TODO: Remove the type assertions here - const residentLabels: UserLabel[] = residentsData.residents.map((r) => ({ + const residentLabels: SelectLabel[] = residentsData.residents.map((r) => ({ label: r.residentId!, value: r.id!, })); @@ -133,7 +130,7 @@ const LogRecordsTable = ({ const buildingsData = await BuildingAPIClient.getBuildings(); if (buildingsData && buildingsData.buildings.length !== 0) { - const buildingLabels: BuildingLabel[] = buildingsData.buildings.map( + const buildingLabels: SelectLabel[] = buildingsData.buildings.map( (building) => ({ label: building.name!, value: building.id! }), ); setBuildingOptions(buildingLabels); @@ -141,7 +138,7 @@ const LogRecordsTable = ({ const usersData = await UserAPIClient.getUsers({ returnAll: true }); if (usersData && usersData.users.length !== 0) { - const userLabels: UserLabel[] = usersData.users + const userLabels: SelectLabel[] = usersData.users .filter((user) => user.userStatus === "Active") .map((user) => ({ label: user.firstName, @@ -152,7 +149,7 @@ const LogRecordsTable = ({ const tagsData = await TagAPIClient.getTags(); if (tagsData && tagsData.tags.length !== 0) { - const tagLabels: TagLabel[] = tagsData.tags.map((tag) => ({ + const tagLabels: SelectLabel[] = tagsData.tags.map((tag) => ({ label: tag.name, value: tag.tagId, })); diff --git a/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx b/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx index ad4e5f1c..e4228628 100644 --- a/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx +++ b/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx @@ -15,7 +15,6 @@ import { Tr, } from "@chakra-ui/react"; import { VscKebabVertical } from "react-icons/vsc"; -import { BuildingLabel } from "../../../types/BuildingTypes"; import { Resident, ResidentStatus } from "../../../types/ResidentTypes"; import EditResident from "../../forms/EditResident"; import ResidentAPIClient from "../../../APIClients/ResidentAPIClient"; @@ -24,9 +23,10 @@ import AuthContext from "../../../contexts/AuthContext"; import CreateToast from "../../common/Toasts"; import ConfirmationModal from "../../common/ConfirmationModal"; import { convertToDate } from "../../../helper/dateHelpers"; +import { SelectLabel } from "../../../types/SharedTypes"; type Props = { - buildingOptions: BuildingLabel[]; + buildingOptions: SelectLabel[]; residents: Resident[]; tableRef: RefObject; userPageNum: number;