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

59 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-05-10 19:02:16 +02:00
import { Fragment, useEffect } from 'react';
import { Link } from 'react-router-dom';
2021-05-07 18:30:06 +02:00
2021-05-10 19:02:16 +02:00
// Redux
import { connect } from 'react-redux';
import { getApps } from '../../store/actions';
// Typescript
import { App } from '../../interfaces';
// CSS
2021-05-07 18:30:06 +02:00
import classes from './Apps.module.css';
2021-05-10 19:02:16 +02:00
// UI
2021-05-07 18:30:06 +02:00
import { Container } from '../UI/Layout/Layout';
2021-05-09 18:36:55 +02:00
import Headline from '../UI/Headlines/Headline/Headline';
2021-05-10 19:02:16 +02:00
import Spinner from '../UI/Spinner/Spinner';
// Subcomponents
2021-05-09 18:36:55 +02:00
import AppCard from './AppCard/AppCard';
2021-05-07 18:30:06 +02:00
2021-05-10 19:02:16 +02:00
interface ComponentProps {
getApps: Function;
apps: App[];
loading: boolean;
}
const Apps = (props: ComponentProps): JSX.Element => {
useEffect(() => {
props.getApps()
}, [props.getApps]);
2021-05-07 18:30:06 +02:00
return (
2021-05-10 19:02:16 +02:00
<Container>
<Headline
title='Pinned Apps'
subtitle={<Link to='/'>Go back</Link>}
/>
<Headline title='All Apps' />
<div className={classes.Apps}>
{props.loading
? 'loading'
: props.apps.map((app: App): JSX.Element => {
return <AppCard key={app.id} app={app} />
})
}
</div>
</Container>
2021-05-07 18:30:06 +02:00
)
}
2021-05-10 19:02:16 +02:00
const mapStateToProps = (state: any) => {
return {
apps: state.app.apps,
loading: state.app.loading
}
}
export default connect(mapStateToProps, { getApps })(Apps);