Fix: Apply server table background to SSL table

- Apply the same background color and styling from the server table to the SSL table for visual consistency.
This commit is contained in:
Tola Leng
2025-07-19 15:37:00 +07:00
parent dc586dc15f
commit c098ecb6bf
@@ -1,8 +1,8 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useQuery, useQueryClient } from "@tanstack/react-query";
import { Plus } from "lucide-react"; import { Plus } from "lucide-react";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { import {
Table, Table,
TableBody, TableBody,
@@ -37,10 +37,12 @@ import { fetchSSLCertificates, addSSLCertificate, deleteSSLCertificate } from "@
import { pb } from "@/lib/pocketbase"; import { pb } from "@/lib/pocketbase";
import { SSLCertificate } from "@/types/ssl.types"; import { SSLCertificate } from "@/types/ssl.types";
import { useLanguage } from "@/contexts/LanguageContext"; import { useLanguage } from "@/contexts/LanguageContext";
import { useTheme } from "@/contexts/ThemeContext";
import { toast } from "sonner"; import { toast } from "sonner";
export const SSLCertificatesTable = () => { export const SSLCertificatesTable = () => {
const { t } = useLanguage(); const { t } = useLanguage();
const { theme } = useTheme();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [showAddDialog, setShowAddDialog] = useState(false); const [showAddDialog, setShowAddDialog] = useState(false);
const [showEditDialog, setShowEditDialog] = useState(false); const [showEditDialog, setShowEditDialog] = useState(false);
@@ -65,7 +67,7 @@ export const SSLCertificatesTable = () => {
setShowAddDialog(false); setShowAddDialog(false);
toast.success(t('certificateAdded')); toast.success(t('certificateAdded'));
} catch (error) { } catch (error) {
console.error("Error adding certificate:", error); // console.error("Error adding certificate:", error);
toast.error(t('failedToAddCertificate')); toast.error(t('failedToAddCertificate'));
} finally { } finally {
setIsSubmitting(false); setIsSubmitting(false);
@@ -87,7 +89,7 @@ export const SSLCertificatesTable = () => {
setSelectedCertificate(null); setSelectedCertificate(null);
toast.success(t('certificateUpdated')); toast.success(t('certificateUpdated'));
} catch (error) { } catch (error) {
console.error("Error updating certificate:", error); // console.error("Error updating certificate:", error);
toast.error(t('failedToUpdateCertificate')); toast.error(t('failedToUpdateCertificate'));
} finally { } finally {
setIsSubmitting(false); setIsSubmitting(false);
@@ -105,7 +107,7 @@ export const SSLCertificatesTable = () => {
setSelectedCertificate(null); setSelectedCertificate(null);
toast.success(t('certificateDeleted')); toast.success(t('certificateDeleted'));
} catch (error) { } catch (error) {
console.error("Error deleting certificate:", error); // console.error("Error deleting certificate:", error);
toast.error(t('failedToDeleteCertificate')); toast.error(t('failedToDeleteCertificate'));
} finally { } finally {
setIsSubmitting(false); setIsSubmitting(false);
@@ -128,24 +130,28 @@ export const SSLCertificatesTable = () => {
}; };
return ( return (
<> <div className="flex-1 flex flex-col h-full">
<Card> {certificates.length === 0 ? (
<CardContent> <div className="text-center py-8 text-muted-foreground">
{t('noCertificatesFound')}
</div>
) : (
<div className={`${theme === 'dark' ? 'bg-gray-900' : 'bg-white'} rounded-lg border border-border shadow-sm`}>
<Table> <Table>
<TableHeader> <TableHeader className={`${theme === 'dark' ? 'bg-gray-800' : 'bg-gray-50'}`}>
<TableRow> <TableRow className={`${theme === 'dark' ? 'border-gray-700 hover:bg-gray-800' : 'border-gray-200 hover:bg-gray-100'}`}>
<TableHead>{t('domain')}</TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4`}>{t('domain')}</TableHead>
<TableHead>{t('status')}</TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4`}>{t('status')}</TableHead>
<TableHead>{t('issuer')}</TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4`}>{t('issuer')}</TableHead>
<TableHead>{t('validUntil')}</TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4`}>{t('validUntil')}</TableHead>
<TableHead>{t('daysLeft')}</TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4`}>{t('daysLeft')}</TableHead>
<TableHead>Check Interval</TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4`}>Check Interval</TableHead>
<TableHead className="w-[50px]"></TableHead> <TableHead className={`${theme === 'dark' ? 'text-gray-300' : 'text-gray-700'} font-medium text-base py-4 text-right w-[50px]`}>Actions</TableHead>
</TableRow> </TableRow>
</TableHeader> </TableHeader>
<TableBody> <TableBody>
{certificates.map((certificate) => ( {certificates.map((certificate) => (
<TableRow key={certificate.id}> <TableRow key={certificate.id} className="hover:bg-muted/50">
<TableCell className="font-medium"> <TableCell className="font-medium">
{certificate.domain} {certificate.domain}
</TableCell> </TableCell>
@@ -164,7 +170,7 @@ export const SSLCertificatesTable = () => {
<TableCell> <TableCell>
{certificate.check_interval || 1} {t('days')} {certificate.check_interval || 1} {t('days')}
</TableCell> </TableCell>
<TableCell> <TableCell className="text-right">
<SSLCertificateActions <SSLCertificateActions
certificate={certificate} certificate={certificate}
onView={openViewDialog} onView={openViewDialog}
@@ -176,14 +182,8 @@ export const SSLCertificatesTable = () => {
))} ))}
</TableBody> </TableBody>
</Table> </Table>
</div>
{certificates.length === 0 && ( )}
<div className="text-center py-8 text-muted-foreground">
{t('noCertificatesFound')}
</div>
)}
</CardContent>
</Card>
{/* View Certificate Dialog */} {/* View Certificate Dialog */}
<SSLCertificateDetailDialog <SSLCertificateDetailDialog
@@ -250,6 +250,6 @@ export const SSLCertificatesTable = () => {
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
</AlertDialog> </AlertDialog>
</> </div>
); );
}; };