DEV Community

Gerardo Andrés Ruiz Castillo
Gerardo Andrés Ruiz Castillo

Posted on • Originally published at geanruca.gitvlg.com

Enhancing Admin User Visibility with Plan Information in devlog-ist/landing

Introduction

This post details the addition of a 'plan' column to the admin users table in the devlog-ist/landing project. This enhancement provides administrators with a clear, at-a-glance view of each user's current subscription plan, derived from their tenant subscription status.

The Problem: Lack of Immediate Plan Visibility

Previously, administrators had to navigate through multiple sections or run separate queries to determine a user's current plan (e.g., corporate, lifetime, annual, monthly, free). This process was inefficient and time-consuming, especially when managing a large user base.

The Solution: Adding a 'Plan' Column

The solution involves adding a new 'plan' column to the admin users table. This column displays a colored badge representing the user's plan, which is dynamically resolved from their tenant subscription status. This provides immediate visibility and simplifies user management.

Implementation Details

The implementation likely involves modifying the user model or a related data retrieval process to include the plan information. The plan status is resolved based on the user's tenant subscription. A colored badge is then generated based on the plan type. For example:

function getUserPlan(User $user): string {
    $subscription = $user->tenant->subscription;

    if ($subscription->isCorporate()) {
        return '<span class="badge bg-corporate">Corporate</span>';
    } elseif ($subscription->isLifetime()) {
        return '<span class="badge bg-lifetime">Lifetime</span>';
    } else {
        return '<span class="badge bg-default">Free</span>';
    }
}
Enter fullscreen mode Exit fullscreen mode

This code snippet illustrates how the user's plan might be determined based on their subscription status and then rendered as an HTML badge. The actual implementation would vary based on the project's specific architecture and frameworks.

Benefits

The addition of the 'plan' column offers several benefits:

  • Improved Efficiency: Administrators can quickly identify user plans without navigating through multiple sections.
  • Enhanced Clarity: The colored badges provide a visual representation of the plan, making it easy to differentiate between different subscription levels.
  • Simplified User Management: The at-a-glance view simplifies various user management tasks, such as assigning permissions or providing support.

Top comments (0)