EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
DomainTable.jsx
Go to the documentation of this file.
1import DomainTableRow from './DomainTableRow';
2
3function parseJwt(token) {
4 try {
5 const payload = token.split('.')[1];
6 return JSON.parse(atob(payload.replace(/-/g, '+').replace(/_/g, '/')));
7 } catch {
8 return null;
9 }
10}
11
12export default function DomainTable({ domains, onEdit, onDelete, onManageDNS, onManage }) {
13 const token = localStorage.getItem('token');
14 const jwtPayload = token ? parseJwt(token) : null;
15 const isRootTenant = jwtPayload?.is_msp || false;
16
17 return (
18 <div className="card">
19 <div className="data-table-container">
20 <table className="data-table">
21 <thead>
22 <tr>
23 <th>Domain</th>
24 {isRootTenant && <th>Tenant</th>}
25 <th>Customer</th>
26 <th>Registrar</th>
27 <th>Expiry Date</th>
28 <th>Status</th>
29 <th>Auto Renew</th>
30 <th>Contract</th>
31 <th>Actions</th>
32 </tr>
33 </thead>
34 <tbody>
35 {domains.length === 0 ? (
36 <tr>
37 <td colSpan={isRootTenant ? "9" : "8"} style={{ textAlign: 'center', padding: '40px', color: 'var(--text-secondary)' }}>
38 No domains registered yet. Click "Register Domain" to get started.
39 </td>
40 </tr>
41 ) : (
42 domains.map((domain) => (
43 <DomainTableRow
44 key={domain.domain_id}
45 domain={domain}
46 onEdit={onEdit}
47 onDelete={onDelete}
48 onManageDNS={onManageDNS}
49 onManage={onManage}
50 isRootTenant={isRootTenant}
51 />
52 ))
53 )}
54 </tbody>
55 </table>
56 </div>
57 </div>
58 );
59}