projects.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { connect } from "react-redux";
  2. import { Link } from "react-router-dom";
  3. const Projects = ({snippets}) => {
  4. return snippets ? (
  5. <div>
  6. <Link to="/">
  7. <button className="float-left btn-secondary d-inline-block mt-2 ml-2">
  8. <span>&#8617;</span>Back to Main Page
  9. </button>
  10. </Link>
  11. <br/>
  12. <br/>
  13. <div style={{alignItems: "center", textAlign: "center"}}>
  14. <Link to="/">
  15. <button className="btn btn-success">New project</button>
  16. </Link>
  17. </div>
  18. {snippets?.map((key, index) => (
  19. <div style={{textAlign: "center", alignItems: "center"}}>
  20. <div className="card w-50 ml-auto mr-auto mt-3 mb-5" style = {{boxShadow:'0px 5px 10px 2px rgba(34, 60, 80, 0.2)'}}>
  21. <div className="card-body" style={{textAlign: "center"}}>
  22. <h3 className="card-title mb-4 text-info">
  23. {snippets?.[index]?.title || "Project without name"}
  24. </h3>
  25. <p className="card-text">
  26. <span className="text-muted">Description</span>&nbsp;
  27. {snippets?.[index]?.description || ""}
  28. </p>
  29. <Link to={"/project/" + snippets?.[index]?._id}>
  30. <button className="btn btn-primary mt-3">Open project</button>
  31. </Link>
  32. </div>
  33. </div>
  34. </div>
  35. ))}
  36. </div>
  37. ) : (
  38. <div>
  39. <Link to="/">
  40. <button className="float-left btn-secondary d-inline-block mt-2 ml-2">
  41. <span>&#8617;</span>Back to Main Page
  42. </button>
  43. </Link>
  44. <br /> <br />
  45. <div className="d-flex justify-content-center">
  46. <div className="spinner-border mt-3" style={{width: "10rem", height: "10rem"}} role="status">
  47. <span className="sr-only">Loading...</span>
  48. </div>
  49. </div>
  50. </div>
  51. );
  52. };
  53. const CProjects = connect((state) => ({snippets: state?.promise?.findSnippet?.payload?.data?.SnippetFind,}))(Projects);
  54. export default CProjects;