-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
142 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { formatearFecha } from "../helpers" | ||
|
||
import IconoAhorro from '../img/icono_ahorro.svg' | ||
import IconoCasa from '../img/icono_casa.svg' | ||
import IconoComida from '../img/icono_comida.svg' | ||
import IconoGastos from '../img/icono_gastos.svg' | ||
import IconoOcio from '../img/icono_ocio.svg' | ||
import IconoSalud from '../img/icono_salud.svg' | ||
import IconoSuscripciones from '../img/icono_suscripciones.svg' | ||
|
||
const diccionarioIconos = { | ||
ahorro: IconoAhorro, | ||
comida: IconoComida, | ||
casa: IconoCasa, | ||
gastos: IconoGastos, | ||
ocio: IconoOcio, | ||
salud: IconoSalud, | ||
suscripciones: IconoSuscripciones | ||
} | ||
|
||
const Gasto = ({ gasto }) => { | ||
return ( | ||
<div className="gasto sombra"> | ||
<div className="contenido-gasto"> | ||
<img | ||
src={diccionarioIconos[gasto.categoria]} | ||
alt="Icono gasto" | ||
/> | ||
<div className="descripcion-gasto"> | ||
<p className="categoria">{gasto.categoria}</p> | ||
<p className="nombre-gasto">{gasto.nombre}</p> | ||
<p className="fecha-gasto"> | ||
Agreado el: {""} | ||
<span>{formatearFecha(gasto.fecha)}</span> | ||
</p> | ||
</div> | ||
</div> | ||
<p className="cantidad-gasto">${gasto.cantidad}</p> | ||
</div> | ||
) | ||
} | ||
|
||
export default Gasto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Gasto from "./Gasto" | ||
|
||
const ListadoGastos = ({ gastos }) => { | ||
return ( | ||
<div className="listado-gastos contenedor"> | ||
<h2>{gastos.length ? 'Gastos' : 'No hay gastos aún'}</h2> | ||
|
||
{gastos.map( gasto => ( | ||
<Gasto | ||
key={gasto.id} | ||
gasto={gasto} | ||
/> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default ListadoGastos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const generarId = () => { | ||
const random = Math.random().toString(36).substr(2) | ||
const fecha = Date.now().toString(36) | ||
return random + fecha | ||
} | ||
|
||
export const formatearFecha = (fecha) => { | ||
const fechaNueva = new Date(fecha); | ||
const opciones = { | ||
year: 'numeric', | ||
month: 'long', | ||
day: '2-digit' | ||
} | ||
|
||
return fechaNueva.toLocaleDateString('es-ES', opciones); | ||
} |