guesstimate/client/src/routes/home/index.tsx

59 lines
2.3 KiB
TypeScript
Raw Normal View History

2020-07-09 13:00:42 +02:00
import React, { FunctionComponent } from "react";
2020-04-22 22:07:52 +02:00
import style from "./style.module.css";
2020-07-09 13:00:42 +02:00
import { useHistory } from 'react-router';
2020-04-20 11:14:46 +02:00
import { base58UUID } from '../../util/uuid';
2020-04-20 14:07:26 +02:00
import { useStoredProjectList } from "../../hooks/use-stored-project-list";
2020-04-20 11:14:46 +02:00
2020-07-09 13:00:42 +02:00
const Home: FunctionComponent = () => {
2020-04-20 14:07:26 +02:00
const [ projects, refreshProjects ] = useStoredProjectList();
2020-07-09 13:00:42 +02:00
const history = useHistory();
2020-04-20 11:14:46 +02:00
const openNewProject = () => {
const uuid = base58UUID();
2020-07-09 13:00:42 +02:00
history.push(`/p/${uuid}`);
2020-04-20 11:14:46 +02:00
};
return (
2020-07-09 13:00:42 +02:00
<div className={`container ${style.home}`}>
<div className="columns">
<div className="column">
<div className="buttons is-right">
<button className="button is-primary"
2020-04-20 11:14:46 +02:00
onClick={openNewProject}>
<strong>+</strong>&nbsp;&nbsp;Nouveau projet
</button>
</div>
2020-07-09 13:00:42 +02:00
<div className="panel">
<p className="panel-heading">
2020-04-20 11:14:46 +02:00
Mes projets
</p>
2020-07-09 13:00:42 +02:00
{/* <div className="panel-block">
<p className="control has-icons-left">
<input className="input" type="text" placeholder="Search" />
<span className="icon is-left">🔍</span>
2020-04-20 11:14:46 +02:00
</p>
2020-04-20 14:07:26 +02:00
</div> */}
{
projects.map(p => (
2020-07-09 13:00:42 +02:00
<a key={`project-${p.id}`} className="panel-block" href={`/p/${p.id}`}>
<span className="panel-icon">🗒</span>
2020-04-20 14:07:26 +02:00
{ p.label ? p.label : "Projet sans nom" }
</a>
))
}
{
projects.length === 0 ?
2020-07-09 13:00:42 +02:00
<p className="panel-block">
<div className={style.noProjects}>Aucun project pour l'instant.</div>
2020-04-20 14:07:26 +02:00
</p> :
null
}
2020-04-20 11:14:46 +02:00
</div>
</div>
</div>
</div>
);
};
export default Home;