website refactor
This commit is contained in:
@@ -11,20 +11,14 @@ import { PresentationError, mapToPresentationError } from '@/lib/contracts/page-
|
||||
* Server-side composition for admin users page.
|
||||
* Fetches user list from API and transforms to ViewData.
|
||||
*/
|
||||
export class AdminUsersPageQuery implements PageQuery<AdminUsersViewData, { search?: string; role?: string; status?: string; page?: number; limit?: number }> {
|
||||
async execute(query: { search?: string; role?: string; status?: string; page?: number; limit?: number }): Promise<Result<AdminUsersViewData, PresentationError>> {
|
||||
export class AdminUsersPageQuery implements PageQuery<AdminUsersViewData, void> {
|
||||
async execute(): Promise<Result<AdminUsersViewData, PresentationError>> {
|
||||
try {
|
||||
// Manual construction: Service creates its own dependencies
|
||||
const adminService = new AdminService();
|
||||
|
||||
// Fetch user list via service
|
||||
const apiDtoResult = await adminService.listUsers({
|
||||
search: query.search,
|
||||
role: query.role,
|
||||
status: query.status,
|
||||
page: query.page || 1,
|
||||
limit: query.limit || 50,
|
||||
});
|
||||
const apiDtoResult = await adminService.listUsers();
|
||||
|
||||
if (apiDtoResult.isErr()) {
|
||||
return Result.err(mapToPresentationError(apiDtoResult.getError()));
|
||||
@@ -46,8 +40,8 @@ export class AdminUsersPageQuery implements PageQuery<AdminUsersViewData, { sear
|
||||
}
|
||||
|
||||
// Static method to avoid object construction in server code
|
||||
static async execute(query: { search?: string; role?: string; status?: string; page?: number; limit?: number }): Promise<Result<AdminUsersViewData, PresentationError>> {
|
||||
static async execute(): Promise<Result<AdminUsersViewData, PresentationError>> {
|
||||
const queryInstance = new AdminUsersPageQuery();
|
||||
return queryInstance.execute(query);
|
||||
return queryInstance.execute();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user