projects.js 1.6 KB

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