Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HomeConst.ts documentation #388

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 15 additions & 26 deletions frontend/src/components/utils/DropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,3 @@
/**
* DropDown Component
*
* @remarks
* A dropdown component that displays a button and a menu with selectable items.
* The component uses Material-UI components for consistent styling.
*
* @component
* @example
* ```typescript
* const menuItems = [
* { item: 'Price', callback: () => setSortBy('avgPrice')},
* { item: 'Rating', callback: () => setSortBy('avgRating')},
* { item: 'Date Added', callback: () => setSortBy('id')},
* ];
*
* function App() {
* return (
* <DropDown menuItems={menuItems} />
* );
* }
*```
* @param {Object} props - The props of the component.
* @param {MenuElement[]} props.menuItems - An array of menu items, each containing an item name and a callback function.
* @returns {JSX.Element} The rendered dropdown component.
*/
import React, { useState } from 'react';
import { Button, Menu, MenuItem, SvgIcon } from '@material-ui/core';
import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
Expand Down Expand Up @@ -72,6 +46,21 @@ const useStyles = makeStyles({
},
});

/**
* DropDown – A dropdown component that displays a button and a menu with selectable items.
*
* @remarks
* The component uses Material-UI components for consistent styling. It allows users to select an item from a dropdown menu, triggering a callback function.
*
* @param {MenuElement[]} props.menuItems – An array of menu items, each containing an item name and a callback function.
* @param {boolean} [props.isMobile] – Optional flag to indicate if the component is being used on a mobile device.
* @param {string} [props.defaultValue] – Optional default value to be displayed on the button.
* @param {string} [props.className] – Optional custom class name for the button.
* @param {boolean} [props.icon] – Optional flag to display an icon on the button.
*
* @return {JSX.Element} – The rendered dropdown component.
*/

export default function DropDown({ menuItems, isMobile, defaultValue, className, icon }: Props) {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const [selected, setSelected] = useState<string>(defaultValue ? defaultValue : menuItems[0].item);
Expand Down
36 changes: 14 additions & 22 deletions frontend/src/components/utils/DropDownWithLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
/**
* A dropdown component with a label.
*
* @component
*
* @param {string} label - The label for the dropdown.
* @param {MenuElement[]} menuItems - An array of menu items, each containing an item name and a callback function.
* @param {React.CSSProperties} [labelStyle] - The style of the label.
* @param {boolean} isMobile - Whether the dropdown is being displayed on a mobile device.
*
* @returns {JSX.Element} The rendered dropdown component.
*
* @example
* // Usage:
* const menuItems = [
* { item: 'Item 1', callback: () => console.log('Item 1 selected') },
* { item: 'Item 2', callback: () => console.log('Item 2 selected') },
* { item: 'Item 3', callback: () => console.log('Item 3 selected') },
* ];
*
* <DropDownWithLabel label="Select an item" menuItems={menuItems} isMobile={true} />
*/
import React from 'react';
import { Typography, Grid } from '@material-ui/core';
import DropDown from './DropDown';
Expand All @@ -36,6 +14,20 @@ interface DropDownWithLabelProps {
isMobile: boolean;
}

/**
* DropDownWithLabel – A dropdown component with a label.
*
* @remarks
* This component renders a label alongside a dropdown menu. It is designed to be responsive and can adjust its layout based on whether it is displayed on a mobile device.
*
* @param {string} props.label – The label for the dropdown.
* @param {MenuElement[]} props.menuItems – An array of menu items, each containing an item name and a callback function.
* @param {React.CSSProperties} [props.labelStyle] – The style of the label.
* @param {boolean} props.isMobile – Whether the dropdown is being displayed on a mobile device.
*
* @return {JSX.Element} – The rendered dropdown component.
*/

const DropDownWithLabel: React.FC<DropDownWithLabelProps> = ({
label,
menuItems,
Expand Down
105 changes: 0 additions & 105 deletions frontend/src/components/utils/Footer/CantFindApartmentModal.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions frontend/src/constants/HomeConsts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
export const loadingLength = 5;

/**
* admins – List of CUApts' admins' email addresses.
*
* @remarks
* This array contains the emails of users who have access to the admin system on CUApts. Each email should be followed with a comment indicating
* the admin's name. This array should be updated periodically to remove old admins and add new admins.
*
* @return {string[]} – An array of admin email addresses.
*/
export const admins: string[] = [
'gs622@cornell.edu', // Grace
'tpp38@cornell.edu', // Sophia
Expand Down
Loading