dashboard/src/components/appList.tsx

30 lines
875 B
TypeScript
Raw Normal View History

2021-06-14 11:29:03 +02:00
import AppCategory, { IAppCategoryProps } from "./appCategory";
import { IAppProps } from "./app";
2020-07-08 19:36:36 +02:00
import { Headline, ListContainer } from "./elements";
2020-07-08 19:36:36 +02:00
export interface IAppListProps {
categories: Array<IAppCategoryProps>;
apps: Array<IAppProps>;
}
2020-07-10 00:17:18 +02:00
2021-03-21 19:59:18 +01:00
/**
* Renders one list containing all app categories and uncategorized apps
2021-06-14 11:29:03 +02:00
* @param {IAppListProps} props props of the given list of apps
* @returns {React.ReactNode} the app list component
2021-03-21 19:59:18 +01:00
*/
const AppList = ({ categories, apps }: IAppListProps) => (
<ListContainer>
<Headline>Applications</Headline>
{categories &&
categories.map(({ name, items }, idx) => (
<AppCategory key={[name, idx].join("")} name={name} items={items} />
))}
{apps && (
2021-06-14 11:29:03 +02:00
<AppCategory name={categories ? "Uncategorized apps" : ""} items={apps} />
2021-03-21 19:59:18 +01:00
)}
</ListContainer>
);
2020-07-08 19:36:36 +02:00
export default AppList;