1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-20 20:19:35 +02:00
flame/client/src/components/Apps/AppGrid/AppGrid.tsx

55 lines
1.4 KiB
TypeScript
Raw Normal View History

import { Link } from 'react-router-dom';
import { App, Category } from '../../../interfaces';
import AppCard from '../AppCard/AppCard';
import classes from './AppGrid.module.css';
interface ComponentProps {
categories: Category[];
apps: App[]
totalCategories?: number;
2021-09-06 12:24:01 +02:00
searching: boolean;
}
const AppGrid = (props: ComponentProps): JSX.Element => {
let apps: JSX.Element;
if (props.categories.length > 0) {
apps = (
<div className={classes.AppGrid}>
{props.categories.map((category: Category): JSX.Element => {
return <AppCard key={category.id} category={category} apps={props.apps.filter((app: App) => app.categoryId === category.id)} />
})}
</div>
2021-09-06 12:24:01 +02:00
);
} else {
if (props.totalCategories) {
2021-09-06 12:24:01 +02:00
if (props.searching) {
apps = (
<p className={classes.AppsMessage}>
No apps match your search criteria
</p>
);
} else {
apps = (
<p className={classes.AppsMessage}>
There are no pinned application categories. You can pin them from the{' '}
2021-09-06 12:24:01 +02:00
<Link to="/applications">/applications</Link> menu
</p>
);
}
} else {
apps = (
2021-09-06 12:24:01 +02:00
<p className={classes.AppsMessage}>
You don't have any applications. You can add a new one from the{' '}
2021-09-06 12:24:01 +02:00
<Link to="/applications">/applications</Link> menu
</p>
);
}
}
return apps;
2021-09-06 12:24:01 +02:00
};
2021-09-06 12:24:01 +02:00
export default AppGrid;