diff --git a/frontend/src/APIClients/AuthAPIClient.ts b/frontend/src/APIClients/AuthAPIClient.ts index bc3bf0e9..11a68e5f 100644 --- a/frontend/src/APIClients/AuthAPIClient.ts +++ b/frontend/src/APIClients/AuthAPIClient.ts @@ -1,8 +1,3 @@ -import { - FetchResult, - MutationFunctionOptions, - OperationVariables, -} from "@apollo/client"; import { AxiosError } from "axios"; import { getAuthErrMessage } from "../helper/error"; import AUTHENTICATED_USER_KEY from "../constants/AuthConstants"; @@ -26,7 +21,7 @@ const login = async ( ); return data; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 401) { return { errCode: axiosErr.response.status, @@ -53,7 +48,7 @@ const twoFa = async ( ); return data; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 401) { return { errMessage: @@ -114,7 +109,7 @@ const register = async ( ); return data; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 409) { return { errCode: axiosErr.response.status, diff --git a/frontend/src/APIClients/BuildingAPIClient.ts b/frontend/src/APIClients/BuildingAPIClient.ts index 300a1c7e..a49c341a 100644 --- a/frontend/src/APIClients/BuildingAPIClient.ts +++ b/frontend/src/APIClients/BuildingAPIClient.ts @@ -1,4 +1,3 @@ -import axios, { AxiosError } from "axios"; import AUTHENTICATED_USER_KEY from "../constants/AuthConstants"; import { getLocalStorageObjProperty } from "../utils/LocalStorageUtils"; import baseAPIClient from "./BaseAPIClient"; diff --git a/frontend/src/APIClients/ResidentAPIClient.ts b/frontend/src/APIClients/ResidentAPIClient.ts index b574a2ed..74ccc087 100644 --- a/frontend/src/APIClients/ResidentAPIClient.ts +++ b/frontend/src/APIClients/ResidentAPIClient.ts @@ -1,7 +1,6 @@ -import axios, { AxiosError } from "axios"; +import { AxiosError } from "axios"; import AUTHENTICATED_USER_KEY from "../constants/AuthConstants"; import { - Resident, GetResidentsReponse, CountResidentsResponse, CreateResidentParams, @@ -99,7 +98,7 @@ const createResident = async ({ ); return true; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 409) { return { @@ -122,8 +121,8 @@ const deleteResident = async (residentId: number): Promise => { headers: { Authorization: bearerToken }, }); return 200; - } catch (error: any) { - const axiosErr = (error as any) as AxiosError; + } catch (error) { + const axiosErr = error as AxiosError; if (axiosErr.response) { return axiosErr.response.status; } @@ -151,7 +150,7 @@ const editResident = async ({ ); return true; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 409) { return { diff --git a/frontend/src/APIClients/TagAPIClient.ts b/frontend/src/APIClients/TagAPIClient.ts index 97a34b7b..8f0db8f0 100644 --- a/frontend/src/APIClients/TagAPIClient.ts +++ b/frontend/src/APIClients/TagAPIClient.ts @@ -65,7 +65,7 @@ const createTag = async ({ ); return true; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 409) { return { @@ -94,7 +94,7 @@ const editTag = async ({ ); return true; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 409) { return { @@ -117,8 +117,8 @@ const deleteTag = async (tagId: number): Promise => { headers: { Authorization: bearerToken }, }); return 200; - } catch (error: any) { - const axiosErr = (error as any) as AxiosError; + } catch (error) { + const axiosErr = error as AxiosError; if (axiosErr.response) { return axiosErr.response.status; } diff --git a/frontend/src/APIClients/UserAPIClient.ts b/frontend/src/APIClients/UserAPIClient.ts index 65be56ae..79bacc27 100644 --- a/frontend/src/APIClients/UserAPIClient.ts +++ b/frontend/src/APIClients/UserAPIClient.ts @@ -8,6 +8,7 @@ import { UpdateUserParams, UserStatus, GetUserStatusResponse, + GetUserParams, } from "../types/UserTypes"; import { ErrorResponse } from "../types/ErrorTypes"; @@ -15,7 +16,7 @@ const getUsers = async ({ returnAll = false, pageNumber = 1, resultsPerPage = 10, -}): Promise => { +}: GetUserParams): Promise => { try { const bearerToken = `Bearer ${getLocalStorageObjProperty( AUTHENTICATED_USER_KEY, @@ -72,8 +73,8 @@ const updateUser = async ({ }, ); return res.status; - } catch (error: any) { - const axiosErr = (error as any) as AxiosError; + } catch (error) { + const axiosErr = error as AxiosError; if (axiosErr.response) { return axiosErr.response.status; } @@ -98,8 +99,8 @@ const updateUserStatus = async ( }, ); return res.status; - } catch (error: any) { - const axiosErr = (error as any) as AxiosError; + } catch (error) { + const axiosErr = error as AxiosError; if (axiosErr.response) { return axiosErr.response.status; } @@ -117,8 +118,8 @@ const deleteUser = async (userId: number): Promise => { headers: { Authorization: bearerToken }, }); return res.status; - } catch (error: any) { - const axiosErr = (error as any) as AxiosError; + } catch (error) { + const axiosErr = error as AxiosError; if (axiosErr.response) { return axiosErr.response.status; } @@ -144,7 +145,7 @@ const inviteUser = async ( ); return true; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 409) { return { @@ -182,7 +183,7 @@ const getUserStatus = async ( "This email address has not been invited. Please try again with a different email.", }; } catch (error) { - const axiosErr = (error as any) as AxiosError; + const axiosErr = error as AxiosError; if (axiosErr.response && axiosErr.response.status === 403) { return { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 53db0629..7484a26a 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,5 +1,5 @@ import "bootstrap/dist/css/bootstrap.min.css"; -import React, { useState, useReducer } from "react"; +import React, { useState } from "react"; import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; import { ChakraProvider } from "@chakra-ui/react"; diff --git a/frontend/src/components/auth/PrivateRoute.tsx b/frontend/src/components/auth/PrivateRoute.tsx index 8849137b..771d13d2 100644 --- a/frontend/src/components/auth/PrivateRoute.tsx +++ b/frontend/src/components/auth/PrivateRoute.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useState, useEffect } from "react"; +import React, { useContext } from "react"; import { Route, Redirect, useLocation } from "react-router-dom"; import AuthContext from "../../contexts/AuthContext"; import { @@ -44,9 +44,6 @@ const PrivateRoute: React.FC = ({ ) { return ; } - - console.log(path, currentPath); - return ; }; diff --git a/frontend/src/components/auth/TwoFa.tsx b/frontend/src/components/auth/TwoFa.tsx index ecd74d60..6a7572d5 100644 --- a/frontend/src/components/auth/TwoFa.tsx +++ b/frontend/src/components/auth/TwoFa.tsx @@ -3,7 +3,6 @@ import { Redirect } from "react-router-dom"; import { Box, Button, - Center, Flex, Input, Spinner, @@ -14,7 +13,6 @@ import authAPIClient from "../../APIClients/AuthAPIClient"; import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants"; import { HOME_PAGE } from "../../constants/Routes"; import AuthContext from "../../contexts/AuthContext"; -import { AuthenticatedUser } from "../../types/AuthTypes"; import CreateToast from "../common/Toasts"; import { isErrorResponse } from "../../helper/error"; @@ -28,6 +26,7 @@ type TwoFaProps = { const TwoFa = ({ email, password, + /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ token, toggle, }: TwoFaProps): React.ReactElement => { diff --git a/frontend/src/components/auth/Verification.tsx b/frontend/src/components/auth/Verification.tsx index 97dce6d2..5f4c0ff5 100644 --- a/frontend/src/components/auth/Verification.tsx +++ b/frontend/src/components/auth/Verification.tsx @@ -1,6 +1,6 @@ import React, { useState, useContext } from "react"; import { useHistory } from "react-router-dom"; -import { Box, Button, Flex, Spinner, Text, VStack } from "@chakra-ui/react"; +import { Box, Button, Flex, Spinner, Text } from "@chakra-ui/react"; import authAPIClient from "../../APIClients/AuthAPIClient"; import CreateToast from "../common/Toasts"; import AuthContext from "../../contexts/AuthContext"; diff --git a/frontend/src/components/common/ConfirmationModal.tsx b/frontend/src/components/common/ConfirmationModal.tsx index dbe207f1..6f63ab11 100644 --- a/frontend/src/components/common/ConfirmationModal.tsx +++ b/frontend/src/components/common/ConfirmationModal.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React from "react"; import { Box, Modal, diff --git a/frontend/src/components/common/Pagination.tsx b/frontend/src/components/common/Pagination.tsx index 5f6fa1d9..b3d1c511 100644 --- a/frontend/src/components/common/Pagination.tsx +++ b/frontend/src/components/common/Pagination.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React from "react"; import { Menu, MenuButton, @@ -60,6 +60,7 @@ const Pagination = ({ }; // Treat the enter key as an alt method of triggering onBlur (lose focus) + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ const handleKeyUp = (event: any) => { if (event.keyCode === 13) { event.target.blur(); diff --git a/frontend/src/components/forms/CreateEmployee.tsx b/frontend/src/components/forms/CreateEmployee.tsx index 06c67a8e..5004ae98 100644 --- a/frontend/src/components/forms/CreateEmployee.tsx +++ b/frontend/src/components/forms/CreateEmployee.tsx @@ -21,7 +21,6 @@ import { Text, } from "@chakra-ui/react"; import { AddIcon } from "@chakra-ui/icons"; -import { INVITE_EMPLOYEE_ERROR } from "../../constants/ErrorMessages"; import CreateToast from "../common/Toasts"; import UserAPIClient from "../../APIClients/UserAPIClient"; import { isErrorResponse } from "../../helper/error"; diff --git a/frontend/src/components/forms/CreateLog.tsx b/frontend/src/components/forms/CreateLog.tsx index 59d4ca63..8e54bc92 100644 --- a/frontend/src/components/forms/CreateLog.tsx +++ b/frontend/src/components/forms/CreateLog.tsx @@ -40,7 +40,6 @@ import LogRecordAPIClient from "../../APIClients/LogRecordAPIClient"; import BuildingAPIClient from "../../APIClients/BuildingAPIClient"; import { selectStyle } from "../../theme/forms/selectStyles"; import { singleDatePickerStyle } from "../../theme/forms/datePickerStyles"; -import { Resident } from "../../types/ResidentTypes"; import { SelectLabel } from "../../types/SharedTypes"; import { combineDateTime, getFormattedTime } from "../../helper/dateHelpers"; @@ -76,25 +75,6 @@ const ALERT_DATA: AlertDataOptions = { }, }; -// Replace this with the tags from the db once the API and table are made -const TAGS = [ - { label: "Tag A", value: "A" }, - { label: "Tag B", value: "B" }, - { label: "Tag C", value: "C" }, -]; - -// Changes the border of the Select components if the input is invalid -function getBorderStyle(state: any, error: boolean): string { - if (state.isFocused) { - return "2px solid #3182ce"; - } - if (error) { - return "2px solid #e53e3e"; - } - - return "1px solid #cbd5e0"; -} - // Helper to get the currently logged in user const getCurUserSelectOption = () => { const curUser: AuthenticatedUser | null = getLocalStorageObj( @@ -107,8 +87,9 @@ const getCurUserSelectOption = () => { return { label: "", value: -1 }; }; -const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props) => { +const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props): React.ReactElement => { // currently, the select for employees is locked and should default to current user. Need to check if admins/regular staff are allowed to change this + /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ const [employee, setEmployee] = useState(getCurUserSelectOption()); const [date, setDate] = useState(new Date()); const [time, setTime] = useState( @@ -133,8 +114,6 @@ const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props) => { const [isCreateOpen, setCreateOpen] = React.useState(false); // error states for non-nullable inputs - const [employeeError, setEmployeeError] = useState(false); - const [dateError, setDateError] = useState(false); const [timeError, setTimeError] = useState(false); const [buildingError, setBuildingError] = useState(false); const [residentError, setResidentError] = useState(false); @@ -219,7 +198,7 @@ const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props) => { if (buildingsData && buildingsData.buildings.length !== 0) { const buildingLabels: SelectLabel[] = buildingsData.buildings.map( - (building) => ({ label: building.name!, value: building.id! }), + (building) => ({ label: building.name, value: building.id }), ); setBuildingOptions(buildingLabels); } @@ -231,7 +210,7 @@ const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props) => { if (residentsData && residentsData.residents.length !== 0) { // TODO: Remove the type assertions here const residentLabels: SelectLabel[] = residentsData.residents.map( - (r) => ({ label: r.residentId!, value: r.id! }), + (r) => ({ label: r.residentId, value: r.id }), ); setResidentOptions(residentLabels); } @@ -272,8 +251,6 @@ const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props) => { setNotes(""); // reset all error states - setEmployeeError(false); - setDateError(false); setTimeError(false); setBuildingError(false); setResidentError(false); @@ -289,8 +266,6 @@ const CreateLog = ({ getRecords, countRecords, setUserPageNum }: Props) => { const handleSubmit = async () => { // Update error states - setEmployeeError(!employee.label); - setDateError(date === null); setTimeError(time === ""); setBuildingError(buildingId === -1); setResidentError(residents.length === 0); diff --git a/frontend/src/components/forms/CreateResident.tsx b/frontend/src/components/forms/CreateResident.tsx index 0afe6a04..85423b96 100644 --- a/frontend/src/components/forms/CreateResident.tsx +++ b/frontend/src/components/forms/CreateResident.tsx @@ -118,7 +118,7 @@ const CreateResident = ({ if (buildingsData && buildingsData.buildings.length !== 0) { const buildingLabels: SelectLabel[] = buildingsData.buildings.map( - (building) => ({ label: building.name!, value: building.id! }), + (building) => ({ label: building.name, value: building.id }), ); setBuildingOptions(buildingLabels); } diff --git a/frontend/src/components/forms/EditLog.tsx b/frontend/src/components/forms/EditLog.tsx index 15c68c3f..181d70f5 100644 --- a/frontend/src/components/forms/EditLog.tsx +++ b/frontend/src/components/forms/EditLog.tsx @@ -29,9 +29,6 @@ import { import type { AlertStatus } from "@chakra-ui/react"; import { SingleDatepicker } from "chakra-dayzed-datepicker"; import { Col, Row } from "react-bootstrap"; -import { AuthenticatedUser } from "../../types/AuthTypes"; -import { getLocalStorageObj } from "../../utils/LocalStorageUtils"; -import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants"; import LogRecordAPIClient from "../../APIClients/LogRecordAPIClient"; import { selectStyle } from "../../theme/forms/selectStyles"; import { singleDatePickerStyle } from "../../theme/forms/datePickerStyles"; @@ -49,7 +46,6 @@ type Props = { tagOptions: SelectLabel[]; getRecords: (pageNumber: number) => Promise; countRecords: () => Promise; - setUserPageNum: React.Dispatch>; buildingOptions: SelectLabel[]; }; @@ -87,9 +83,8 @@ const EditLog = ({ tagOptions, getRecords, countRecords, - setUserPageNum, buildingOptions, -}: Props) => { +}: Props): React.ReactElement => { // currently, the select for employees is locked and should default to current user. Need to check if admins/regular staff are allowed to change this const [date, setDate] = useState(new Date()); @@ -102,8 +97,6 @@ const EditLog = ({ const [flagged, setFlagged] = useState(false); // error states for non-nullable inputs - const [employeeError, setEmployeeError] = useState(false); - const [dateError, setDateError] = useState(false); const [timeError, setTimeError] = useState(false); const [buildingError, setBuildingError] = useState(false); const [residentError, setResidentError] = useState(false); @@ -200,8 +193,6 @@ const EditLog = ({ setFlagged(logRecord.flagged); // error states for non-nullable inputs - setEmployeeError(false); - setDateError(false); setTimeError(false); setBuildingError(false); setResidentError(false); @@ -210,7 +201,6 @@ const EditLog = ({ const handleSubmit = async () => { // Update error states - setDateError(date === null); setTimeError(time === ""); setBuildingError(buildingId === -1); setResidentError(residents.length === 0); @@ -254,6 +244,7 @@ const EditLog = ({ if (isOpen) { initializeValues(); } + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [isOpen]); useEffect(() => { diff --git a/frontend/src/components/forms/EditResident.tsx b/frontend/src/components/forms/EditResident.tsx index 4a70eb55..21df67ff 100644 --- a/frontend/src/components/forms/EditResident.tsx +++ b/frontend/src/components/forms/EditResident.tsx @@ -2,12 +2,8 @@ import React, { useEffect, useState } from "react"; import Select, { SingleValue } from "react-select"; import { - Alert, - AlertDescription, - AlertIcon, Box, Button, - Checkbox, FormControl, FormErrorMessage, FormLabel, @@ -19,8 +15,6 @@ import { ModalCloseButton, ModalOverlay, ModalFooter, - Text, - ScaleFade, Divider, InputGroup, IconButton, diff --git a/frontend/src/components/forms/Login.tsx b/frontend/src/components/forms/Login.tsx index 8b761e39..83835073 100644 --- a/frontend/src/components/forms/Login.tsx +++ b/frontend/src/components/forms/Login.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useState, useEffect } from "react"; +import React, { useContext, useState } from "react"; import { Box, Button, @@ -9,14 +9,10 @@ import { Input, Spinner, } from "@chakra-ui/react"; -import { Redirect, useHistory } from "react-router-dom"; +import { useHistory } from "react-router-dom"; import authAPIClient from "../../APIClients/AuthAPIClient"; import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants"; -import { - HOME_PAGE, - SIGNUP_PAGE, - VERIFICATION_PAGE, -} from "../../constants/Routes"; +import { SIGNUP_PAGE } from "../../constants/Routes"; import AuthContext from "../../contexts/AuthContext"; import { isAuthErrorResponse, isErrorResponse } from "../../helper/error"; import UserAPIClient from "../../APIClients/UserAPIClient"; @@ -39,6 +35,7 @@ const Login = ({ setEmail, password, setPassword, + /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ setToken, toggle, setToggle, diff --git a/frontend/src/components/forms/ViewLog.tsx b/frontend/src/components/forms/ViewLog.tsx index ecab0f84..835a1d85 100644 --- a/frontend/src/components/forms/ViewLog.tsx +++ b/frontend/src/components/forms/ViewLog.tsx @@ -1,5 +1,4 @@ -/* eslint-disable prettier/prettier */ -import React, { useEffect, useState } from "react"; +import React from "react"; import Select from "react-select"; import { Box, @@ -17,15 +16,11 @@ import { ModalOverlay, ModalHeader, Text, - Textarea, ModalFooter, ModalCloseButton, } from "@chakra-ui/react"; import { Col, Row } from "react-bootstrap"; -import { AuthenticatedUser } from "../../types/AuthTypes"; -import { getLocalStorageObj } from "../../utils/LocalStorageUtils"; -import AUTHENTICATED_USER_KEY from "../../constants/AuthConstants"; -import { viewStyle} from "../../theme/forms/selectStyles"; +import { viewStyle } from "../../theme/forms/selectStyles"; import { LogRecord } from "../../types/LogRecordTypes"; import { SelectLabel } from "../../types/SharedTypes"; import { convertToString, getFormattedTime } from "../../helper/dateHelpers"; @@ -40,17 +35,6 @@ type Props = { allowEdit: boolean; }; -// Helper to get the currently logged in user -const getCurUserSelectOption = () => { - const curUser: AuthenticatedUser | null = getLocalStorageObj( - AUTHENTICATED_USER_KEY, - ); - if (curUser) { - return `${curUser.firstName} ${curUser.lastName}` - } - return ""; -}; - const ViewLog = ({ logRecord, isOpen, @@ -58,18 +42,22 @@ const ViewLog = ({ toggleEdit, residentOptions, tagOptions, - allowEdit -}: Props) => { - + allowEdit, +}: Props): React.ReactElement => { const handleEdit = () => { toggleClose(); setTimeout(toggleEdit, 400); - } + }; return ( <> - + View Log Record @@ -95,7 +83,9 @@ const ViewLog = ({ Date @@ -108,7 +98,9 @@ const ViewLog = ({ isDisabled size="md" type="time" - defaultValue={getFormattedTime(new Date(logRecord.datetime))} + defaultValue={getFormattedTime( + new Date(logRecord.datetime), + )} _disabled={{ bg: "transparent" }} _hover={{ borderColor: "teal.100" }} /> @@ -132,13 +124,16 @@ const ViewLog = ({ - Residents + Residents null, MultiValueRemove: () => null }} + components={{ + DropdownIndicator: () => null, + MultiValueRemove: () => null, + }} placeholder="No Tags" - defaultValue={tagOptions.filter( - (item) => logRecord.tags.includes(item.label), + defaultValue={tagOptions.filter((item) => + logRecord.tags.includes(item.label), )} styles={viewStyle} /> @@ -168,7 +166,11 @@ const ViewLog = ({ @@ -191,23 +193,19 @@ const ViewLog = ({ Notes - - {logRecord.note} - + {logRecord.note} - + - { - allowEdit && ( - - ) - } - + {allowEdit && ( + + )} + diff --git a/frontend/src/components/pages/AdminControls/EmployeeDirectory.tsx b/frontend/src/components/pages/AdminControls/EmployeeDirectory.tsx index d04706e4..c0f4e822 100644 --- a/frontend/src/components/pages/AdminControls/EmployeeDirectory.tsx +++ b/frontend/src/components/pages/AdminControls/EmployeeDirectory.tsx @@ -47,6 +47,7 @@ const EmployeeDirectoryPage = (): React.ReactElement => { useEffect(() => { setUserPageNum(1); getUsers(1); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [resultsPerPage]); useEffect(() => { diff --git a/frontend/src/components/pages/AdminControls/SignInLogs.tsx b/frontend/src/components/pages/AdminControls/SignInLogs.tsx index 935d19c7..e9620bcb 100644 --- a/frontend/src/components/pages/AdminControls/SignInLogs.tsx +++ b/frontend/src/components/pages/AdminControls/SignInLogs.tsx @@ -73,6 +73,7 @@ const SignInLogsPage = (): React.ReactElement => { useEffect(() => { setUserPageNum(1); getSignInLogs(1); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [resultsPerPage]); useEffect(() => { diff --git a/frontend/src/components/pages/AdminControls/Tags.tsx b/frontend/src/components/pages/AdminControls/Tags.tsx index e8a055e0..6ebc87c9 100644 --- a/frontend/src/components/pages/AdminControls/Tags.tsx +++ b/frontend/src/components/pages/AdminControls/Tags.tsx @@ -51,6 +51,7 @@ const TagsPage = (): React.ReactElement => { useEffect(() => { setUserPageNum(1); getTags(1); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [resultsPerPage]); useEffect(() => { diff --git a/frontend/src/components/pages/Auth/LoginPage.tsx b/frontend/src/components/pages/Auth/LoginPage.tsx index 988bca5a..9a7238cc 100644 --- a/frontend/src/components/pages/Auth/LoginPage.tsx +++ b/frontend/src/components/pages/Auth/LoginPage.tsx @@ -1,6 +1,6 @@ import React, { useState } from "react"; -import Login from "../../forms/Login"; import TwoFa from "../../auth/TwoFa"; +import Login from "../../forms/Login"; const LoginPage = (): React.ReactElement => { const [email, setEmail] = useState(""); diff --git a/frontend/src/components/pages/Errors/NotFound.tsx b/frontend/src/components/pages/Errors/NotFound.tsx index 15cdbbb5..20ce35de 100644 --- a/frontend/src/components/pages/Errors/NotFound.tsx +++ b/frontend/src/components/pages/Errors/NotFound.tsx @@ -1,14 +1,5 @@ -import React, { useContext, useState, useEffect } from "react"; -import { - Box, - Button, - Flex, - Text, - FormControl, - FormErrorMessage, - Input, - Spinner, -} from "@chakra-ui/react"; +import React from "react"; +import { Box, Button, Flex, Text } from "@chakra-ui/react"; import { useHistory } from "react-router-dom"; import { HOME_PAGE } from "../../../constants/Routes"; diff --git a/frontend/src/components/pages/HomePage/HomePage.tsx b/frontend/src/components/pages/HomePage/HomePage.tsx index 95e3cdf6..7f24df3a 100644 --- a/frontend/src/components/pages/HomePage/HomePage.tsx +++ b/frontend/src/components/pages/HomePage/HomePage.tsx @@ -158,6 +158,7 @@ const HomePage = (): React.ReactElement => { useEffect(() => { setUserPageNum(1); getLogRecords(1); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [ buildings, employees, @@ -173,6 +174,7 @@ const HomePage = (): React.ReactElement => { useEffect(() => { countLogRecords(); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [ buildings, employees, diff --git a/frontend/src/components/pages/HomePage/HomePageFilters.tsx b/frontend/src/components/pages/HomePage/HomePageFilters.tsx index 64042338..faa709b2 100644 --- a/frontend/src/components/pages/HomePage/HomePageFilters.tsx +++ b/frontend/src/components/pages/HomePage/HomePageFilters.tsx @@ -8,7 +8,6 @@ import { Box, Grid, GridItem, - Button, Checkbox, FormControl, FormLabel, @@ -19,7 +18,7 @@ import { } from "@chakra-ui/react"; import { SmallCloseIcon } from "@chakra-ui/icons"; import { Card } from "react-bootstrap"; -import Select, { MultiValue, SingleValue } from "react-select"; +import Select, { MultiValue } from "react-select"; import { SingleDatepicker } from "chakra-dayzed-datepicker"; import { selectStyle } from "../../../theme/forms/selectStyles"; import { singleDatePickerStyle } from "../../../theme/forms/datePickerStyles"; @@ -82,7 +81,7 @@ const HomePageFilters = ({ if (buildingsData && buildingsData.buildings.length !== 0) { const buildingLabels: SelectLabel[] = buildingsData.buildings.map( - (building) => ({ label: building.name!, value: building.id! }), + (building) => ({ label: building.name, value: building.id }), ); setBuildingOptions(buildingLabels); } @@ -189,17 +188,6 @@ const HomePageFilters = ({ setTags(mutableSelectedTags); }; - const handleClearAll = () => { - setAttentionTos([]); - setBuildings([]); - setEmployees([]); - setEndDate(undefined); - setFlagged(false); - setResidents([]); - setStartDate(undefined); - setTags([]); - }; - useEffect(() => { getBuildingsOptions(); getUsers(); diff --git a/frontend/src/components/pages/HomePage/LogRecordsTable.tsx b/frontend/src/components/pages/HomePage/LogRecordsTable.tsx index 5c8229c4..75a7587a 100644 --- a/frontend/src/components/pages/HomePage/LogRecordsTable.tsx +++ b/frontend/src/components/pages/HomePage/LogRecordsTable.tsx @@ -79,7 +79,7 @@ const LogRecordsTable = ({ countRecords, setUserPageNum, }: Props): React.ReactElement => { - const { authenticatedUser, setAuthenticatedUser } = useContext(AuthContext); + const { authenticatedUser } = useContext(AuthContext); const [showAlert, setShowAlert] = useState(false); @@ -135,8 +135,8 @@ const LogRecordsTable = ({ // TODO: Remove the type assertions here const residentLabels: SelectLabel[] = residentsData.residents.map( (r) => ({ - label: r.residentId!, - value: r.id!, + label: r.residentId, + value: r.id, }), ); setResidentOptions(residentLabels); @@ -146,7 +146,7 @@ const LogRecordsTable = ({ if (buildingsData && buildingsData.buildings.length !== 0) { const buildingLabels: SelectLabel[] = buildingsData.buildings.map( - (building) => ({ label: building.name!, value: building.id! }), + (building) => ({ label: building.name, value: building.id }), ); setBuildingOptions(buildingLabels); } @@ -298,7 +298,6 @@ const LogRecordsTable = ({ tagOptions={tagOptions} getRecords={getRecords} countRecords={countRecords} - setUserPageNum={setUserPageNum} buildingOptions={buildingOptions} /> diff --git a/frontend/src/components/pages/ResidentDirectory/ResidentDirectory.tsx b/frontend/src/components/pages/ResidentDirectory/ResidentDirectory.tsx index 7fb63ac9..9f05b830 100644 --- a/frontend/src/components/pages/ResidentDirectory/ResidentDirectory.tsx +++ b/frontend/src/components/pages/ResidentDirectory/ResidentDirectory.tsx @@ -48,8 +48,8 @@ const ResidentDirectory = (): React.ReactElement => { if (data) { const buildingLabels: SelectLabel[] = data.buildings.map((building) => ({ - label: building.name!, - value: building.id!, + label: building.name, + value: building.id, })); setBuildingOptions(buildingLabels); } @@ -137,6 +137,7 @@ const ResidentDirectory = (): React.ReactElement => { setUserPageNum(1); getResidents(1); countResidents(); + /* eslint-disable-next-line react-hooks/exhaustive-deps */ }, [ resultsPerPage, residentSelections, diff --git a/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryFilters.tsx b/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryFilters.tsx index c92f6143..19e35a09 100644 --- a/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryFilters.tsx +++ b/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryFilters.tsx @@ -3,18 +3,16 @@ import { Box, Grid, GridItem, - Button, FormControl, FormLabel, Text, InputGroup, InputRightElement, IconButton, - Flex, } from "@chakra-ui/react"; -import { CloseIcon, SmallCloseIcon } from "@chakra-ui/icons"; +import { SmallCloseIcon } from "@chakra-ui/icons"; import { Card } from "react-bootstrap"; -import Select, { MultiValue, SingleValue } from "react-select"; +import Select, { MultiValue } from "react-select"; import { SingleDatepicker } from "chakra-dayzed-datepicker"; import { selectStyle } from "../../../theme/forms/selectStyles"; import { singleDatePickerStyle } from "../../../theme/forms/datePickerStyles"; @@ -124,13 +122,6 @@ const ResidentDirectoryFilters = ({ setEndDate(newEndDate); }; - const handleClearAll = () => { - setResidentSelections([]); - setBuildingSelections([]); - setEndDate(undefined); - setStartDate(undefined); - }; - useEffect(() => { getResidentOptions(); }, []); diff --git a/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx b/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx index e1274631..36e4e760 100644 --- a/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx +++ b/frontend/src/components/pages/ResidentDirectory/ResidentDirectoryTable.tsx @@ -169,10 +169,9 @@ const ResidentDirectoryTable = ({ {residents.map((resident) => { const { startDate, endDate } = getFormattedDates(resident); - // TODO: Remove non-null assertion from residentId return ( - {resident.residentId!} + {resident.residentId} ({ authenticatedUser: null, - /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ setAuthenticatedUser: ( + /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ _authenticatedUser: AuthenticatedUser | null, ): void => {}, }); diff --git a/frontend/src/theme/forms/selectStyles.tsx b/frontend/src/theme/forms/selectStyles.tsx index f9eefc63..806db7f3 100644 --- a/frontend/src/theme/forms/selectStyles.tsx +++ b/frontend/src/theme/forms/selectStyles.tsx @@ -11,13 +11,16 @@ const optionBackgroundColor = (isSelected: boolean, isFocused: boolean) => { return colors.white.default; }; +/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ const selectStyle: any = { + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ singleValue: (provided: any) => ({ ...provided, color: colors.teal[300], border: "none", boxShadow: "none", }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ control: (provided: any, state: any) => ({ ...provided, ...fontStyles["body-medium"], @@ -32,6 +35,7 @@ const selectStyle: any = { borderColor: state.isFocused ? colors.teal[400] : colors.teal[100], boxShadow: "none", }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ option: (provided: any, state: any) => ({ ...provided, ...fontStyles["body-medium"], @@ -41,6 +45,7 @@ const selectStyle: any = { backgroundColor: colors.teal[100], }, }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ multiValue: (provided: any, state: any) => ({ ...provided, backgroundColor: colors.teal[50], @@ -55,13 +60,16 @@ const selectStyle: any = { }), }; +/* eslint-disable-next-line @typescript-eslint/no-explicit-any */ const viewStyle: any = { + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ singleValue: (provided: any) => ({ ...provided, color: colors.teal[300], border: "none", boxShadow: "none", }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ control: (provided: any, state: any) => ({ ...provided, ...fontStyles["body-medium"], @@ -79,6 +87,7 @@ const viewStyle: any = { ? "transparent" : provided.backgroundColor, }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ option: (provided: any, state: any) => ({ ...provided, ...fontStyles["body-medium"], @@ -88,6 +97,7 @@ const viewStyle: any = { backgroundColor: colors.teal[100], }, }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ multiValue: (provided: any, state: any) => ({ ...provided, backgroundColor: colors.teal[50], @@ -100,6 +110,7 @@ const viewStyle: any = { cursor: "pointer", }, }), + /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ indicatorSeparator: (provided: any, state: any) => ({ ...provided, backgroundColor: state.isDisabled diff --git a/frontend/src/types/UserTypes.ts b/frontend/src/types/UserTypes.ts index 23b39f09..ca1fa6ee 100644 --- a/frontend/src/types/UserTypes.ts +++ b/frontend/src/types/UserTypes.ts @@ -8,6 +8,12 @@ export type User = { authId: string; }; +export type GetUserParams = { + returnAll?: boolean; + pageNumber?: number; + resultsPerPage?: number; +}; + export type UpdateUserParams = Omit; export type GetUsersResponse = {