Skip to content

Commit e8f9f19

Browse files
authored
Merge pull request #59 from Lemoncode/feature/#49-layout-editar-expediente
Feature/#49 layout editar expediente
2 parents f8f361a + 5ef71bd commit e8f9f19

14 files changed

+261
-5
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { Typography } from '@mui/material';
3+
import { TextFieldForm } from '#common/components';
4+
import { useWithTheme } from '#core/theme';
5+
import { MontosIvaForm } from './montos-iva-form.component';
6+
import * as innerClasses from './adjudicacion-form.styles';
7+
8+
export const AdjudicacionForm: React.FC = () => {
9+
const classes = useWithTheme(innerClasses);
10+
11+
return (
12+
<section>
13+
<Typography variant="h6">Adjudicación</Typography>
14+
<MontosIvaForm prefix="adj" />
15+
<div className={classes.adjudicatarioContainer}>
16+
<TextFieldForm name="adjudicatario" label="Adjudicatario" />
17+
<TextFieldForm name="cif" label="CIF" />
18+
</div>
19+
</section>
20+
);
21+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Theme } from '@mui/material';
2+
import { css } from '@emotion/css';
3+
4+
export const adjudicatarioContainer = (theme: Theme) => css`
5+
display: flex;
6+
gap: ${theme.spacing(2)};
7+
8+
@media (max-width: 768px) {
9+
flex-direction: column;
10+
}
11+
`;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './montos-iva-form.component';
2+
export * from './adjudicacion-form.component';
3+
export * from './presupuesto-base-form.component';
4+
export * from './listado-anualidad.component';
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from 'react';
2+
import { Button, Card, CardContent, IconButton, Typography } from '@mui/material';
3+
import DeleteIcon from '@mui/icons-material/Delete';
4+
import FolderIcon from '@mui/icons-material/Folder';
5+
import { useWithTheme } from '#core/theme';
6+
import { Anualidad } from '../editar-expediente.vm';
7+
import * as innerClasses from './listado-anualidad.styles';
8+
9+
const AnualidadItem: React.FC<Anualidad> = ({ ano: year, monto: amount, iva, simbolo: symbol }) => {
10+
const classes = useWithTheme(innerClasses);
11+
12+
return (
13+
<div className={classes.ListItemContainer}>
14+
<span>{year}</span>
15+
<span>{`${amount.toLocaleString()}${symbol}`}</span>
16+
<span>{`${iva.toLocaleString()}${symbol}`}</span>
17+
<IconButton>
18+
<DeleteIcon />
19+
</IconButton>
20+
</div>
21+
);
22+
};
23+
24+
interface Props {
25+
rows: Anualidad[];
26+
}
27+
28+
export const ListadoAnualidad: React.FC<Props> = props => {
29+
const { rows } = props;
30+
const classes = useWithTheme(innerClasses);
31+
return (
32+
<Card sx={{ mt: 2 }}>
33+
<CardContent>
34+
<div className={classes.tableHeader}>
35+
<Typography variant="caption" fontWeight="bold">
36+
Anualidades
37+
</Typography>
38+
<Button variant="outlined" className={classes.newButton}>
39+
<FolderIcon />
40+
<span>Nueva</span>
41+
</Button>
42+
</div>
43+
44+
<div className={classes.TableBody}>
45+
<Typography variant="caption" fontWeight={'bold'}>
46+
Ejercicio
47+
</Typography>
48+
</div>
49+
{rows.map(row => (
50+
<AnualidadItem key={row.id} {...row} />
51+
))}
52+
</CardContent>
53+
</Card>
54+
);
55+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Theme } from '@mui/material';
2+
import { css } from '@emotion/css';
3+
4+
export const tableHeader = (theme: Theme) => css`
5+
display: flex;
6+
justify-content: space-between;
7+
align-items: center;
8+
margin-bottom: ${theme.spacing(2)};
9+
10+
@media (max-width: 768px) {
11+
flex-direction: column;
12+
}
13+
`;
14+
15+
export const newButton = (theme: Theme) => css`
16+
display: flex;
17+
gap: ${theme.spacing(1)};
18+
`;
19+
20+
export const ListItemContainer = (theme: Theme) => css`
21+
display: flex;
22+
justify-content: space-between;
23+
align-items: center;
24+
padding-bottom: ${theme.spacing(1)};
25+
padding-top: ${theme.spacing(1)};
26+
border-bottom: 1px solid #ddd;
27+
`;
28+
29+
export const TableBody = css`
30+
padding-bottom: 8px;
31+
border-bottom: 1px solid #ddd;
32+
`;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import { TextFieldForm } from '#common/components';
3+
import { useWithTheme } from '#core/theme';
4+
import * as innerClasses from './montos-iva-form.styles';
5+
6+
export const MontosIvaForm: React.FC<{ prefix: string }> = ({ prefix }) => {
7+
const classes = useWithTheme(innerClasses);
8+
return (
9+
<section className={classes.container}>
10+
<TextFieldForm name={`${prefix}-importe-sin-iva`} label="Importe sin IVA" />
11+
<TextFieldForm name={`${prefix}-iva`} label="% IVA" value={21} disabled />
12+
<TextFieldForm name={`${prefix}-importe-iva`} label="Importe IVA" />
13+
<TextFieldForm name={`${prefix}-importe-con-iva`} label="Importe con IVA" />
14+
</section>
15+
);
16+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Theme } from '@mui/material';
2+
import { css } from '@emotion/css';
3+
4+
export const container = (theme: Theme) => css`
5+
display: grid;
6+
grid-template-columns: repeat(4, 1fr);
7+
gap: ${theme.spacing(2)};
8+
9+
@media (max-width: 768px) {
10+
grid-template-columns: 1fr;
11+
}
12+
`;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import { Typography } from '@mui/material';
3+
import { ListadoAnualidad } from './listado-anualidad.component';
4+
import { MontosIvaForm } from './montos-iva-form.component';
5+
import { Anualidad } from '../editar-expediente.vm';
6+
7+
export const PresupuestoBaseForm: React.FC<{ rows: Anualidad[] }> = props => {
8+
const { rows } = props;
9+
10+
return (
11+
<section>
12+
<Typography variant="h6">Presupuesto base</Typography>
13+
<MontosIvaForm prefix="base" />
14+
<ListadoAnualidad rows={rows} />
15+
</section>
16+
);
17+
};
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import React from 'react';
2+
import { Anualidad } from './editar-expediente.vm';
3+
import { EditarInformacionFinanciera } from './editar-informacion-financiera.component';
24

