Fix jwt-token
This commit is contained in:
@@ -259,11 +259,15 @@ const BrandingSettings = ({ tenantConfig, onRefresh }) => {
|
||||
if (response.data.success) {
|
||||
setBranding(prev => ({ ...prev, logo_url: response.data.data.logo_url }));
|
||||
setLogoPreview(null);
|
||||
// Clear the file input to allow selecting the same file again
|
||||
event.target.value = '';
|
||||
toast.success('Logo uploaded successfully');
|
||||
if (onRefresh) onRefresh();
|
||||
}
|
||||
} catch (error) {
|
||||
toast.error('Failed to upload logo');
|
||||
// Clear the file input on error too
|
||||
event.target.value = '';
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
@@ -278,6 +282,33 @@ const BrandingSettings = ({ tenantConfig, onRefresh }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleLogoRemove = async () => {
|
||||
if (!branding.logo_url) return;
|
||||
|
||||
// Confirm removal
|
||||
if (!window.confirm(t('settings.confirmRemoveLogo'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
setUploading(true);
|
||||
|
||||
try {
|
||||
const response = await api.delete('/tenant/logo');
|
||||
|
||||
if (response.data.success) {
|
||||
setBranding(prev => ({ ...prev, logo_url: null }));
|
||||
setLogoPreview(null);
|
||||
toast.success(t('settings.logoRemoved'));
|
||||
if (onRefresh) onRefresh();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error removing logo:', error);
|
||||
toast.error(t('settings.logoRemoveFailed'));
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="bg-white shadow rounded-lg">
|
||||
<div className="px-4 py-5 sm:p-6">
|
||||
@@ -299,16 +330,38 @@ const BrandingSettings = ({ tenantConfig, onRefresh }) => {
|
||||
|
||||
{/* Current logo display */}
|
||||
{branding.logo_url && (
|
||||
<div className="mb-4">
|
||||
<img
|
||||
src={branding.logo_url.startsWith('http') ? branding.logo_url : `${api.defaults.baseURL.replace('/api', '')}${branding.logo_url}`}
|
||||
alt="Current logo"
|
||||
className="h-16 w-auto object-contain border border-gray-200 rounded p-2"
|
||||
onError={(e) => {
|
||||
e.target.style.display = 'none';
|
||||
}}
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">Current logo</p>
|
||||
<div className="mb-4 p-4 border border-gray-200 rounded-lg bg-gray-50">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<img
|
||||
src={branding.logo_url.startsWith('http') ? branding.logo_url : `${api.defaults.baseURL.replace('/api', '')}${branding.logo_url}`}
|
||||
alt="Current logo"
|
||||
className="h-16 w-auto object-contain border border-gray-200 rounded p-2 bg-white"
|
||||
onError={(e) => {
|
||||
e.target.style.display = 'none';
|
||||
}}
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">Current logo</p>
|
||||
</div>
|
||||
<div className="flex space-x-2 ml-4">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => document.getElementById('logo-file-input').click()}
|
||||
disabled={!canEdit || uploading}
|
||||
className="px-3 py-1.5 text-xs font-medium text-primary-700 bg-primary-100 rounded hover:bg-primary-200 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{t('settings.changeLogo')}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleLogoRemove}
|
||||
disabled={!canEdit || uploading}
|
||||
className="px-3 py-1.5 text-xs font-medium text-red-700 bg-red-100 rounded hover:bg-red-200 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{t('settings.removeLogo')}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -316,6 +369,7 @@ const BrandingSettings = ({ tenantConfig, onRefresh }) => {
|
||||
<div className="flex items-center space-x-4">
|
||||
<div className="flex-1">
|
||||
<input
|
||||
id="logo-file-input"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
disabled={!canEdit || uploading}
|
||||
@@ -325,7 +379,7 @@ const BrandingSettings = ({ tenantConfig, onRefresh }) => {
|
||||
}}
|
||||
className="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-primary-50 file:text-primary-700 hover:file:bg-primary-100 disabled:opacity-50"
|
||||
/>
|
||||
<p className="text-xs text-gray-500 mt-1">PNG, JPG up to 5MB</p>
|
||||
<p className="text-xs text-gray-500 mt-1">PNG, JPG up to 5MB {branding.logo_url ? '• Click "' + t('settings.changeLogo') + '" to replace current logo' : ''}</p>
|
||||
</div>
|
||||
|
||||
{uploading && (
|
||||
|
||||
Reference in New Issue
Block a user