.
This commit is contained in:
parent
738da90b23
commit
7293385550
@ -58,8 +58,14 @@ export const QuoteDetailsCardEditor = ({
|
|||||||
id: "description" as const,
|
id: "description" as const,
|
||||||
accessorKey: "description",
|
accessorKey: "description",
|
||||||
header: t("quotes.form_fields.items.description.label"),
|
header: t("quotes.form_fields.items.description.label"),
|
||||||
cell: ({ row: { index } }) => {
|
cell: ({ row: { index, original } }) => {
|
||||||
return <FormTextAreaField autoSize {...register(`items.${index}.description`)} />;
|
return (
|
||||||
|
<FormTextAreaField
|
||||||
|
readOnly={original?.id_article}
|
||||||
|
autoSize
|
||||||
|
{...register(`items.${index}.description`)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
size: 500,
|
size: 500,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,18 +1,10 @@
|
|||||||
import {
|
import { IUseCase, IUseCaseError, UseCaseError } from "@/contexts/common/application/useCases";
|
||||||
IUseCase,
|
|
||||||
IUseCaseError,
|
|
||||||
UseCaseError,
|
|
||||||
} from "@/contexts/common/application/useCases";
|
|
||||||
import { IRepositoryManager } from "@/contexts/common/domain";
|
import { IRepositoryManager } from "@/contexts/common/domain";
|
||||||
import {
|
import { Collection, ICollection, IQueryCriteria, Result } from "@shared/contexts";
|
||||||
Collection,
|
|
||||||
ICollection,
|
|
||||||
IQueryCriteria,
|
|
||||||
Result,
|
|
||||||
} from "@shared/contexts";
|
|
||||||
|
|
||||||
import { IInfrastructureError } from "@/contexts/common/infrastructure";
|
import { IInfrastructureError } from "@/contexts/common/infrastructure";
|
||||||
import { ISequelizeAdapter } from "@/contexts/common/infrastructure/sequelize";
|
import { ISequelizeAdapter } from "@/contexts/common/infrastructure/sequelize";
|
||||||
|
import { logger } from "@/infrastructure/logger";
|
||||||
import { Article, ICatalogRepository } from "../domain";
|
import { Article, ICatalogRepository } from "../domain";
|
||||||
|
|
||||||
export interface IListArticlesParams {
|
export interface IListArticlesParams {
|
||||||
@ -29,10 +21,7 @@ export class ListArticlesUseCase
|
|||||||
private _adapter: ISequelizeAdapter;
|
private _adapter: ISequelizeAdapter;
|
||||||
private _repositoryManager: IRepositoryManager;
|
private _repositoryManager: IRepositoryManager;
|
||||||
|
|
||||||
constructor(props: {
|
constructor(props: { adapter: ISequelizeAdapter; repositoryManager: IRepositoryManager }) {
|
||||||
adapter: ISequelizeAdapter;
|
|
||||||
repositoryManager: IRepositoryManager;
|
|
||||||
}) {
|
|
||||||
this._adapter = props.adapter;
|
this._adapter = props.adapter;
|
||||||
this._repositoryManager = props.repositoryManager;
|
this._repositoryManager = props.repositoryManager;
|
||||||
}
|
}
|
||||||
@ -41,9 +30,7 @@ export class ListArticlesUseCase
|
|||||||
return this._repositoryManager.getRepository<T>(name);
|
return this._repositoryManager.getRepository<T>(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(
|
async execute(params: Partial<IListArticlesParams>): Promise<ListArticlesResult> {
|
||||||
params: Partial<IListArticlesParams>,
|
|
||||||
): Promise<ListArticlesResult> {
|
|
||||||
const { queryCriteria } = params;
|
const { queryCriteria } = params;
|
||||||
|
|
||||||
return this.findArticles(queryCriteria);
|
return this.findArticles(queryCriteria);
|
||||||
@ -51,26 +38,20 @@ export class ListArticlesUseCase
|
|||||||
|
|
||||||
private async findArticles(queryCriteria) {
|
private async findArticles(queryCriteria) {
|
||||||
const transaction = this._adapter.startTransaction();
|
const transaction = this._adapter.startTransaction();
|
||||||
const productRepoBuilder =
|
const productRepoBuilder = this.getRepositoryByName<ICatalogRepository>("Article");
|
||||||
this.getRepositoryByName<ICatalogRepository>("Article");
|
|
||||||
|
|
||||||
let products: ICollection<Article> = new Collection();
|
let products: ICollection<Article> = new Collection();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await transaction.complete(async (t) => {
|
await transaction.complete(async (t) => {
|
||||||
products = await productRepoBuilder({ transaction: t }).findAll(
|
products = await productRepoBuilder({ transaction: t }).findAll(queryCriteria);
|
||||||
queryCriteria,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return Result.ok(products);
|
return Result.ok(products);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const _error = error as IInfrastructureError;
|
const _error = error as IInfrastructureError;
|
||||||
|
logger().error(_error);
|
||||||
return Result.fail(
|
return Result.fail(
|
||||||
UseCaseError.create(
|
UseCaseError.create(UseCaseError.REPOSITORY_ERROR, "Error al listar el catálogo", _error)
|
||||||
UseCaseError.REPOSITORY_ERROR,
|
|
||||||
"Error al listar el catálogo",
|
|
||||||
_error,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,6 @@
|
|||||||
import {
|
import { IUseCase, IUseCaseError, UseCaseError } from "@/contexts/common/application/useCases";
|
||||||
IUseCase,
|
|
||||||
IUseCaseError,
|
|
||||||
UseCaseError,
|
|
||||||
} from "@/contexts/common/application/useCases";
|
|
||||||
import { IRepositoryManager } from "@/contexts/common/domain";
|
import { IRepositoryManager } from "@/contexts/common/domain";
|
||||||
import {
|
import { Collection, ICollection, IQueryCriteria, Result } from "@shared/contexts";
|
||||||
Collection,
|
|
||||||
ICollection,
|
|
||||||
IQueryCriteria,
|
|
||||||
Result,
|
|
||||||
} from "@shared/contexts";
|
|
||||||
|
|
||||||
import { IInfrastructureError } from "@/contexts/common/infrastructure";
|
import { IInfrastructureError } from "@/contexts/common/infrastructure";
|
||||||
import { ISequelizeAdapter } from "@/contexts/common/infrastructure/sequelize";
|
import { ISequelizeAdapter } from "@/contexts/common/infrastructure/sequelize";
|
||||||
@ -24,16 +15,11 @@ export type ListUsersResult =
|
|||||||
| Result<never, IUseCaseError> // Misc errors (value objects)
|
| Result<never, IUseCaseError> // Misc errors (value objects)
|
||||||
| Result<ICollection<User>, never>; // Success!
|
| Result<ICollection<User>, never>; // Success!
|
||||||
|
|
||||||
export class ListUsersUseCase
|
export class ListUsersUseCase implements IUseCase<IListUsersParams, Promise<ListUsersResult>> {
|
||||||
implements IUseCase<IListUsersParams, Promise<ListUsersResult>>
|
|
||||||
{
|
|
||||||
private _adapter: ISequelizeAdapter;
|
private _adapter: ISequelizeAdapter;
|
||||||
private _repositoryManager: IRepositoryManager;
|
private _repositoryManager: IRepositoryManager;
|
||||||
|
|
||||||
constructor(props: {
|
constructor(props: { adapter: ISequelizeAdapter; repositoryManager: IRepositoryManager }) {
|
||||||
adapter: ISequelizeAdapter;
|
|
||||||
repositoryManager: IRepositoryManager;
|
|
||||||
}) {
|
|
||||||
this._adapter = props.adapter;
|
this._adapter = props.adapter;
|
||||||
this._repositoryManager = props.repositoryManager;
|
this._repositoryManager = props.repositoryManager;
|
||||||
}
|
}
|
||||||
@ -56,19 +42,13 @@ export class ListUsersUseCase
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await transaction.complete(async (t) => {
|
await transaction.complete(async (t) => {
|
||||||
users = await userRepoBuilder({ transaction: t }).findAll(
|
users = await userRepoBuilder({ transaction: t }).findAll(queryCriteria);
|
||||||
queryCriteria,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
return Result.ok(users);
|
return Result.ok(users);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
const _error = error as IInfrastructureError;
|
const _error = error as IInfrastructureError;
|
||||||
return Result.fail(
|
return Result.fail(
|
||||||
UseCaseError.create(
|
UseCaseError.create(UseCaseError.REPOSITORY_ERROR, "Error al listar los usuarios", _error)
|
||||||
UseCaseError.REPOSITORY_ERROR,
|
|
||||||
"Error al listar los usurios",
|
|
||||||
_error,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
import rTracer from "cls-rtracer";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { createLogger, format, transports } from "winston";
|
import { createLogger, format, transports } from "winston";
|
||||||
import DailyRotateFile from "winston-daily-rotate-file";
|
import DailyRotateFile from "winston-daily-rotate-file";
|
||||||
@ -85,3 +86,7 @@ function initLogger(rTracer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export { initLogger };
|
export { initLogger };
|
||||||
|
|
||||||
|
export const logger = () => {
|
||||||
|
return initLogger(rTracer);
|
||||||
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user