Skip to content

Commit

Permalink
Avoid partial app + jsx -> js for domain and service
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Nov 8, 2023
1 parent 3fff8b8 commit 33edce7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import App from './App'
import { MailReader } from './components/MailReader'
import { MailsGrid } from './components/MailsGrid'
import { MailsSummary } from './components/MailsSummary'
import { mailService } from './service/mail'
import { mailService } from './service/mailService'

describe('smoke test de la app', () => {
test('la app levanta', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/MailReader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { InputText } from 'primereact/inputtext'
import { Panel } from 'primereact/panel'
import { useEffect, useState } from 'react'

import { mailService } from '../service/mail'
import { mailService } from '../service/mailService'
import { MailsGrid } from './MailsGrid'
import { MailsSummary } from './MailsSummary'

Expand Down
64 changes: 32 additions & 32 deletions src/components/MailsGrid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ import { DataTable } from 'primereact/datatable'
import { Mail } from '../domain/mail'
import PropTypes from 'prop-types'

const fechaTemplate = (mail) => {
return (
<span data-testid="fecha">{mail.fechaCorta}</span>
)
}

const marcarComoLeidoTemplate = (alLeerMail) => (mail) => {
return (
mail.leido ? '' : <Button type="button" data-testid={'btnMarcarLeido' + mail.id} icon="pi pi-check" className="p-button-secondary" title="Marcar como leído" onClick={() => alLeerMail(mail)}></Button>
)
}

const recienteTemplate = (mail) => {
return (
mail.esReciente() ?
<span title="Reciente" data-testid={'reciente' + mail.id} className="p-badge p-badge-info icon-badge" style={{ display: 'flex', alignItems: 'center', alignContent: 'center', justifyContent: 'center' }}>
<i className="pi pi-calendar"></i>
</span> : ''
)
}

const leidoTemplate = ({ id, leido }) => {
return (
leido ?
'' :
<span title="No leído" data-testid={'noLeido' + id} className="p-badge p-badge-warning icon-badge" style={{ display: 'flex', alignItems: 'center', alignContent: 'center', justifyContent: 'center' }}>
<i className="pi pi-eye"></i>
</span>
)
}

// Componente que sabe mostrar los mails en una tabla
export const MailsGrid = ({ mails, alLeerMail }) => {
const fechaTemplate = (mail) => {
return (
<span data-testid="fecha">{mail.fechaCorta}</span>
)
}

const marcarComoLeidoTemplate = (mail) => {
return (
mail.leido ? '' : <Button type="button" data-testid={'btnMarcarLeido' + mail.id} icon="pi pi-check" className="p-button-secondary" title="Marcar como leído" onClick={() => alLeerMail(mail)}></Button>
)
}

const recienteTemplate = (mail) => {
return (
mail.esReciente() ?
<span title="Reciente" data-testid={'reciente' + mail.id} className="p-badge p-badge-info icon-badge" style={{ display: 'flex', alignItems: 'center', alignContent: 'center', justifyContent: 'center' }}>
<i className="pi pi-calendar"></i>
</span> : ''
)
}

const leidoTemplate = ({ id, leido }) => {
return (
leido ?
'' :
<span title="No leído" data-testid={'noLeido' + id} className="p-badge p-badge-warning icon-badge" style={{ display: 'flex', alignItems: 'center', alignContent: 'center', justifyContent: 'center' }}>
<i className="pi pi-eye"></i>
</span>
)
}

return (
<DataTable value={mails} autoLayout={true} className="p-datatable-striped">
<Column header="Fecha" body={fechaTemplate} field="fechaOrdenamiento" sortable></Column>
Expand All @@ -45,7 +45,7 @@ export const MailsGrid = ({ mails, alLeerMail }) => {
<Column field="texto" header="Texto" sortable></Column>
<Column body={recienteTemplate} ></Column>
<Column body={leidoTemplate} ></Column>
<Column body={marcarComoLeidoTemplate(alLeerMail)} ></Column>
<Column body={marcarComoLeidoTemplate} ></Column>
</DataTable >
)
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { subDays } from "date-fns"
import { Mail } from "../domain/mail"
import { mailService } from "./mail"
import { mailService } from "./mailService"

describe('test del service', () => {

Expand Down

0 comments on commit 33edce7

Please sign in to comment.