Inicio.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import React from "react";
  2. import { useAuth } from "../../hooks";
  3. import { Row, Card, List } from "antd";
  4. import { useHistory } from "react-router-dom";
  5. import { ViewLoading } from "../../components";
  6. import { DefaultLayout } from "../../components/layouts";
  7. const Inicio = () => {
  8. const history = useHistory();
  9. const { user } = useAuth();
  10. const cardsAdmin = [
  11. {
  12. id: 0,
  13. titulo: "Eventos",
  14. img: "/assets/eventos.png",
  15. path: "/administracion/eventos",
  16. },
  17. {
  18. id: 1,
  19. titulo: "Usuarios",
  20. img: "/assets/usuarios.png",
  21. path: "/administracion/usuarios",
  22. },
  23. {
  24. id: 2,
  25. titulo: "Grupos",
  26. img: "/assets/grupos.png",
  27. path: "/administracion/grupos",
  28. },
  29. {
  30. id: 3,
  31. titulo: "Reportes",
  32. img: "/assets/reportes.png",
  33. path: "/administracion/reportes",
  34. },
  35. ];
  36. const cardsCliente = [
  37. {
  38. id: 0,
  39. titulo: "Editar perfil",
  40. img: "/assets/profile.png",
  41. path: "/perfil",
  42. },
  43. ];
  44. const ViewAdmin = () => {
  45. return (
  46. <List
  47. grid={{
  48. gutter: 16,
  49. column: 6,
  50. }}
  51. dataSource={cardsAdmin}
  52. renderItem={(item) => (
  53. <List.Item>
  54. <Card
  55. onClick={ () => history.push(item.path) }
  56. title={item.titulo}
  57. style={{ textAlign: "center", cursor: 'pointer' }}
  58. >
  59. <img
  60. alt={item.titulo}
  61. src={item?.img}
  62. width="100%"
  63. />
  64. </Card>
  65. </List.Item>
  66. )}
  67. />
  68. );
  69. };
  70. const ViewCliente = () => {
  71. return (
  72. <List
  73. grid={{
  74. gutter: 10,
  75. column: 3,
  76. }}
  77. dataSource={cardsCliente}
  78. renderItem={(item) => (
  79. <List.Item>
  80. <Card
  81. onClick={ () => history.push(item.path) }
  82. title={item.titulo}
  83. style={{ textAlign: "center", cursor: 'pointer' }}
  84. >
  85. <img
  86. alt={item.titulo}
  87. src={item?.img}
  88. width="100%"
  89. />
  90. </Card>
  91. </List.Item>
  92. )}
  93. />
  94. );
  95. };
  96. if (!user) return <ViewLoading />;
  97. return (
  98. <DefaultLayout className="site-card-wrapper">
  99. <Row gutter={10}>
  100. {user?.rol === "admin" ? <ViewAdmin /> : <ViewCliente />}
  101. </Row>
  102. </DefaultLayout>
  103. );
  104. };
  105. export default Inicio;