Skip to content

Esta PR implementa la pantalla para editar datos generales. #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions mock-server/src/dals/expediente/expediente.repository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { paginateItems } from '#common/helpers/index.js';
import { CollectionQuery } from '#common/models/index.js';
import { db } from '#dals/mock.data.js';
import { ObjectId } from 'mongodb';
import * as model from './expediente.model.js';

export const expedienteRepository = {
Expand All @@ -13,4 +14,10 @@ export const expedienteRepository = {
totalPages: db.expedientes.length,
},
},

getExpedienteById: async (id: string): Promise<model.Expediente | null> => {
const objectId = new ObjectId(id);
const expediente = db.expedientes.find(e => e.id.equals(objectId));
return expediente ?? null;
},
};
16 changes: 15 additions & 1 deletion mock-server/src/pods/expediente/expediente.rest-api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import express from 'express';
import { expedienteRepository } from '#dals/expediente/expediente.repository.js';
import { mapExpedienteListFromModelToApi } from './expediente.mappers.js';
import { mapExpedienteFromModelToApi, mapExpedienteListFromModelToApi } from './expediente.mappers.js';

export const expedienteApi = express.Router();

expedienteApi.get('/:id', async (req, res, next) => {
try {
const { id } = req.params;
const expediente = await expedienteRepository.getExpedienteById(id);
if (!expediente) {
res.status(404).send({ message: 'Expediente no encontrado' });
return;
}
res.send(mapExpedienteFromModelToApi(expediente));
} catch (error) {
next(error);
}
});

expedienteApi.get('/', async (req, res, next) => {
try {
const page = Number(req.query.page);
Expand Down
Loading