From 9a398d6a7d3396c0ac563efe078808087a253534 Mon Sep 17 00:00:00 2001 From: Maria Adriana <97130795+mariadriana-deemaze@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:48:56 +0000 Subject: [PATCH] [SOA-43] User verified flag (#45) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat 🎸 (be): add verified flag to user * styles 💅 : add conditional verified badge to UI --- app/interfaces/user.ts | 1 + app/models/user.ts | 3 +++ app/services/user_notification_service.ts | 1 + app/services/user_service.ts | 1 + ...13498735_add_verified_flag_to_users_table.ts | 17 +++++++++++++++++ inertia/components/posts/post_card.tsx | 12 +++++++++--- inertia/pages/users/show.tsx | 11 +++++++---- 7 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 database/migrations/1732813498735_add_verified_flag_to_users_table.ts diff --git a/app/interfaces/user.ts b/app/interfaces/user.ts index 5a714d9..fed2b07 100644 --- a/app/interfaces/user.ts +++ b/app/interfaces/user.ts @@ -11,6 +11,7 @@ export interface UserResponse extends BaseEntity { fullname: string username: string email: string + verified: boolean attachments: { cover: AttachmentResponse | null avatar: AttachmentResponse | null diff --git a/app/models/user.ts b/app/models/user.ts index dd9571c..b0d7ebe 100644 --- a/app/models/user.ts +++ b/app/models/user.ts @@ -37,6 +37,9 @@ export default class User extends compose(BaseModel, AuthFinder, Notifiable('use @column() declare email: string + @column() + declare verified: boolean + @column() role: AccountRole = AccountRole.USER diff --git a/app/services/user_notification_service.ts b/app/services/user_notification_service.ts index c23e8bc..2bed510 100644 --- a/app/services/user_notification_service.ts +++ b/app/services/user_notification_service.ts @@ -20,6 +20,7 @@ export default class UserNotificationService { surname: null, fullname: 'Moderation team', email: 'info@social-adonis.com', + verified: true, createdAt: new Date().toISOString(), updatedAt: new Date().toISOString(), role: AccountRole.ADMIN, diff --git a/app/services/user_service.ts b/app/services/user_service.ts index 9c381f0..b30bbb8 100644 --- a/app/services/user_service.ts +++ b/app/services/user_service.ts @@ -150,6 +150,7 @@ export class UserService { const resource: UserResponse = { id: data.id, role: data.role, + verified: data.verified, name: data.name, surname: data.surname, fullname: data.fullName, diff --git a/database/migrations/1732813498735_add_verified_flag_to_users_table.ts b/database/migrations/1732813498735_add_verified_flag_to_users_table.ts new file mode 100644 index 0000000..2823bf5 --- /dev/null +++ b/database/migrations/1732813498735_add_verified_flag_to_users_table.ts @@ -0,0 +1,17 @@ +import { BaseSchema } from '@adonisjs/lucid/schema' + +export default class extends BaseSchema { + protected tableName = 'users' + + async up() { + this.schema.alterTable(this.tableName, (table) => { + table.boolean('verified').defaultTo(false) + }) + } + + async down() { + this.schema.alterTable(this.tableName, (table) => { + table.dropColumn('verified') + }) + } +} diff --git a/inertia/components/posts/post_card.tsx b/inertia/components/posts/post_card.tsx index c712ad7..8cacc47 100644 --- a/inertia/components/posts/post_card.tsx +++ b/inertia/components/posts/post_card.tsx @@ -11,6 +11,7 @@ import { Trash2, Flag, Pin, + BadgeCheck, } from 'lucide-react' import { Button } from '@/components/ui/button' import { @@ -493,9 +494,14 @@ export default function PostCard({
- @{post.user.username} -
++ @{post.user.username} +
+ {post.user.verified && ( ++
@{user.username}