projects.js 1.9 KB

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