Hide, don't clear seenIps upon error

This commit is contained in:
2024-11-01 16:15:35 -05:00
parent 10b93d41d6
commit 40385c9739

View File

@@ -35,7 +35,6 @@ export default function App() {
} catch (error) { } catch (error) {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);
setError(error.message); setError(error.message);
setSeenIps([]); // Clear any previous data
} }
}; };
@@ -67,17 +66,22 @@ export default function App() {
<div className="relative overflow-x-auto"> <div className="relative overflow-x-auto">
<table className="w-full text-left text-sm text-gray-500 rtl:text-right dark:text-gray-300"> <table className="w-full text-left text-sm text-gray-500 rtl:text-right dark:text-gray-300">
<tbody> <tbody>
{seenIps.map((ip) => ( {error == null
<tr key={ip.ip} className="border-b last:border-0 bg-white dark:border-neutral-700 dark:bg-neutral-800"> ? seenIps.map((ip) => (
<td className="py-4"> <tr
<Code>{ip.ip}</Code> key={ip.ip}
</td> className="border-b bg-white last:border-0 dark:border-neutral-700 dark:bg-neutral-800"
<td className="py-4"> >
{ip.count} time{ip.count > 1 ? 's' : ''} <td className="py-4">
</td> <Code>{ip.ip}</Code>
<td className="py-4">{ip.last_seen}</td> </td>
</tr> <td className="py-4">
))} {ip.count} time{ip.count > 1 ? 's' : ''}
</td>
<td className="py-4">{ip.last_seen}</td>
</tr>
))
: null}
</tbody> </tbody>
</table> </table>
</div> </div>