From cb2d5926b201eba211d2d5d32ab00b27e9258a18 Mon Sep 17 00:00:00 2001
From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com>
Date: Sun, 18 Jun 2023 17:05:26 +0700
Subject: [PATCH] Fix/alerts (#276)
* improve alert view
* improve alert view
---
.../views/alerts/alert-detail-item.tsx | 59 +++++++++++++++++++
.../internal/views/alerts/index.tsx | 18 +-----
2 files changed, 61 insertions(+), 16 deletions(-)
create mode 100644 src/containers/internal/views/alerts/alert-detail-item.tsx
diff --git a/src/containers/internal/views/alerts/alert-detail-item.tsx b/src/containers/internal/views/alerts/alert-detail-item.tsx
new file mode 100644
index 0000000..401a1ed
--- /dev/null
+++ b/src/containers/internal/views/alerts/alert-detail-item.tsx
@@ -0,0 +1,59 @@
+import dayjs from "dayjs";
+import React, { useState } from "react";
+import { Alert } from "src/api/types";
+import { Icons } from "src/components";
+
+type AlertDetailsItemProps = {
+ alert: Alert;
+};
+
+export const AlertDetailItem = ({ alert }: AlertDetailsItemProps) => {
+ const [open, setOpen] = useState(false);
+
+ return (
+
+
{
+ if (e.target.open && !open) {
+ setOpen(e.target.open);
+ }
+ }}
+ >
+
+
+
+
+ {dayjs(alert.time).format("YYYY MM.DD hh:mm:ss a")}
+
+
+
+
+
+
+ {alert.message}
+
+
+
+
+
+
+
+ {Object.keys(alert).map((key) => (
+
+ {key}:
+
+ {alert[key as keyof typeof alert]
+ ? String(alert[key as keyof typeof alert])
+ : "null"}
+
+
+ ))}
+
+
+
+
+ );
+};
+
+export default AlertDetailItem;
diff --git a/src/containers/internal/views/alerts/index.tsx b/src/containers/internal/views/alerts/index.tsx
index 248d997..ba45a67 100644
--- a/src/containers/internal/views/alerts/index.tsx
+++ b/src/containers/internal/views/alerts/index.tsx
@@ -16,7 +16,6 @@ import {
Section,
SelectFilter,
Spinner,
- Icons,
} from "src/components";
import type { Account, Alert, PageQuery } from "src/api/types";
@@ -27,6 +26,7 @@ import {
getQueryFilter,
setLocation,
} from "src/store/localStore";
+import AlertDetailItem from "./alert-detail-item";
export const Alerts = () => {
const user = useSelectState("user");
@@ -112,21 +112,7 @@ export const Alerts = () => {
) : hasLength(alerts) ? (
alerts.map((alert) => (
-
-
-
-
- {dayjs(alert.time).format("YYYY MM.DD hh:mm a")}
-
-
-
-
-
- {alert.message}
-
-
-
-
+
))
) : (
No data.