Skip to content

Commit

Permalink
fix: Applied suggestions from review
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreSoftwareDeveloper committed Jun 12, 2024
1 parent f7ad02c commit 9156eb3
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
46 changes: 46 additions & 0 deletions backend/src/plugins/core/admin/members/edit/dto/edit.obj.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ObjectType, Field, Int } from "@nestjs/graphql";

@ObjectType()
export class EditAdminMembersObj {
@Field(() => Int)
id: number;

@Field(() => String)
name_seo: string;

@Field(() => String)
name: string;

@Field(() => String)
email: string;

@Field(() => String)
password: string;

@Field(() => Date)
joined: Date;

@Field(() => Int)
posts: number;

@Field(() => Boolean)
newsletter: boolean;

@Field(() => String)
avatar_color: string;

@Field(() => Int)
group_id: number;

@Field(() => String)
first_name: string;

@Field(() => String)
last_name: string;

@Field(() => Date)
birthday: Date;

@Field(() => String)
ip_address: string;
}
11 changes: 6 additions & 5 deletions backend/src/plugins/core/admin/members/edit/edit.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Injectable } from "@nestjs/common";
import { eq } from "drizzle-orm";
import { eq, return } from "drizzle-orm";

import { EditAdminMembersArgs } from "./dto/edit.args";

import { core_users } from "@/plugins/core/admin/database/schema/users";
import { DatabaseService } from "@/database/database.service";
import { NotFoundError } from "@/utils/errors/not-found-error";
import { AccessDeniedError } from "@/utils/errors/access-denied-error";
import { EditAdminMembersObj } from "./dto/edit.obj";

@Injectable()
export class EditAdminMembersService {
Expand All @@ -20,7 +21,7 @@ export class EditAdminMembersService {
first_name,
last_name,
birthday
}: EditAdminMembersArgs): Promise<string> {
}: EditAdminMembersArgs): Promise<EditAdminMembersObj> {
const user = await this.databaseService.db.query.core_users.findFirst({
where: eq(core_users.id, id)
});
Expand All @@ -35,7 +36,7 @@ export class EditAdminMembersService {

if (!admin) throw new AccessDeniedError();

await this.databaseService.db
const update = await this.databaseService.db
.update(core_users)
.set({
name: name,
Expand All @@ -45,8 +46,8 @@ export class EditAdminMembersService {
last_name: last_name,
birthday: birthday
})
.where(eq(core_users.id, id));
.where(eq(core_users.id, id)).returning();

return "Success!";
return update[0];
}
}

0 comments on commit 9156eb3

Please sign in to comment.