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 1 commit 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
53 changes: 27 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,33 @@ const useStyles = makeStyles({
},
});

/**
* 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.
*/

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
31 changes: 16 additions & 15 deletions frontend/src/components/utils/DropDownWithLabel.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
import React from 'react';
import { Typography, Grid } from '@material-ui/core';
import DropDown from './DropDown';

type MenuElement = {
item: string;
callback: () => void;
};

interface DropDownWithLabelProps {
label: string;
menuItems: MenuElement[];
labelStyle?: React.CSSProperties;
isMobile: boolean;
}

/**
* A dropdown component with a label.
*
Expand All @@ -20,21 +36,6 @@
*
* <DropDownWithLabel label="Select an item" menuItems={menuItems} isMobile={true} />
*/
import React from 'react';
import { Typography, Grid } from '@material-ui/core';
import DropDown from './DropDown';

type MenuElement = {
item: string;
callback: () => void;
};

interface DropDownWithLabelProps {
label: string;
menuItems: MenuElement[];
labelStyle?: React.CSSProperties;
isMobile: boolean;
}

const DropDownWithLabel: React.FC<DropDownWithLabelProps> = ({
label,
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[] = [
'[email protected]', // Grace
'[email protected]', // Sophia
Expand Down
Loading