DEV Community

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

Posted on • Originally published at geanruca.gitvlg.com

Enhancing Tenant Management in devlog-ist/landing with Plan Visibility

This post details the addition of a 'plan' column to the admin tenants table in the devlog-ist/landing project, improving tenant management and visibility.

The Need for Plan Visibility

The original tenant management interface lacked a clear, immediate indicator of each tenant's current plan. This required administrators to navigate to separate sections or run custom queries to determine the plan associated with each tenant, creating unnecessary overhead.

Implementation: Adding the 'Plan' Column

The solution involved modifying the admin tenants table to include a 'plan' column. This column displays each tenant's current plan using a colored badge, mirroring the style already in use within the users table. This ensures visual consistency and ease of recognition.

To implement this, the table rendering logic was updated to fetch the plan information for each tenant. A mapping was created between plan types and corresponding badge colors. This mapping is used to dynamically generate the appropriate badge style for each tenant's plan.

Example of badge generation:

function getPlanBadge(string $plan):
string {
    $colorMap = [
        'basic' => 'gray',
        'premium' => 'green',
        'enterprise' => 'purple',
    ];
    $color = $colorMap[$plan] ?? 'blue';
    return "<span class='badge text-bg-{$color}'>{$plan}</span>";
}
Enter fullscreen mode Exit fullscreen mode

This function takes a plan name as input and returns an HTML span element representing a colored badge. The color is determined by a predefined $colorMap. If the plan is not found in the map, a default color ('blue') is used.

Benefits and Impact

Adding the 'plan' column provides several key benefits:

  • Improved Visibility: Administrators can now see each tenant's plan at a glance, without needing to navigate to other sections.
  • Enhanced Efficiency: Streamlines tenant management workflows, reducing the time required to identify and manage tenants based on their plans.
  • Consistent UI: Maintains a consistent user interface by using the same badge style as the users table.

Conclusion

By adding a 'plan' column with colored badges to the admin tenants table, the devlog-ist/landing project has significantly improved the usability and efficiency of its tenant management interface. This simple addition provides immediate value by increasing visibility and reducing administrative overhead.

Top comments (0)