Skip to content

Commit

Permalink
Removal of eslint errors
Browse files Browse the repository at this point in the history
Mostly removed unnecesary code.
  • Loading branch information
chrsrns committed Oct 10, 2023
1 parent 41a905b commit 33b4925
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 106 deletions.
22 changes: 2 additions & 20 deletions src-frontend-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import {
Card,
Col,
Container,
Nav,
NavDropdown,
Navbar,
Row,
Stack,
Expand Down Expand Up @@ -38,9 +36,6 @@ import SideNotifications from "./components/Notifications";
import {
enable as enableDarkMode,
disable as disableDarkMode,
auto as followSystemColorScheme,
exportGeneratedCSS as collectCSS,
isEnabled as isDarkReaderEnabled,
} from "darkreader";
import { FeedbackForm } from "./components/FeedbackForm";

Expand Down Expand Up @@ -117,8 +112,6 @@ const radios: SidebarColBtnType[] = [
},
];
const SidebarCol = () => {
const [radioValue, setRadioValue] = useState("1");

useEffect(() => {
if (Cookies.get("usertype") == "Admin")
radios.push({
Expand All @@ -145,8 +138,6 @@ const SidebarCol = () => {
name={radio.name}
iconClass={radio.iconClass}
value={radio.value}
radioValue={radioValue}
setRadioValue={setRadioValue}
link={radio.link}
/>
))}
Expand All @@ -156,15 +147,7 @@ const SidebarCol = () => {
);
};

const SidebarColBtn = ({
idx,
name,
iconClass,
value,
radioValue,
setRadioValue,
link,
}) => {
const SidebarColBtn = ({ idx, name, iconClass, value, link }) => {
const navigate = useNavigate();
const location = useLocation();

Expand All @@ -174,9 +157,8 @@ const SidebarColBtn = ({
variant={link === location.pathname ? "primary" : "secondary"}
name="radio"
value={value}
onClick={(e) => {
onClick={() => {
navigate(link);
setRadioValue(e.currentTarget.value);
}}
size="lg"
className="shadow-sm rounded-pill"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Form, Button, Container, Row, Col, Stack } from 'react-bootstrap';
import { useEffect, useState } from 'react';
import { Form, Button, Stack } from 'react-bootstrap';
import Select from 'react-select'

import LoadingOverlay from 'react-loading-overlay-ts';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment from 'moment';
import React, { useEffect, useState } from 'react';
import { Form, Button, Container, Row, Col, Stack } from 'react-bootstrap';
import { useEffect, useState } from 'react';
import { Form, Button, Row, Col, Stack } from 'react-bootstrap';
import Select from 'react-select'

import LoadingOverlay from 'react-loading-overlay-ts';
Expand Down Expand Up @@ -68,7 +68,7 @@ function RegistrationForm() {
setUserTypes(data)
return data;
})
]).then(responses => {
]).then(() => {
console.log("done")
setIsLoading(false)
})
Expand Down Expand Up @@ -180,7 +180,7 @@ function RegistrationForm() {
}

// Validate Password
if (formData.login_password.length < 6 && formData.login_password.length != 0 && formData.id) {
if (formData.login_password.length < 6 && formData.login_password.length !== 0 && formData.id) {
newFormErrors.login_password = 'Password must be at least 6 characters long or be left blank to leave unchanged';
isValid = false;
} else if (formData.login_password.length < 6 && !formData.id) {
Expand Down
23 changes: 1 addition & 22 deletions src-frontend-react/src/components/AdminTools/index.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,11 @@
import { useEffect, useState } from "react";
import { Button, Card, Col, Form, FormGroup, Row } from "react-bootstrap";
import { customFetch } from "../../utils";
import { Button, Card, Col, Row } from "react-bootstrap";
import { Jumbotron } from "../Jumbotron";
import { AnnouncementsForm } from "./AnnouncementsForm";
import RegistrationForm from "./RegistrationForm";
import UserApprovalComponent from "./UserApproval";

export const AdminTools = ({ sidebarbtn_onClick }) => {

const [data, setData] = useState([]);

useEffect(() => {
customFetch(`${global.server_backend_url}/backend/users/announcements`)
.then((response) => {
if (response.ok) {
console.log("res ok")
return response.json();
}
throw response;
})
.then((data) => {
setData(data);
console.log(data);
}).catch((err) => {
console.log(err)
});
}, []);

return (
<>
<p className="float-start d-lg-none d-md-block">
Expand Down
21 changes: 7 additions & 14 deletions src-frontend-react/src/components/AppointmentFormModal/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import moment from "moment";
import { useEffect, useState } from "react";
import { Button, Container, Form, ListGroup, Modal, Stack, Tab, Tabs } from "react-bootstrap";
import { Button, Form, ListGroup, Modal, Stack, Tab, Tabs } from "react-bootstrap";

import LoadingOverlay from 'react-loading-overlay-ts';
import { customFetch } from "../../utils";
import Chat from "../Chat/ChatBubble";

const AppointmentFormUserList = ({ fname, mname, lname, id, onButtonClick }) => {
const AppointmentFormUserList = ({ fname, mname, lname, onButtonClick }) => {
return (
<ListGroup.Item className="d-flex justify-content-between align-items-center">
<>
Expand All @@ -20,13 +20,6 @@ const AppointmentFormUserList = ({ fname, mname, lname, id, onButtonClick }) =>

/// TODO Refactor this component to imitate use of default values in RegistrationForm
export const AppointmentFormModal = ({ id, show, eventRange, handleClose: handleCloseCallback }) => {
const [defaultValues, setDefaultValues] = useState({
selectedStaffList: [],
selectedStudentList: [],
selectedScheduleType: "",
appointmentTitle: "",
appointmentContent: ""
})

const [staffList, setStaffList] = useState([])
const [selectedStaffList, setSelectedStaffList] = useState([]);
Expand Down Expand Up @@ -73,7 +66,7 @@ export const AppointmentFormModal = ({ id, show, eventRange, handleClose: handle
else throw response;
})
.then((data) => {
if (data != scheduleTypes)
if (data !== scheduleTypes)
setScheduleTypes(data);
return data;
}),
Expand All @@ -84,7 +77,7 @@ export const AppointmentFormModal = ({ id, show, eventRange, handleClose: handle
else throw response;
})
.then((data) => {
if (data != scheduleRepeatTypes)
if (data !== scheduleRepeatTypes)
setScheduleRepeatTypes(data);
return data;
}),
Expand All @@ -97,7 +90,7 @@ export const AppointmentFormModal = ({ id, show, eventRange, handleClose: handle
throw response;
})
.then((data) => {
if (data != studentsList)
if (data !== studentsList)
setStudentsList(data);
}),

Expand All @@ -109,11 +102,11 @@ export const AppointmentFormModal = ({ id, show, eventRange, handleClose: handle
throw response;
})
.then((data) => {
if (data != staffList)
if (data !== staffList)
setStaffList(data);
}),

]).then(responses => {
]).then(() => {
console.log("done")
setIsLoading(false)
})
Expand Down
2 changes: 0 additions & 2 deletions src-frontend-react/src/components/Appointments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import DragAndDropCalendar from "../DragAndDropCalendar";

const localizer = momentLocalizer(moment);
export const Appointments = ({ sidebarbtn_onClick }) => {
const [data, setData] = useState([]);

return (
<>
<p className="float-start d-lg-none d-md-block">
Expand Down
6 changes: 3 additions & 3 deletions src-frontend-react/src/components/Chat/ChatBubble/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Container, Row, Col, Card, Stack, Form, Button } from 'react-bootstrap';
import { useEffect, useState } from 'react';
import { Container, Card, Stack, Form, Button } from 'react-bootstrap';
import { useCookies } from 'react-cookie';
import LoadingOverlay from 'react-loading-overlay-ts';
import { customFetch } from '../../../utils';
Expand All @@ -9,7 +9,7 @@ const DEFAULT_FORM_VALUES = {
}

const Chat = ({ scheduleId }) => {
const [cookies, setCookie] = useCookies(['login_username'])
const [cookies] = useCookies(['login_username'])

const [messages, setMessages] = useState([])
const [formData, setFormData] = useState(DEFAULT_FORM_VALUES);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment, useCallback, useEffect, useMemo, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import PropTypes from 'prop-types'
import { Calendar, Views, DateLocalizer } from 'react-big-calendar'
import withDragAndDrop from 'react-big-calendar/lib/addons/dragAndDrop'
Expand Down Expand Up @@ -60,7 +60,7 @@ export default function DragAndDropCalendar({ localizer }) {
if (response.ok) return response.json();
else throw response;
}).then((data) => {
if (data != eventsFull) {
if (data !== eventsFull) {
setEventsFull(data);

setEventsMapped([...data.map((eventFull) => {
Expand Down Expand Up @@ -218,7 +218,7 @@ export default function DragAndDropCalendar({ localizer }) {
Completed: "#d8fea1"
}
const eventPropGetter = useCallback(
(event, start, end, isSelected) => ({
(event, _start, _end) => ({
...(event.state === "Available" && {
style: {
backgroundColor: appointmentsTypesColors.Available,
Expand Down
2 changes: 1 addition & 1 deletion src-frontend-react/src/components/FeedbackForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const FeedbackForm = ({ sidebarbtn_onClick }) => {
if (response.ok) {
return response.json();
} else throw response;
}).then((data) => {
}).then(() => {
toast(`Thank you for your feedback!`)
}).catch((err) => {
console.log(err)
Expand Down
2 changes: 1 addition & 1 deletion src-frontend-react/src/components/LoadingModal/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from 'react';
import { useState, useEffect } from 'react';
import { Modal, Spinner } from 'react-bootstrap';

const FullscreenLoaderModal = ({ show }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const RegistrationForm = () => {
}

// Validate Password
if (formData.login_password.length < 6 && formData.login_password.length != 0 && formData.id) {
if (formData.login_password.length < 6 && formData.login_password.length !== 0 && formData.id) {
newFormErrors.login_password = 'Password must be at least 6 characters long or be left blank to leave unchanged';
isValid = false;
} else if (formData.login_password.length < 6 && !formData.id) {
Expand Down
33 changes: 3 additions & 30 deletions src-frontend-react/src/components/LoginFormModal/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,15 @@
import React, { useEffect, useState } from 'react';
import { Modal, Button, Form, Tab, Tabs, Col, Row, ToastContainer, Toast } from 'react-bootstrap';
import { useEffect, useState } from 'react';
import { Modal, Button, Form, Tab, Tabs, ToastContainer, Toast } from 'react-bootstrap';
import { useCookies } from 'react-cookie';

import LoadingOverlay from "react-loading-overlay-ts";
import { toast } from 'react-toastify';
import { customFetch } from '../../utils';

import RegistrationForm from './RegistrationForm';
import { socket } from '../../socket';

import Cookies from "js-cookie";

const DEFAULT_REG_FORM_VALUES = {
fname: '',
mname: '',
lname: '',
addr: '',
cnum: '',
emailaddr: '',
bdate: '',
type: '',
login_username: '', // Add username field
}

export const LoginFormModal = ({ show, onHide, isLoggingIn }) => {
const [cookies, setCookie] = useCookies(['accessToken', 'refreshToken', 'login_username'])

const [regFormData, setRegFormData] = useState(DEFAULT_REG_FORM_VALUES)
const [regFormErrors, setRegFormErrors] = useState(DEFAULT_REG_FORM_VALUES)
const [userTypes, setUserTypes] = useState([])
const [, setCookie] = useCookies(['accessToken', 'refreshToken', 'login_username'])

const [showNotif, setShowNotif] = useState(false)
const [responseHeader, setResponseHeader] = useState("")
Expand Down Expand Up @@ -82,14 +63,6 @@ export const LoginFormModal = ({ show, onHide, isLoggingIn }) => {
])
}

const handleChange = (e) => {
const { name, value } = e.target;
setRegFormData({
...regFormData,
[name]: value,
});
};

useEffect(() => {
fetchAll()
}, [])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from 'react';
import { Form, Button, Container, Row, Col, Stack } from 'react-bootstrap';
import { useEffect, useState } from 'react';
import { Form, Button, Stack } from 'react-bootstrap';
import Select from 'react-select'

import LoadingOverlay from 'react-loading-overlay-ts';
Expand Down
1 change: 0 additions & 1 deletion src-frontend-react/src/components/Notifications/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useEffect, useState } from "react";
import { Alert, ListGroup } from "react-bootstrap";
import LoadingOverlay from "react-loading-overlay-ts";
import { toast } from "react-toastify";
import { customFetch } from "../../utils";

Expand Down

0 comments on commit 33b4925

Please sign in to comment.