Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor Bechthold committed Jan 1, 2024
1 parent 6422dad commit b7f81e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions frontend/src/components/pages/HomePage/LogRecordsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down Expand Up @@ -84,7 +81,7 @@ const LogRecordsTable = ({

const [showAlert, setShowAlert] = useState(false);

const [buildingOptions, setBuildingOptions] = useState<BuildingLabel[]>([]);
const [buildingOptions, setBuildingOptions] = useState<SelectLabel[]>([]);

// Menu states
const [deleteOpenMap, setDeleteOpenMap] = useState<{
Expand All @@ -95,9 +92,9 @@ const LogRecordsTable = ({
);

// Dropdown option states
const [employeeOptions, setEmployeeOptions] = useState<UserLabel[]>([]);
const [residentOptions, setResidentOptions] = useState<ResidentLabel[]>([]);
const [tagOptions, setTagOptions] = useState<TagLabel[]>([]);
const [employeeOptions, setEmployeeOptions] = useState<SelectLabel[]>([]);
const [residentOptions, setResidentOptions] = useState<SelectLabel[]>([]);
const [tagOptions, setTagOptions] = useState<SelectLabel[]>([]);

// Handle delete confirmation toggle
const handleDeleteToggle = (logId: number) => {
Expand All @@ -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!,
}));
Expand All @@ -133,15 +130,15 @@ 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);
}

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,
Expand All @@ -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,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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<HTMLDivElement>;
userPageNum: number;
Expand Down

0 comments on commit b7f81e8

Please sign in to comment.