diff --git a/client/src/components/DateInput.jsx b/client/src/components/DateInput.jsx
index d7943aa..a54175d 100644
--- a/client/src/components/DateInput.jsx
+++ b/client/src/components/DateInput.jsx
@@ -3,6 +3,8 @@ import styles from "./DateInput.module.css";
/* Custom date input with label and callback */
+// todo: begin here with jsdoc task
+
function DateInput({ label, value, handleChange }) {
const id = label.toLowerCase();
diff --git a/client/src/lib/response.js b/client/src/lib/response.js
index f60137c..504c8fd 100644
--- a/client/src/lib/response.js
+++ b/client/src/lib/response.js
@@ -1,5 +1,9 @@
-/*
-Helper functions to validate API responses
+/**
+ * Helper function to validate API responses
+ * @param {res} res
+ * @param {json} json
+ * @param {function} setAuth
+ * @returns {void}
*/
export function validateAdminResponse(res, json, setAuth) {
diff --git a/client/src/pages-admin/Dashboard/Dashboard.jsx b/client/src/pages-admin/Dashboard/Dashboard.jsx
index 09ba95d..b7bbd67 100644
--- a/client/src/pages-admin/Dashboard/Dashboard.jsx
+++ b/client/src/pages-admin/Dashboard/Dashboard.jsx
@@ -2,6 +2,11 @@ import { Navigate, useOutletContext } from "react-router-dom";
import DashboardStats from "./DashboardStats.jsx";
import DashboardTable from "./DashboardTable.jsx";
+/**
+ * Dashboard page in admin app
+ * @returns {JSX.Element}
+ */
+
function Dashboard() {
const { auth } = useOutletContext();
diff --git a/client/src/pages-admin/Dashboard/DashboardStats.jsx b/client/src/pages-admin/Dashboard/DashboardStats.jsx
index d769411..49eef8d 100644
--- a/client/src/pages-admin/Dashboard/DashboardStats.jsx
+++ b/client/src/pages-admin/Dashboard/DashboardStats.jsx
@@ -14,6 +14,11 @@ import {
import { validateAdminResponse } from "../../lib/response.js";
import ErrorComponent from "../../components/ErrorComponent.jsx";
+/**
+ * Component used to fetch and render database stats
+ * @returns {JSX.Element}
+ */
+
function DashboardStats() {
const COLORS = ["#0088FE", "#00C49F", "#FFBB28", "#FF8042", "#185c36"];
const { apihost, auth, setAuth } = useOutletContext();
diff --git a/client/src/pages-admin/Dashboard/DashboardTable.jsx b/client/src/pages-admin/Dashboard/DashboardTable.jsx
index c73639c..5a3f32d 100644
--- a/client/src/pages-admin/Dashboard/DashboardTable.jsx
+++ b/client/src/pages-admin/Dashboard/DashboardTable.jsx
@@ -7,6 +7,11 @@ import CardWrapper from "../../components/CardWrapper.jsx";
import ErrorComponent from "../../components/ErrorComponent.jsx";
import { validateAdminResponse } from "../../lib/response.js";
+/**
+ * Component used to fetch and render all rows in interactions table
+ * @returns {JSX.Element}
+ */
+
function DashboardTable() {
const { apihost, auth, setAuth } = useOutletContext();
const [rows, setRows] = useState([]);
diff --git a/client/src/pages-admin/Database/Database.jsx b/client/src/pages-admin/Database/Database.jsx
index c97f03a..2da3abb 100644
--- a/client/src/pages-admin/Database/Database.jsx
+++ b/client/src/pages-admin/Database/Database.jsx
@@ -1,7 +1,3 @@
-/*
-Database page in app admin area. Contains DatabaseTable and DatabaseModal components to help organize code.
- */
-
import { Navigate, useOutletContext } from "react-router-dom";
import { useState } from "react";
import TabSelector from "../../components/TabSelector.jsx";
@@ -9,6 +5,11 @@ import DatabaseTable from "./DatabaseTable.jsx";
import DatabaseModal from "./DatabaseModal.jsx";
import styles from "./Database.module.css";
+/**
+ * Database page in admin app
+ * @returns {JSX.Element}
+ */
+
function Database() {
const { auth } = useOutletContext();
const [activeTab, setActiveTab] = useState("");
diff --git a/client/src/pages-admin/Database/DatabaseModal.jsx b/client/src/pages-admin/Database/DatabaseModal.jsx
index eb10450..fd89bea 100644
--- a/client/src/pages-admin/Database/DatabaseModal.jsx
+++ b/client/src/pages-admin/Database/DatabaseModal.jsx
@@ -13,6 +13,16 @@ import Form from "../../components/Form.jsx";
import Button from "../../components/Button.jsx";
import { validateAdminResponse } from "../../lib/response.js";
+/**
+ * Modal component used to add and edit rows in database tables
+ * @param {string} table
+ * @param {string} rowId
+ * @param {boolean} modalOpen
+ * @param {() => void} setModalOpen
+ * @param {() => void} setRefresh
+ * @returns {JSX.Element}
+ */
+
function DatabaseModal({ table, rowId, modalOpen, setModalOpen, setRefresh }) {
/* Component State */
const { apihost, auth, setAuth } = useOutletContext();
diff --git a/client/src/pages-admin/Database/DatabaseTable.jsx b/client/src/pages-admin/Database/DatabaseTable.jsx
index 1ce2dff..f4a7a45 100644
--- a/client/src/pages-admin/Database/DatabaseTable.jsx
+++ b/client/src/pages-admin/Database/DatabaseTable.jsx
@@ -1,8 +1,3 @@
-/*
-Table wrapper component for Database.jsx.
-Responsible for fetching and rendering table rows using the app's table component.
- */
-
import { useState, useEffect } from "react";
import PropTypes from "prop-types";
import { useOutletContext } from "react-router-dom";
@@ -12,6 +7,15 @@ import Table from "../../components/Table.jsx";
import Button from "../../components/Button.jsx";
import { validateAdminResponse } from "../../lib/response.js";
+/**
+ * Component used to fetch and render database table rows
+ * @param {string} table
+ * @param {(string) => void} setRowId
+ * @param {(boolean) => void} setModalOpen
+ * @param {number} refresh
+ * @returns {JSX.Element}
+ */
+
function DatabaseTable({ table, setRowId, setModalOpen, refresh }) {
const { apihost, auth, setAuth } = useOutletContext();
const [rows, setRows] = useState([]);
diff --git a/client/src/pages-admin/Reporting/Reporting.jsx b/client/src/pages-admin/Reporting/Reporting.jsx
index b098f9a..235e06d 100644
--- a/client/src/pages-admin/Reporting/Reporting.jsx
+++ b/client/src/pages-admin/Reporting/Reporting.jsx
@@ -3,13 +3,17 @@ import { Navigate, useOutletContext } from "react-router-dom";
import { useState } from "react";
import ReportingDisplay from "./ReportingDisplay.jsx";
-const defaultParams = {
- startMonth: "",
- endMonth: "",
- category: "",
-};
+/**
+ * Admin reporting page in admin app
+ * @returns {JSX.Element}
+ */
function Reporting() {
+ const defaultParams = {
+ startMonth: "",
+ endMonth: "",
+ category: "",
+ };
const { auth } = useOutletContext();
const [params, setParams] = useState(defaultParams);
diff --git a/client/src/pages-admin/Reporting/ReportingDisplay.jsx b/client/src/pages-admin/Reporting/ReportingDisplay.jsx
index 2faf3b1..4a12ce0 100644
--- a/client/src/pages-admin/Reporting/ReportingDisplay.jsx
+++ b/client/src/pages-admin/Reporting/ReportingDisplay.jsx
@@ -1,8 +1,3 @@
-/**
- *
- *
- */
-
import PropTypes from "prop-types";
import { useState, useEffect } from "react";
import { useOutletContext } from "react-router-dom";
@@ -10,6 +5,12 @@ import { validateAdminResponse } from "../../lib/response.js";
import { toast } from "react-hot-toast";
import parseMonthInput from "../../lib/parseMonthInput.js";
+/**
+ * A React component to fetch and render admin report data
+ * @param {{startMonth: string, endMonth: string, categoy: string}} params Parameters for admin report
+ * @returns {JSX.Element}
+ */
+
function ReportingDisplay({ params }) {
const { auth, apihost, setAuth } = useOutletContext();
const [report, setReport] = useState(null);
diff --git a/client/src/pages-admin/Reporting/ReportingParams.jsx b/client/src/pages-admin/Reporting/ReportingParams.jsx
index e13641e..5761841 100644
--- a/client/src/pages-admin/Reporting/ReportingParams.jsx
+++ b/client/src/pages-admin/Reporting/ReportingParams.jsx
@@ -2,6 +2,13 @@ import PropTypes from "prop-types";
import Form from "../../components/Form.jsx";
import SelectInput from "../../components/SelectInput.jsx";
+/**
+ * Component to capture admin report params user input
+ * @param {{startMonth: string, endMonth: string, category: string}} params Admin report params
+ * @param {function} updateParams Callback function to update report params
+ * @return {JSX.Element}
+ */
+
const categories = [
{ id: "type", value: "Types" },
{ id: "format", value: "Formats" },
diff --git a/client/src/pages/Home.jsx b/client/src/pages/Home.jsx
index 7f38f59..84a4d1f 100644
--- a/client/src/pages/Home.jsx
+++ b/client/src/pages/Home.jsx
@@ -7,6 +7,11 @@ import ErrorComponent from "../components/ErrorComponent.jsx";
import styles from "./Home.module.css";
+/**
+ * App homepage component
+ * @returns {JSX.Element}
+ */
+
function Home() {
const { apihost, options } = useOutletContext();
const [effectTrigger, setEffectTrigger] = useState(true);
diff --git a/client/src/pages/Record.jsx b/client/src/pages/Record.jsx
index cb5d4c2..f7a0c0a 100644
--- a/client/src/pages/Record.jsx
+++ b/client/src/pages/Record.jsx
@@ -15,6 +15,11 @@ const defaultFormState = {
format: "",
};
+/**
+ * App recording page component
+ * @returns {JSX.Element}
+ */
+
function Record() {
// Component state
const { apihost, options } = useOutletContext();
diff --git a/client/src/pages/Report.jsx b/client/src/pages/Report.jsx
index a54c86f..37e0567 100644
--- a/client/src/pages/Report.jsx
+++ b/client/src/pages/Report.jsx
@@ -26,6 +26,11 @@ import CountReport from "../components/CountReport";
import CardWrapper from "../components/CardWrapper";
import TabSelector from "../components/TabSelector.jsx";
+/**
+ * App report page component
+ * @returns {JSX.Element}
+ */
+
function Report() {
const defaultFormState = {
start: "",
From 8e05170df4c3901bef6d2de25c7ab02848e5e656 Mon Sep 17 00:00:00 2001
From: James Spears
Date: Fri, 13 Dec 2024 10:58:23 -0500
Subject: [PATCH 07/16] Improve SelectInput and DateInput prop handling and
typing
Signed-off-by: James Spears
---
client/src/components/Button.jsx | 2 +-
client/src/components/DateInput.jsx | 22 ++++++++++----
client/src/components/SelectInput.jsx | 7 ++---
.../Reporting/ReportingDisplay.jsx | 3 +-
.../pages-admin/Reporting/ReportingParams.jsx | 29 ++++++++-----------
client/src/pages/Record.jsx | 3 ++
client/src/pages/Report.jsx | 9 ++++--
7 files changed, 44 insertions(+), 31 deletions(-)
diff --git a/client/src/components/Button.jsx b/client/src/components/Button.jsx
index 66c1b48..e9857ef 100644
--- a/client/src/components/Button.jsx
+++ b/client/src/components/Button.jsx
@@ -5,7 +5,7 @@ import styles from "./Button.module.css";
* Custom button component
* @param {string} id - prop to set `data-id` property of button
* @param {string} text - button text property
- * @param {() => void} action - button click callback function
+ * @param {(event) => void} action - button click callback function
* @param {'primary' | 'danger'} variant - styled button variant
* @param {'button' | 'submit'} type
* @param {Object} [style] - Optional React style object
diff --git a/client/src/components/DateInput.jsx b/client/src/components/DateInput.jsx
index a54175d..75e64dd 100644
--- a/client/src/components/DateInput.jsx
+++ b/client/src/components/DateInput.jsx
@@ -3,16 +3,24 @@ import styles from "./DateInput.module.css";
/* Custom date input with label and callback */
-// todo: begin here with jsdoc task
-
-function DateInput({ label, value, handleChange }) {
- const id = label.toLowerCase();
+/**
+ * Custom date input with label and callback
+ * @param id {string}
+ * @param label {string}
+ * @param type {'date' | 'month'}
+ * @param value {string}
+ * @param handleChange {(event) => void}
+ * @returns {JSX.Element}
+ */
+function DateInput({ id, label, type, value, handleChange }) {
return (
-
+