mirror of
https://github.com/Myzel394/kleckrelay-website.git
synced 2025-06-20 08:15:26 +02:00
adding delete reports
This commit is contained in:
parent
e37eecda97
commit
553f93828f
@ -12,7 +12,8 @@
|
|||||||
},
|
},
|
||||||
"defaultError": "An error occurred.",
|
"defaultError": "An error occurred.",
|
||||||
"defaultSuccess": "Success!",
|
"defaultSuccess": "Success!",
|
||||||
"loading": "Loading..."
|
"loading": "Loading...",
|
||||||
|
"actionNotUndoable": "This action cannot be undone!"
|
||||||
},
|
},
|
||||||
|
|
||||||
"routes": {
|
"routes": {
|
||||||
@ -181,6 +182,13 @@
|
|||||||
},
|
},
|
||||||
"ReportDetailRoute": {
|
"ReportDetailRoute": {
|
||||||
"title": "Report Details",
|
"title": "Report Details",
|
||||||
|
"actions": {
|
||||||
|
"delete": {
|
||||||
|
"label": "Delete Report",
|
||||||
|
"description": "Are you sure you want to delete this report?",
|
||||||
|
"continueAction": "Delete Report"
|
||||||
|
}
|
||||||
|
},
|
||||||
"sections": {
|
"sections": {
|
||||||
"information": {
|
"information": {
|
||||||
"title": "Email Information",
|
"title": "Email Information",
|
||||||
|
57
src/route-widgets/ReportDetailRoute/DeleteButton.tsx
Normal file
57
src/route-widgets/ReportDetailRoute/DeleteButton.tsx
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import {ReactElement, useState} from "react"
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Dialog,
|
||||||
|
DialogActions,
|
||||||
|
DialogContent,
|
||||||
|
DialogContentText,
|
||||||
|
DialogTitle,
|
||||||
|
Typography,
|
||||||
|
} from "@mui/material"
|
||||||
|
import {useTranslation} from "react-i18next"
|
||||||
|
import {MdDelete} from "react-icons/md"
|
||||||
|
import {TiCancel} from "react-icons/ti"
|
||||||
|
|
||||||
|
export interface DeleteButtonProps {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ReportDetailRoute({id}: DeleteButtonProps): ReactElement {
|
||||||
|
const {t} = useTranslation()
|
||||||
|
|
||||||
|
const [showDeleteDialog, setShowDeleteDialog] = useState<boolean>(false)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
color="error"
|
||||||
|
size="small"
|
||||||
|
startIcon={<MdDelete />}
|
||||||
|
onClick={() => setShowDeleteDialog(true)}
|
||||||
|
>
|
||||||
|
{t("routes.ReportDetailRoute.actions.delete.label")}
|
||||||
|
</Button>
|
||||||
|
<Dialog open={showDeleteDialog} onClose={() => setShowDeleteDialog(false)}>
|
||||||
|
<DialogTitle>{t("routes.ReportDetailRoute.actions.delete.label")}</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText>
|
||||||
|
{t("routes.ReportDetailRoute.actions.delete.description")}
|
||||||
|
</DialogContentText>
|
||||||
|
<DialogContentText color="error">
|
||||||
|
{t("general.actionNotUndoable")}
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions>
|
||||||
|
<Button startIcon={<TiCancel />} onClick={() => setShowDeleteDialog(false)}>
|
||||||
|
{t("general.cancelLabel")}
|
||||||
|
</Button>
|
||||||
|
<Button startIcon={<MdDelete />} color="error">
|
||||||
|
{t("routes.ReportDetailRoute.actions.delete.continueAction")}
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
@ -4,12 +4,15 @@ import {useTranslation} from "react-i18next"
|
|||||||
import React, {ReactElement} from "react"
|
import React, {ReactElement} from "react"
|
||||||
|
|
||||||
import {useQuery} from "@tanstack/react-query"
|
import {useQuery} from "@tanstack/react-query"
|
||||||
import {List} from "@mui/material"
|
import {Button, List} from "@mui/material"
|
||||||
|
|
||||||
import {DecryptedReportContent, Report} from "~/server-types"
|
import {DecryptedReportContent, Report} from "~/server-types"
|
||||||
import {getReport} from "~/apis"
|
import {getReport} from "~/apis"
|
||||||
import {DecryptReport, SimpleOverlayInformation, SimplePageBuilder} from "~/components"
|
import {DecryptReport, SimpleOverlayInformation, SimplePageBuilder} from "~/components"
|
||||||
import {WithEncryptionRequired} from "~/hocs"
|
import {WithEncryptionRequired} from "~/hocs"
|
||||||
|
import {BsTrash} from "react-icons/bs"
|
||||||
|
import {MdDelete} from "react-icons/md"
|
||||||
|
import DeleteButton from "~/route-widgets/ReportDetailRoute/DeleteButton"
|
||||||
import ProxiedImagesListItem from "~/route-widgets/ReportDetailRoute/ProxiedImagesListItem"
|
import ProxiedImagesListItem from "~/route-widgets/ReportDetailRoute/ProxiedImagesListItem"
|
||||||
import QueryResult from "~/components/QueryResult"
|
import QueryResult from "~/components/QueryResult"
|
||||||
import SinglePixelImageTrackersListItem from "~/route-widgets/ReportDetailRoute/SinglePixelImageTrackersListItem"
|
import SinglePixelImageTrackersListItem from "~/route-widgets/ReportDetailRoute/SinglePixelImageTrackersListItem"
|
||||||
@ -23,7 +26,10 @@ function ReportDetailRoute(): ReactElement {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SimplePageBuilder.Page title="Report Details">
|
<SimplePageBuilder.Page
|
||||||
|
title="Report Details"
|
||||||
|
actions={query.data && <DeleteButton id={query.data.id} />}
|
||||||
|
>
|
||||||
<QueryResult<Report> query={query}>
|
<QueryResult<Report> query={query}>
|
||||||
{encryptedReport => (
|
{encryptedReport => (
|
||||||
<DecryptReport encryptedContent={encryptedReport.encryptedContent}>
|
<DecryptReport encryptedContent={encryptedReport.encryptedContent}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user