Enhance user management and billing integration
- Updated the `UserSummaryDto` to include `BillingEnabled` and `BillingPaidUntil` properties, allowing for better tracking of user billing status. - Refactored the `IdentityService` to populate the new billing fields when retrieving user summaries. - Modified the dashboard and admin user management components to display billing information, including a link to the billing page and a badge for billing status. - Added internationalization support for new billing-related labels in both English and Russian. - Ensured frontend components reflect the updated user data structure, enhancing user experience with billing visibility.
This commit is contained in:
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { Input } from '@/shared/ui/input'
|
||||
import { Button } from '@/shared/ui/button'
|
||||
import { Badge } from '@/shared/ui/badge'
|
||||
import { PaidUntilBadge } from '@/features/billing/PaidUntilBadge'
|
||||
import { listUsers } from '@/features/admin/users/api'
|
||||
import { UserManageDialog } from '@/features/admin/users/UserManageDialog'
|
||||
import type { UserSummaryDto } from '@/shared/api/types'
|
||||
@@ -56,6 +57,7 @@ function AdminUsersPage() {
|
||||
<th className="py-2 font-medium">{t('admin.users.userName')}</th>
|
||||
<th className="py-2 font-medium">{t('admin.users.role')}</th>
|
||||
<th className="py-2 font-medium">{t('admin.users.statusLabel')}</th>
|
||||
<th className="py-2 font-medium">{t('admin.users.billingLabel')}</th>
|
||||
<th className="py-2" />
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -73,6 +75,13 @@ function AdminUsersPage() {
|
||||
: t('admin.users.status.pending')}
|
||||
</Badge>
|
||||
</td>
|
||||
<td className="py-2">
|
||||
{user.billingEnabled ? (
|
||||
<PaidUntilBadge paidUntil={user.billingPaidUntil} />
|
||||
) : (
|
||||
<span className="text-muted-foreground">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="py-2 text-right">
|
||||
<Button size="sm" variant="outline" onClick={() => setManaging(user)}>
|
||||
{t('admin.users.manage')}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { createFileRoute, Link } from '@tanstack/react-router'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useRequireAuth } from '@/features/auth/guards'
|
||||
@@ -6,6 +6,8 @@ import { ActivationGate } from '@/features/activation/ActivationGate'
|
||||
import { ConfigCard } from '@/features/configs/ConfigCard'
|
||||
import { CreateConfigDialog } from '@/features/configs/CreateConfigDialog'
|
||||
import { SubscriptionCard } from '@/features/configs/SubscriptionCard'
|
||||
import { PaidUntilBadge } from '@/features/billing/PaidUntilBadge'
|
||||
import { getMyBillingStatus } from '@/features/billing/api'
|
||||
import { getMyConfigs, listAvailableInbounds } from '@/features/configs/api'
|
||||
|
||||
export const Route = createFileRoute('/dashboard')({ component: DashboardPage })
|
||||
@@ -26,6 +28,7 @@ function ConfigsList() {
|
||||
const { t } = useTranslation()
|
||||
const { data, isLoading } = useQuery({ queryKey: ['my-configs'], queryFn: getMyConfigs })
|
||||
const inboundsQuery = useQuery({ queryKey: ['available-inbounds'], queryFn: listAvailableInbounds })
|
||||
const billingStatusQuery = useQuery({ queryKey: ['my-billing-status'], queryFn: getMyBillingStatus })
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full max-w-4xl flex-col gap-6 px-6 py-10">
|
||||
@@ -39,6 +42,12 @@ function ConfigsList() {
|
||||
: t('configs.quota', { used: data.configs.length, max: data.maxConfigs })}
|
||||
</p>
|
||||
)}
|
||||
{billingStatusQuery.data?.billingEnabled && (
|
||||
<Link to="/billing" className="mt-1 inline-flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground">
|
||||
{t('billing.paidUntilLabel')}
|
||||
<PaidUntilBadge paidUntil={billingStatusQuery.data.paidUntil} />
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
{inboundsQuery.data?.length === 0 ? (
|
||||
<p className="max-w-xs text-right text-sm text-muted-foreground">{t('configs.noInboundsNotice')}</p>
|
||||
|
||||
Reference in New Issue
Block a user