hide unused features
This commit is contained in:
1 parent
4c284493ba
commit
e3921beac4
3 files changed
+35
-47
No files matched your search
@@ -3,52 +3,26 @@ import Stack from "@mui/material/Stack";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { Table, type Header, ValueLabel } from "@/Components/v2/design-elements";
|
||||
import { ActionsMenu, type ActionMenuItem } from "@/Components/v2/actions-menu";
|
||||
import { Dialog } from "@/Components/v2/inputs";
|
||||
import { ExternalLink } from "lucide-react";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useTheme } from "@mui/material/styles";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useDelete } from "@/Hooks/UseApi";
|
||||
import { useState } from "react";
|
||||
import { createToast } from "@/Utils/toastUtils";
|
||||
|
||||
import type { StatusPage } from "@/Types/StatusPage";
|
||||
|
||||
interface StatusPagesTableProps {
|
||||
data: StatusPage[];
|
||||
refetch: () => void;
|
||||
setSelectedStatusPage: (statusPage: StatusPage | null) => void;
|
||||
}
|
||||
|
||||
export const StatusPagesTable = ({ data, refetch }: StatusPagesTableProps) => {
|
||||
export const StatusPagesTable = ({
|
||||
data,
|
||||
setSelectedStatusPage,
|
||||
}: StatusPagesTableProps) => {
|
||||
const { t } = useTranslation();
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
const { deleteFn, loading: isDeleting } = useDelete();
|
||||
|
||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
||||
const [selectedStatusPage, setSelectedStatusPage] = useState<StatusPage | null>(null);
|
||||
|
||||
const handleDeleteClick = (statusPage: StatusPage) => {
|
||||
setSelectedStatusPage(statusPage);
|
||||
setIsDeleteDialogOpen(true);
|
||||
};
|
||||
|
||||
const handleDeleteConfirm = async () => {
|
||||
if (!selectedStatusPage) return;
|
||||
const result = await deleteFn(`/status-page/${selectedStatusPage.id}`);
|
||||
if (result) {
|
||||
createToast({ body: t("pages.statusPages.deleteSuccess") });
|
||||
refetch();
|
||||
}
|
||||
setIsDeleteDialogOpen(false);
|
||||
setSelectedStatusPage(null);
|
||||
};
|
||||
|
||||
const handleDeleteCancel = () => {
|
||||
setIsDeleteDialogOpen(false);
|
||||
setSelectedStatusPage(null);
|
||||
};
|
||||
|
||||
const getActions = (row: StatusPage): ActionMenuItem[] => {
|
||||
return [
|
||||
@@ -67,9 +41,7 @@ export const StatusPagesTable = ({ data, refetch }: StatusPagesTableProps) => {
|
||||
{t("common.buttons.delete")}
|
||||
</Typography>
|
||||
),
|
||||
action: () => {
|
||||
handleDeleteClick(row);
|
||||
},
|
||||
action: () => setSelectedStatusPage(row),
|
||||
closeMenu: true,
|
||||
},
|
||||
];
|
||||
@@ -165,14 +137,6 @@ export const StatusPagesTable = ({ data, refetch }: StatusPagesTableProps) => {
|
||||
onRowClick={handleRowClick}
|
||||
emptyViewText={t("common.table.empty")}
|
||||
/>
|
||||
<Dialog
|
||||
open={isDeleteDialogOpen}
|
||||
title={t("common.dialogs.delete.title")}
|
||||
content={t("common.dialogs.delete.description")}
|
||||
onConfirm={handleDeleteConfirm}
|
||||
onCancel={handleDeleteCancel}
|
||||
loading={isDeleting}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user