35
export const EditarDatosEconomicosPod: React.FC = () => {
4-
return <h2>Datos Económicos</h2>;
6+
// TODO: quitar luego de su implementacion
7+
const listadoAnualidades: Anualidad[] = [
8+
{ ano: 2022, monto: 1234, iva: 1111, id: 1, simbolo: '€' },
9+
{ ano: 2023, monto: 5678, iva: 2222, id: 2, simbolo: '€' },
10+
{ ano: 2024, monto: 9123, iva: 3333, id: 3, simbolo: '€' },
11+
];
12+
return <EditarInformacionFinanciera onSubmit={() => {}} listadoAnualidades={listadoAnualidades} />;
513
};

src/modules/expedientes/editar-datos-economicos/editar-expediente.type.ts

Whitespace-only changes.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export interface Expediente {
2+
id: number;
3+
}
4+
5+
export interface Anualidad {
6+
id: number;
7+
ano: number;
8+
monto: number;
9+
iva: number;
10+
simbolo: string;
11+
}
12+
13+
export const createEmptyExpediente = (): Expediente => ({ id: 0 });
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React from 'react';
2+
import { Button } from '@mui/material';
3+
import { Form, Formik } from 'formik';
4+
import { NavigationButton } from '#common/components';
5+
import { useWithTheme } from '#core/theme';
6+
import { AdjudicacionForm, PresupuestoBaseForm } from './components';
7+
import { Anualidad, Expediente, createEmptyExpediente } from './editar-expediente.vm';
8+
import * as innerClasses from './editar-informacion-financiera.styles';
9+
10+
interface Props {
11+
onSubmit: (values: Expediente) => void;
12+
listadoAnualidades: Anualidad[];
13+
}
14+
15+
export const EditarInformacionFinanciera: React.FC<Props> = props => {
16+
const { onSubmit, listadoAnualidades } = props;
17+
const classes = useWithTheme(innerClasses);
18+
19+
return (
20+
<section className={classes.root}>
21+
<Formik initialValues={createEmptyExpediente()} enableReinitialize={true} onSubmit={onSubmit}>
22+
<Form className={classes.form}>
23+
<PresupuestoBaseForm rows={listadoAnualidades} />
24+
<AdjudicacionForm />
25+
<section className={classes.buttonContainer}>
26+
<NavigationButton path="/expedientes" text="Volver" variant="text" />
27+
<Button type="submit" variant="contained">
28+
Guardar
29+
</Button>
30+
</section>
31+
</Form>
32+
</Formik>
33+
</section>
34+
);
35+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Theme } from '@mui/material';
2+
import { css } from '@emotion/css';
3+
4+
export const root = (theme: Theme) => css`
5+
width: 100%;
6+
display: flex;
7+
flex-direction: column;
8+
gap: ${theme.spacing(4)};
9+
`;
10+
11+
export const form = (theme: Theme) => css`
12+
display: grid;
13+
grid-template-columns: repeat(2, 1fr);
14+
gap: ${theme.spacing(4)};
15+
@media (max-width: 768px) {
16+
grid-template-columns: 1fr;
17+
}
18+
`;
19+
20+
export const buttonContainer = (theme: Theme) => css`
21+
grid-column: 1 / 3;
22+
display: flex;
23+
justify-content: flex-end;
24+
gap: ${theme.spacing(4)};
25+
26+
@media (max-width: 768px) {
27+
grid-column: 1 / 2;
28+
place-self: center;
29+
}
30+
`;

src/modules/expedientes/list/expedientes.columns.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import * as innerClasses from './expedientes.styles';
2+
3+
import { Box, Chip } from '@mui/material';
4+
import { Delete as DeleteIcon, Edit as EditIcon, Visibility as VisibilityIcon } from '@mui/icons-material';
5+
16
import { ColumnDef } from '@tanstack/react-table';
7+
import { Expediente } from './expedientes.vm';
28
import { Link } from '@tanstack/react-router';
3-
import { Chip, Box } from '@mui/material';
4-
import { Edit as EditIcon, Delete as DeleteIcon, Visibility as VisibilityIcon } from '@mui/icons-material';
59
import { useWithTheme } from '#core/theme';
6-
import { Expediente } from './expedientes.vm';
7-
import * as innerClasses from './expedientes.styles';
810

911
export const useColumns = (): ColumnDef<Expediente>[] => {
1012
const classes = useWithTheme(innerClasses);

0 commit comments

Comments
 (0)