Fix jwt-token

This commit is contained in:
2025-09-19 13:33:51 +02:00
parent 6863e3bc65
commit b2bc3f4567
4 changed files with 328 additions and 46 deletions

View File

@@ -1,5 +1,6 @@
import React, { useState, useEffect } from 'react'
import api from '../services/api'
import { t } from '../utils/tempTranslations' // Temporary translation system
import { BuildingOfficeIcon, UsersIcon, ServerIcon, ChartBarIcon } from '@heroicons/react/24/outline'
const Dashboard = () => {
@@ -38,26 +39,26 @@ const Dashboard = () => {
const statCards = [
{
name: 'Total Tenants',
name: t('dashboard.totalTenants'),
value: stats.tenants,
icon: BuildingOfficeIcon,
color: 'bg-blue-500'
},
{
name: 'Total Users',
name: t('dashboard.totalUsers'),
value: stats.users,
icon: UsersIcon,
color: 'bg-green-500'
},
{
name: 'Active Sessions',
name: t('dashboard.activeSessions'),
value: stats.activeSessions,
icon: ChartBarIcon,
color: 'bg-yellow-500'
},
{
name: 'System Health',
value: stats.systemHealth === 'good' ? 'Good' : 'Issues',
name: t('dashboard.systemHealth'),
value: stats.systemHealth === 'good' ? t('dashboard.good') : t('dashboard.issues'),
icon: ServerIcon,
color: stats.systemHealth === 'good' ? 'bg-green-500' : 'bg-red-500'
}
@@ -74,8 +75,8 @@ const Dashboard = () => {
return (
<div>
<div className="mb-8">
<h1 className="text-2xl font-bold text-gray-900">Dashboard</h1>
<p className="text-gray-600">Overview of your UAMILS system</p>
<h1 className="text-2xl font-bold text-gray-900">{t('dashboard.title')}</h1>
<p className="text-gray-600">{t('dashboard.description')}</p>
</div>
{/* Stats Grid */}

View File

@@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'
import api from '../services/api'
import toast from 'react-hot-toast'
import TenantModal from '../components/TenantModal'
import { t } from '../utils/tempTranslations' // Temporary translation system
import {
PlusIcon,
PencilIcon,
@@ -82,16 +83,16 @@ const Tenants = () => {
}
const deleteTenant = async (tenantId) => {
if (!confirm('Are you sure you want to delete this tenant? This action cannot be undone.')) {
if (!confirm(t('tenants.confirmDelete'))) {
return
}
try {
await api.delete(`/management/tenants/${tenantId}`)
toast.success('Tenant deleted successfully')
toast.success(t('tenants.deleteSuccess'))
loadTenants()
} catch (error) {
toast.error('Failed to delete tenant')
toast.error(t('tenants.deleteError'))
console.error('Error deleting tenant:', error)
}
}
@@ -99,8 +100,8 @@ const Tenants = () => {
const toggleTenantStatus = async (tenant) => {
const action = tenant.is_active ? 'deactivate' : 'activate'
const confirmMessage = tenant.is_active
? `Are you sure you want to deactivate "${tenant.name}"? Users will not be able to access this tenant.`
: `Are you sure you want to activate "${tenant.name}"?`
? t('tenants.confirmDeactivate', { name: tenant.name })
: t('tenants.confirmActivate', { name: tenant.name })
if (!confirm(confirmMessage)) {
return
@@ -108,10 +109,10 @@ const Tenants = () => {
try {
await api.post(`/management/tenants/${tenant.id}/${action}`)
toast.success(`Tenant ${action}d successfully`)
toast.success(t(`tenants.${action}Success`))
loadTenants()
} catch (error) {
toast.error(`Failed to ${action} tenant`)
toast.error(t(`tenants.${action}Error`))
console.error(`Error ${action}ing tenant:`, error)
}
}
@@ -166,7 +167,7 @@ const Tenants = () => {
? 'bg-green-100 text-green-800'
: 'bg-red-100 text-red-800'
}`}>
{isActive ? 'Active' : 'Inactive'}
{isActive ? t('common.active') : t('common.inactive')}
</span>
)
}
@@ -185,15 +186,15 @@ const Tenants = () => {
<div className="mb-8">
<div className="flex justify-between items-center">
<div>
<h1 className="text-2xl font-bold text-gray-900">Tenants</h1>
<p className="text-gray-600">Manage organizations and their configurations</p>
<h1 className="text-2xl font-bold text-gray-900">{t('tenants.title')}</h1>
<p className="text-gray-600">{t('tenants.description')}</p>
</div>
<button
onClick={() => setShowCreateModal(true)}
className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center space-x-2"
>
<PlusIcon className="h-5 w-5" />
<span>Create Tenant</span>
<span>{t('tenants.addTenant')}</span>
</button>
</div>
</div>
@@ -204,7 +205,7 @@ const Tenants = () => {
<MagnifyingGlassIcon className="absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400" />
<input
type="text"
placeholder="Search tenants..."
placeholder={t('tenants.searchPlaceholder')}
value={searchTerm}
onChange={handleSearch}
className="pl-10 pr-4 py-2 border border-gray-300 rounded-lg w-full max-w-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
@@ -218,28 +219,28 @@ const Tenants = () => {
<thead className="bg-gray-50">
<tr>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Tenant
{t('tenants.tenant')}
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Domain
{t('tenants.domain')}
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Auth Provider
{t('tenants.authProvider')}
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Subscription
{t('tenants.subscription')}
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Users
{t('tenants.users')}
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Created
{t('tenants.created')}
</th>
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
{t('tenants.status')}
</th>
<th className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
Actions
{t('tenants.actions')}
</th>
</tr>
</thead>
@@ -295,14 +296,14 @@ const Tenants = () => {
<button
onClick={() => handleEditTenant(tenant)}
className="text-blue-600 hover:text-blue-900 p-1 rounded"
title="Edit"
title={t('tenants.edit')}
>
<PencilIcon className="h-4 w-4" />
</button>
<button
onClick={() => deleteTenant(tenant.id)}
className="text-red-600 hover:text-red-900 p-1 rounded"
title="Delete"
title={t('tenants.delete')}
>
<TrashIcon className="h-4 w-4" />
</button>
@@ -322,24 +323,24 @@ const Tenants = () => {
disabled={pagination.offset === 0}
className="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:opacity-50"
>
Previous
{t('common.previous')}
</button>
<button
onClick={() => loadTenants(pagination.offset + pagination.limit, searchTerm)}
disabled={pagination.offset + pagination.limit >= pagination.total}
className="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 disabled:opacity-50"
>
Next
{t('common.next')}
</button>
</div>
<div className="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
<div>
<p className="text-sm text-gray-700">
Showing <span className="font-medium">{pagination.offset + 1}</span> to{' '}
<span className="font-medium">
{Math.min(pagination.offset + pagination.limit, pagination.total)}
</span>{' '}
of <span className="font-medium">{pagination.total}</span> results
{t('common.showingResults', {
start: pagination.offset + 1,
end: Math.min(pagination.offset + pagination.limit, pagination.total),
total: pagination.total
})}
</p>
</div>
</div>
@@ -349,15 +350,15 @@ const Tenants = () => {
{tenants.length === 0 && !loading && (
<div className="text-center py-12">
<BuildingOfficeIcon className="mx-auto h-12 w-12 text-gray-400" />
<h3 className="mt-2 text-sm font-medium text-gray-900">No tenants</h3>
<p className="mt-1 text-sm text-gray-500">Get started by creating a new tenant.</p>
<h3 className="mt-2 text-sm font-medium text-gray-900">{t('tenants.noTenants')}</h3>
<p className="mt-1 text-sm text-gray-500">{t('tenants.noTenantsDescription')}</p>
<div className="mt-6">
<button
onClick={() => setShowCreateModal(true)}
className="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700"
>
<PlusIcon className="h-5 w-5 mr-2" />
Create Tenant
{t('tenants.createTenant')}
</button>
</div>
</div>