remove unused
This commit is contained in:
1 parent
c1258d3cdf
commit
b1db74d96f
2 files changed
-204
No files matched your search
@@ -1,83 +0,0 @@
|
|||||||
// Components
|
|
||||||
import Menu from "@mui/material/Menu";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import Icon from "@/Components/v1/Icon";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
|
||||||
|
|
||||||
// Utils
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useTheme } from "@emotion/react";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import PropTypes from "prop-types";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
const ActionMenu = ({ notification, onDelete }) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
|
||||||
const open = Boolean(anchorEl);
|
|
||||||
const { t } = useTranslation();
|
|
||||||
// Handlers
|
|
||||||
const handleClick = (event) => {
|
|
||||||
event.stopPropagation();
|
|
||||||
setAnchorEl(event.currentTarget);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleClose = (event) => {
|
|
||||||
if (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
setAnchorEl(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRemove = (e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onDelete(notification.id);
|
|
||||||
handleClose();
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleConfigure = (e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
navigate(`/notifications/${notification.id}`);
|
|
||||||
handleClose();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<IconButton
|
|
||||||
aria-label="notification actions"
|
|
||||||
onClick={handleClick}
|
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<Icon
|
|
||||||
name="Settings"
|
|
||||||
size={20}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
|
|
||||||
<Menu
|
|
||||||
anchorEl={anchorEl}
|
|
||||||
open={open}
|
|
||||||
onClose={handleClose}
|
|
||||||
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
onMouseDown={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
<MenuItem onClick={handleConfigure}>{t("configure")}</MenuItem>
|
|
||||||
<MenuItem
|
|
||||||
onClick={handleRemove}
|
|
||||||
sx={{ "&.MuiButtonBase-root": { color: theme.palette.error.main } }}
|
|
||||||
>
|
|
||||||
{t("delete")}
|
|
||||||
</MenuItem>
|
|
||||||
</Menu>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
ActionMenu.propTypes = {
|
|
||||||
notification: PropTypes.object,
|
|
||||||
onDelete: PropTypes.func,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ActionMenu;
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
// Components
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import Breadcrumbs from "@/Components/v1/Breadcrumbs/index.jsx";
|
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import DataTable from "@/Components/v1/Table/index.jsx";
|
|
||||||
import ActionMenu from "./components/ActionMenu.jsx";
|
|
||||||
import PageStateWrapper from "@/Components/v1/PageStateWrapper/index.jsx";
|
|
||||||
|
|
||||||
// Utils
|
|
||||||
import { useState } from "react";
|
|
||||||
import { useTheme } from "@emotion/react";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import {
|
|
||||||
useGetNotificationsByTeamId,
|
|
||||||
useDeleteNotification,
|
|
||||||
} from "../../Hooks/useNotifications.js";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
|
|
||||||
const Notifications = () => {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const theme = useTheme();
|
|
||||||
const BREADCRUMBS = [{ name: "notifications", path: "/notifications" }];
|
|
||||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
|
||||||
const [notifications, isLoading, error] = useGetNotificationsByTeamId(updateTrigger);
|
|
||||||
const [deleteNotification, isDeleting, deleteError] = useDeleteNotification();
|
|
||||||
const { t } = useTranslation();
|
|
||||||
// Handlers
|
|
||||||
const triggerUpdate = () => {
|
|
||||||
setUpdateTrigger(!updateTrigger);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onDelete = (id) => {
|
|
||||||
deleteNotification(id, triggerUpdate);
|
|
||||||
};
|
|
||||||
|
|
||||||
const headers = [
|
|
||||||
{
|
|
||||||
id: "name",
|
|
||||||
content: "Name",
|
|
||||||
render: (row) => {
|
|
||||||
return row.notificationName;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "target",
|
|
||||||
content: "Target",
|
|
||||||
render: (row) => {
|
|
||||||
return row.address;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "platform",
|
|
||||||
content: "Platform",
|
|
||||||
render: (row) => {
|
|
||||||
return row?.config?.platform || row.type;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
id: "actions",
|
|
||||||
content: "Actions",
|
|
||||||
onClick: (e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
},
|
|
||||||
render: (row) => {
|
|
||||||
return (
|
|
||||||
<ActionMenu
|
|
||||||
notification={row}
|
|
||||||
onDelete={onDelete}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<PageStateWrapper
|
|
||||||
networkError={error}
|
|
||||||
isLoading={isLoading}
|
|
||||||
items={notifications}
|
|
||||||
type="notifications"
|
|
||||||
fallbackLink="/notifications/create"
|
|
||||||
>
|
|
||||||
<Stack gap={theme.spacing(10)}>
|
|
||||||
<Breadcrumbs list={BREADCRUMBS} />
|
|
||||||
<Stack
|
|
||||||
direction="row"
|
|
||||||
justifyContent="flex-end"
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
variant="contained"
|
|
||||||
color="accent"
|
|
||||||
onClick={() => navigate("/notifications/create")}
|
|
||||||
>
|
|
||||||
{t("notifications.createButton")}
|
|
||||||
</Button>
|
|
||||||
</Stack>
|
|
||||||
<Typography variant="h1">{t("notifications.createTitle")}</Typography>
|
|
||||||
<DataTable
|
|
||||||
config={{
|
|
||||||
onRowClick: (row) => navigate(`/notifications/${row.id}`),
|
|
||||||
rowSX: {
|
|
||||||
cursor: "pointer",
|
|
||||||
"&:hover td": {
|
|
||||||
backgroundColor: theme.palette.tertiary.main,
|
|
||||||
transition: "background-color .3s ease",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
headers={headers}
|
|
||||||
data={notifications}
|
|
||||||
/>
|
|
||||||
</Stack>
|
|
||||||
</PageStateWrapper>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Notifications;
|
|
||||||
Reference in new issue
Block a user