Merge pull request '#9-Mehrfach-gefundene-Kennzahlen' (#61) from #9-Mehrfach-gefundene-Kennzahlen into main
Reviewed-on: #61pull/65/head
commit
2009d5b6f3
|
|
@ -3,7 +3,6 @@ import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
|
||||||
import SearchIcon from "@mui/icons-material/Search";
|
import SearchIcon from "@mui/icons-material/Search";
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
IconButton,
|
|
||||||
Link,
|
Link,
|
||||||
Paper,
|
Paper,
|
||||||
Table,
|
Table,
|
||||||
|
|
@ -13,6 +12,7 @@ import {
|
||||||
TableHead,
|
TableHead,
|
||||||
TableRow,
|
TableRow,
|
||||||
TextField,
|
TextField,
|
||||||
|
Tooltip,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
|
@ -32,7 +32,7 @@ const SETTINGS = [
|
||||||
|
|
||||||
interface KennzahlenTableProps {
|
interface KennzahlenTableProps {
|
||||||
onPageClick?: (page: number) => void;
|
onPageClick?: (page: number) => void;
|
||||||
pdfId: string; // Neue Prop für die PDF-ID
|
pdfId: string;
|
||||||
data: {
|
data: {
|
||||||
[key: string]: {
|
[key: string]: {
|
||||||
label: string;
|
label: string;
|
||||||
|
|
@ -44,7 +44,6 @@ interface KennzahlenTableProps {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// React-Komponente
|
|
||||||
export default function KennzahlenTable({
|
export default function KennzahlenTable({
|
||||||
onPageClick,
|
onPageClick,
|
||||||
data,
|
data,
|
||||||
|
|
@ -121,6 +120,16 @@ export default function KennzahlenTable({
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleNavigateToDetail = (settingName: string) => {
|
||||||
|
navigate({
|
||||||
|
to: "/extractedResult/$pitchBook/$kpi",
|
||||||
|
params: {
|
||||||
|
pitchBook: pdfId,
|
||||||
|
kpi: settingName,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableContainer component={Paper}>
|
<TableContainer component={Paper}>
|
||||||
<Table>
|
<Table>
|
||||||
|
|
@ -132,7 +141,7 @@ export default function KennzahlenTable({
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<strong>Wert</strong>
|
<strong>Wert</strong>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell align="center">
|
||||||
<strong>Seite</strong>
|
<strong>Seite</strong>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
@ -147,89 +156,122 @@ export default function KennzahlenTable({
|
||||||
}))
|
}))
|
||||||
.map((row) => {
|
.map((row) => {
|
||||||
let borderColor = "transparent";
|
let borderColor = "transparent";
|
||||||
if (
|
const hasMultipleValues = row.extractedValues.length > 1;
|
||||||
row.setting.mandatory &&
|
const hasNoValue = row.setting.mandatory &&
|
||||||
(row.extractedValues.length === 0 ||
|
(row.extractedValues.length === 0 ||
|
||||||
row.extractedValues.at(0)?.entity === "")
|
row.extractedValues.at(0)?.entity === "");
|
||||||
)
|
|
||||||
|
if (hasNoValue) {
|
||||||
borderColor = "red";
|
borderColor = "red";
|
||||||
else if (row.extractedValues.length > 1) borderColor = "#f6ed48";
|
} else if (hasMultipleValues) {
|
||||||
|
borderColor = "#f6ed48";
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={row.setting.name}>
|
<TableRow key={row.setting.name}>
|
||||||
<TableCell>{row.setting.name}</TableCell>
|
<TableCell>{row.setting.name}</TableCell>
|
||||||
<TableCell
|
<TableCell
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
startEditing(
|
// Only allow inline editing for non-multiple value cells
|
||||||
row.extractedValues.at(0)?.entity || "",
|
if (!hasMultipleValues) {
|
||||||
row.setting.name,
|
startEditing(
|
||||||
)
|
row.extractedValues.at(0)?.entity || "",
|
||||||
}
|
row.setting.name,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Navigate to detail page for multiple values
|
||||||
|
handleNavigateToDetail(row.setting.name);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
{hasMultipleValues ? (
|
||||||
sx={{
|
<Tooltip
|
||||||
border: `2px solid ${borderColor}`,
|
title={
|
||||||
borderRadius: 1,
|
<>
|
||||||
padding: "4px 8px",
|
<b>Problem</b><br />
|
||||||
display: "flex",
|
Mehrere Werte für die Kennzahl gefunden.
|
||||||
alignItems: "center",
|
</>
|
||||||
justifyContent: "space-between",
|
}
|
||||||
width: "100%",
|
placement="bottom"
|
||||||
cursor: "text",
|
arrow
|
||||||
}}
|
>
|
||||||
>
|
<Box
|
||||||
|
sx={{
|
||||||
|
border: `2px solid ${borderColor}`,
|
||||||
|
borderRadius: 1,
|
||||||
|
padding: "4px 8px",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "space-between",
|
||||||
|
width: "100%",
|
||||||
|
cursor: "pointer",
|
||||||
|
'&:hover': {
|
||||||
|
backgroundColor: '#f5f5f5'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 1,
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
{row.extractedValues.at(0)?.entity || "—"}
|
||||||
|
</span>
|
||||||
|
</Box>
|
||||||
|
<SearchIcon
|
||||||
|
fontSize="small"
|
||||||
|
sx={{ color: "#f6ed48" }}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
border: `2px solid ${borderColor}`,
|
||||||
|
borderRadius: 1,
|
||||||
|
padding: "4px 8px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
gap: 1,
|
justifyContent: "space-between",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
|
cursor: "text",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{row.setting.mandatory &&
|
<Box
|
||||||
row.extractedValues.length === 0 && (
|
sx={{
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 1,
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{hasNoValue && (
|
||||||
<ErrorOutlineIcon fontSize="small" color="error" />
|
<ErrorOutlineIcon fontSize="small" color="error" />
|
||||||
)}
|
)}
|
||||||
{editingIndex === row.setting.name ? (
|
{editingIndex === row.setting.name ? (
|
||||||
<TextField
|
<TextField
|
||||||
value={editValue}
|
value={editValue}
|
||||||
onChange={(e) => setEditValue(e.target.value)}
|
onChange={(e) => setEditValue(e.target.value)}
|
||||||
onKeyDown={(e) =>
|
onKeyDown={(e) =>
|
||||||
handleKeyPress(e, row.setting.name)
|
handleKeyPress(e, row.setting.name)
|
||||||
}
|
}
|
||||||
onBlur={() => handleSave(row.setting.name)}
|
onBlur={() => handleSave(row.setting.name)}
|
||||||
autoFocus
|
autoFocus
|
||||||
size="small"
|
size="small"
|
||||||
fullWidth
|
fullWidth
|
||||||
variant="standard"
|
variant="standard"
|
||||||
sx={{ margin: "-8px 0" }}
|
sx={{ margin: "-8px 0" }}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<span>
|
<span>
|
||||||
{row.extractedValues.at(0)?.entity || "—"}
|
{row.extractedValues.at(0)?.entity || "—"}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{row.extractedValues.length > 1 && (
|
|
||||||
<IconButton
|
|
||||||
aria-label="select"
|
|
||||||
onClick={() =>
|
|
||||||
navigate({
|
|
||||||
to: "/extractedResult/$pitchBook/$kpi",
|
|
||||||
params: {
|
|
||||||
pitchBook: pdfId,
|
|
||||||
kpi: row.setting.name,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<SearchIcon
|
|
||||||
fontSize="small"
|
|
||||||
sx={{ color: "#f6ed48" }}
|
|
||||||
/>
|
|
||||||
</IconButton>
|
|
||||||
)}
|
|
||||||
{row.extractedValues.length <= 1 && (
|
|
||||||
<EditIcon
|
<EditIcon
|
||||||
fontSize="small"
|
fontSize="small"
|
||||||
sx={{ color: "#555", cursor: "pointer" }}
|
sx={{ color: "#555", cursor: "pointer" }}
|
||||||
|
|
@ -241,10 +283,10 @@ export default function KennzahlenTable({
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
</Box>
|
||||||
</Box>
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell align="center">
|
||||||
<Link
|
<Link
|
||||||
component="button"
|
component="button"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
|
@ -262,4 +304,4 @@ export default function KennzahlenTable({
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -10,11 +10,13 @@ import { socket } from "../socket";
|
||||||
interface PDFViewerProps {
|
interface PDFViewerProps {
|
||||||
pitchBookId: string;
|
pitchBookId: string;
|
||||||
currentPage?: number;
|
currentPage?: number;
|
||||||
|
onPageChange?: (page: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function PDFViewer({
|
export default function PDFViewer({
|
||||||
pitchBookId,
|
pitchBookId,
|
||||||
currentPage,
|
currentPage,
|
||||||
|
onPageChange,
|
||||||
}: PDFViewerProps) {
|
}: PDFViewerProps) {
|
||||||
const [numPages, setNumPages] = useState<number | null>(null);
|
const [numPages, setNumPages] = useState<number | null>(null);
|
||||||
const [pageNumber, setPageNumber] = useState(currentPage || 1);
|
const [pageNumber, setPageNumber] = useState(currentPage || 1);
|
||||||
|
|
@ -42,7 +44,7 @@ export default function PDFViewer({
|
||||||
if (currentPage && currentPage !== pageNumber) {
|
if (currentPage && currentPage !== pageNumber) {
|
||||||
setPageNumber(currentPage);
|
setPageNumber(currentPage);
|
||||||
}
|
}
|
||||||
}, [currentPage, pageNumber]);
|
}, [currentPage]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleProgress = (data: { id: number; progress: number }) => {
|
const handleProgress = (data: { id: number; progress: number }) => {
|
||||||
|
|
@ -58,6 +60,11 @@ export default function PDFViewer({
|
||||||
};
|
};
|
||||||
}, [pitchBookId]);
|
}, [pitchBookId]);
|
||||||
|
|
||||||
|
const handlePageChange = (newPage: number) => {
|
||||||
|
setPageNumber(newPage);
|
||||||
|
onPageChange?.(newPage);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
display="flex"
|
display="flex"
|
||||||
|
|
@ -65,15 +72,13 @@ export default function PDFViewer({
|
||||||
justifyContent="center"
|
justifyContent="center"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
width="100%"
|
width="100%"
|
||||||
height="100%"
|
height="auto"
|
||||||
p={2}
|
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
ref={containerRef}
|
ref={containerRef}
|
||||||
sx={{
|
sx={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
maxHeight: "90vh",
|
height: "auto",
|
||||||
overflow: "auto",
|
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
|
|
@ -89,33 +94,34 @@ export default function PDFViewer({
|
||||||
onSourceError={(error) => console.error("Ungültige PDF:", error)}
|
onSourceError={(error) => console.error("Ungültige PDF:", error)}
|
||||||
>
|
>
|
||||||
{containerWidth && (
|
{containerWidth && (
|
||||||
<Page pageNumber={pageNumber} width={containerWidth * 0.8} />
|
<Page pageNumber={pageNumber} width={containerWidth * 0.98} />
|
||||||
)}
|
)}
|
||||||
</Document>
|
</Document>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
mt={2}
|
mt={1}
|
||||||
display="flex"
|
display="flex"
|
||||||
alignItems="center"
|
alignItems="center"
|
||||||
justifyContent="center"
|
justifyContent="center"
|
||||||
gap={1}
|
gap={1}
|
||||||
|
p={1}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={pageNumber <= 1}
|
disabled={pageNumber <= 1}
|
||||||
onClick={() => setPageNumber((p) => p - 1)}
|
onClick={() => handlePageChange(pageNumber - 1)}
|
||||||
>
|
>
|
||||||
<ArrowCircleLeftIcon fontSize="large" />
|
<ArrowCircleLeftIcon fontSize="large" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<span>
|
<span>
|
||||||
{pageNumber} / {numPages}
|
{pageNumber} / {numPages}
|
||||||
</span>
|
</span>
|
||||||
<IconButton
|
<IconButton
|
||||||
disabled={pageNumber >= (numPages || 1)}
|
disabled={pageNumber >= (numPages || 1)}
|
||||||
onClick={() => setPageNumber((p) => p + 1)}
|
onClick={() => handlePageChange(pageNumber + 1)}
|
||||||
>
|
>
|
||||||
<ArrowCircleRightIcon fontSize="large" />
|
<ArrowCircleRightIcon fontSize="large" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -41,8 +41,7 @@ function ExtractedResultsPage() {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Typography variant="h5" gutterBottom>
|
<Typography variant="h5" gutterBottom>
|
||||||
Kennzahlen extrahiert aus: <br />
|
<strong>Extrahierte Kennzahlen</strong>
|
||||||
<strong>FONDSNAME: TODO</strong>
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
|
|
@ -51,7 +50,7 @@ function ExtractedResultsPage() {
|
||||||
sx={{
|
sx={{
|
||||||
width: "100vw",
|
width: "100vw",
|
||||||
maxWidth: "100%",
|
maxWidth: "100%",
|
||||||
height: "80vh",
|
height: "85vh",
|
||||||
mt: 4,
|
mt: 4,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
@ -59,7 +58,8 @@ function ExtractedResultsPage() {
|
||||||
elevation={2}
|
elevation={2}
|
||||||
sx={{
|
sx={{
|
||||||
width: "45%",
|
width: "45%",
|
||||||
height: "100%",
|
maxHeight: "100%",
|
||||||
|
height: "fit-content",
|
||||||
borderRadius: 2,
|
borderRadius: 2,
|
||||||
backgroundColor: "#eeeeee",
|
backgroundColor: "#eeeeee",
|
||||||
padding: 2,
|
padding: 2,
|
||||||
|
|
@ -76,23 +76,33 @@ function ExtractedResultsPage() {
|
||||||
display="flex"
|
display="flex"
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
justifyContent="space-between"
|
justifyContent="space-between"
|
||||||
gap={5}
|
gap={3}
|
||||||
sx={{ width: "55%", height: "95%" }}
|
sx={{
|
||||||
|
width: "55%",
|
||||||
|
maxHeight: "95%"
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Paper
|
<Paper
|
||||||
elevation={2}
|
elevation={2}
|
||||||
sx={{
|
sx={{
|
||||||
height: "100%",
|
width: "100%",
|
||||||
|
height: "fit-content",
|
||||||
|
maxHeight: "100%",
|
||||||
borderRadius: 2,
|
borderRadius: 2,
|
||||||
backgroundColor: "#eeeeee",
|
backgroundColor: "#eeeeee",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
overflow: "auto",
|
||||||
|
padding: 2
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<PDFViewer pitchBookId={pitchBook} currentPage={currentPage} />
|
<PDFViewer
|
||||||
|
pitchBookId={pitchBook}
|
||||||
|
currentPage={currentPage}
|
||||||
|
onPageChange={setCurrentPage}
|
||||||
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
<Box mt={2} display="flex" justifyContent="flex-end" gap={2}>
|
<Box mt={2} display="flex" justifyContent="flex-end" gap={2} sx={{ flexShrink: 0 }}>
|
||||||
<Button variant="contained" sx={{ backgroundColor: "#383838" }}>
|
<Button variant="contained" sx={{ backgroundColor: "#383838" }}>
|
||||||
<ContentPasteIcon sx={{ fontSize: 18, mr: 1 }} />
|
<ContentPasteIcon sx={{ fontSize: 18, mr: 1 }} />
|
||||||
Kennzahlenzeile kopieren
|
Kennzahlenzeile kopieren
|
||||||
|
|
@ -109,4 +119,4 @@ function ExtractedResultsPage() {
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +1,369 @@
|
||||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
import {
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
Box,
|
||||||
|
Button, Dialog, DialogActions, DialogContent,
|
||||||
|
DialogContentText,
|
||||||
|
DialogTitle,
|
||||||
|
IconButton,
|
||||||
|
Link,
|
||||||
|
Paper,
|
||||||
|
Radio,
|
||||||
|
Table,
|
||||||
|
TableBody,
|
||||||
|
TableCell,
|
||||||
|
TableContainer,
|
||||||
|
TableHead,
|
||||||
|
TableRow,
|
||||||
|
TextField,
|
||||||
|
Typography
|
||||||
|
} from "@mui/material";
|
||||||
|
import {useMutation, useQueryClient, useSuspenseQuery} from "@tanstack/react-query";
|
||||||
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
|
import {useEffect, useState} from "react";
|
||||||
|
import PDFViewer from "../components/pdfViewer";
|
||||||
import { kpiQueryOptions } from "../util/query";
|
import { kpiQueryOptions } from "../util/query";
|
||||||
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||||
|
import {fetchPutKPI} from "../util/api";
|
||||||
|
|
||||||
export const Route = createFileRoute("/extractedResult_/$pitchBook/$kpi")({
|
export const Route = createFileRoute("/extractedResult_/$pitchBook/$kpi")({
|
||||||
component: RouteComponent,
|
component: ExtractedResultsPage,
|
||||||
loader: ({ context: { queryClient }, params: { pitchBook } }) =>
|
loader: ({ context: { queryClient }, params: { pitchBook } }) =>
|
||||||
queryClient.ensureQueryData(kpiQueryOptions(pitchBook)),
|
queryClient.ensureQueryData(kpiQueryOptions(pitchBook)),
|
||||||
});
|
});
|
||||||
|
|
||||||
function RouteComponent() {
|
function ExtractedResultsPage() {
|
||||||
const { pitchBook, kpi } = Route.useParams();
|
const params = Route.useParams() as { pitchBook: string; kpi: string };
|
||||||
|
const { pitchBook, kpi } = params;
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: { [kpi.toUpperCase()]: kpiValues },
|
data: kpiData
|
||||||
} = useSuspenseQuery(kpiQueryOptions(pitchBook));
|
} = useSuspenseQuery(kpiQueryOptions(pitchBook));
|
||||||
|
|
||||||
|
const kpiValues = kpiData[kpi.toUpperCase()] || [];
|
||||||
|
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||||
|
const [currentPage, setCurrentPage] = useState(kpiValues[0]?.page || 1);
|
||||||
|
const [showConfirmDialog, setShowConfirmDialog] = useState(false);
|
||||||
|
const [hasChanges, setHasChanges] = useState(false);
|
||||||
|
const [customValue, setCustomValue] = useState('');
|
||||||
|
const originalValue = kpiValues[0]?.entity || '';
|
||||||
|
const selectedValue = selectedIndex === -1 ? customValue : (kpiValues[selectedIndex]?.entity || '');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setHasChanges(selectedValue !== originalValue);
|
||||||
|
}, [selectedValue, originalValue]);
|
||||||
|
|
||||||
|
const { mutate: updateKPI } = useMutation({
|
||||||
|
mutationFn: () => {
|
||||||
|
const updatedData = { ...kpiData };
|
||||||
|
updatedData[kpi.toUpperCase()] = [{
|
||||||
|
...kpiValues[0],
|
||||||
|
entity: selectedValue
|
||||||
|
}];
|
||||||
|
return fetchPutKPI(Number(pitchBook), updatedData);
|
||||||
|
},
|
||||||
|
onSuccess: () => {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ["pitchBookKPI", pitchBook],
|
||||||
|
});
|
||||||
|
navigate({
|
||||||
|
to: "/extractedResult/$pitchBook",
|
||||||
|
params: { pitchBook }
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.error('Error updating KPI:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = event.target.value;
|
||||||
|
if (value === 'custom') {
|
||||||
|
setSelectedIndex(-1);
|
||||||
|
} else {
|
||||||
|
const index = parseInt(value);
|
||||||
|
setSelectedIndex(index);
|
||||||
|
setCustomValue('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCustomValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const value = event.target.value;
|
||||||
|
setCustomValue(value);
|
||||||
|
setSelectedIndex(-1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRowClick = (index: number) => {
|
||||||
|
setSelectedIndex(index);
|
||||||
|
setCustomValue('');
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBackClick = () => {
|
||||||
|
if (hasChanges) {
|
||||||
|
setShowConfirmDialog(true);
|
||||||
|
} else {
|
||||||
|
navigate({
|
||||||
|
to: "/extractedResult/$pitchBook",
|
||||||
|
params: { pitchBook }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleConfirmDiscard = () => {
|
||||||
|
setShowConfirmDialog(false);
|
||||||
|
navigate({
|
||||||
|
to: "/extractedResult/$pitchBook",
|
||||||
|
params: { pitchBook }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelDiscard = () => {
|
||||||
|
setShowConfirmDialog(false);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAcceptReview = () => {
|
||||||
|
updateKPI();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<Box p={4}>
|
||||||
{kpiValues.map((e) => (
|
<Box sx={{ display: 'flex', alignItems: 'center', mb: 3 }}>
|
||||||
<div key={`${e.entity}_${e.page}`}>
|
<IconButton onClick={handleBackClick} sx={{ mr: 2 }}>
|
||||||
{e.label}: {e.entity}
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }} />
|
||||||
</div>
|
</IconButton>
|
||||||
))}
|
<Typography variant="h5" fontWeight="bold">
|
||||||
</div>
|
Überprüfung der Kennzahl: {kpi}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
display="flex"
|
||||||
|
gap={4}
|
||||||
|
sx={{
|
||||||
|
width: "100vw",
|
||||||
|
maxWidth: "100%",
|
||||||
|
height: "85vh",
|
||||||
|
mt: 4,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Paper
|
||||||
|
elevation={2}
|
||||||
|
sx={{
|
||||||
|
width: "45%",
|
||||||
|
maxHeight: "100%",
|
||||||
|
height: "fit-content",
|
||||||
|
borderRadius: 2,
|
||||||
|
backgroundColor: "#eeeeee",
|
||||||
|
padding: 2,
|
||||||
|
overflow: "auto",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableContainer component={Paper}>
|
||||||
|
<Table>
|
||||||
|
<TableHead>
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>
|
||||||
|
<strong>Gefundene Werte</strong>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="center">
|
||||||
|
<strong>Seite</strong>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{kpiValues.map((item, index) => (
|
||||||
|
<TableRow
|
||||||
|
key={`${item.entity}_${item.page}_${index}`}
|
||||||
|
sx={{
|
||||||
|
'&:hover': { backgroundColor: '#f9f9f9' },
|
||||||
|
cursor: 'pointer'
|
||||||
|
}}
|
||||||
|
onClick={() => handleRowClick(index)}
|
||||||
|
>
|
||||||
|
<TableCell>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
borderRadius: 1,
|
||||||
|
padding: '4px 8px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '100%',
|
||||||
|
cursor: 'pointer',
|
||||||
|
'&:hover': {
|
||||||
|
borderColor: '#ccc'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Radio
|
||||||
|
value={index.toString()}
|
||||||
|
checked={selectedIndex === index}
|
||||||
|
onChange={handleRadioChange}
|
||||||
|
sx={{
|
||||||
|
color: '#383838',
|
||||||
|
'&.Mui-checked': { color: '#383838' },
|
||||||
|
padding: '4px',
|
||||||
|
marginRight: 1,
|
||||||
|
'&:focus': {
|
||||||
|
outline: 'none'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<span>{item.entity}</span>
|
||||||
|
</Box>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell align="center">
|
||||||
|
<Link
|
||||||
|
component="button"
|
||||||
|
onClick={(e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setCurrentPage(item.page);
|
||||||
|
}}
|
||||||
|
sx={{ cursor: 'pointer' }}
|
||||||
|
>
|
||||||
|
{item.page}
|
||||||
|
</Link>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
padding: '4px 8px',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
width: '100%',
|
||||||
|
cursor: 'pointer',
|
||||||
|
'&:hover': {
|
||||||
|
borderColor: '#ccc'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedIndex(-1);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Radio
|
||||||
|
value="custom"
|
||||||
|
checked={selectedIndex === -1 && customValue !== ''}
|
||||||
|
onChange={handleRadioChange}
|
||||||
|
sx={{
|
||||||
|
color: '#383838',
|
||||||
|
'&.Mui-checked': { color: '#383838' },
|
||||||
|
padding: '4px',
|
||||||
|
marginRight: 1,
|
||||||
|
'&:focus': {
|
||||||
|
outline: 'none'
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
placeholder="Einen abweichenden Wert eingeben..."
|
||||||
|
value={customValue}
|
||||||
|
onChange={handleCustomValueChange}
|
||||||
|
variant="standard"
|
||||||
|
fullWidth
|
||||||
|
InputProps={{
|
||||||
|
disableUnderline: true,
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
'& .MuiInput-input': {
|
||||||
|
padding: 0,
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onClick={(e: React.MouseEvent) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</TableContainer>
|
||||||
|
</Paper>
|
||||||
|
<Box
|
||||||
|
display="flex"
|
||||||
|
flexDirection="column"
|
||||||
|
justifyContent="space-between"
|
||||||
|
gap={3}
|
||||||
|
sx={{ width: "55%", height: "95%" }}
|
||||||
|
>
|
||||||
|
<Paper
|
||||||
|
elevation={2}
|
||||||
|
sx={{
|
||||||
|
width: "100%",
|
||||||
|
height: "fit-content",
|
||||||
|
maxHeight: "100%",
|
||||||
|
borderRadius: 2,
|
||||||
|
backgroundColor: "#eeeeee",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
overflow: "auto",
|
||||||
|
padding: 2
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PDFViewer
|
||||||
|
pitchBookId={pitchBook}
|
||||||
|
currentPage={currentPage}
|
||||||
|
onPageChange={setCurrentPage}
|
||||||
|
/>
|
||||||
|
</Paper>
|
||||||
|
<Box mt={2} display="flex" justifyContent="flex-end" gap={2}>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
onClick={handleAcceptReview}
|
||||||
|
disabled={!selectedValue}
|
||||||
|
sx={{
|
||||||
|
backgroundColor: '#383838',
|
||||||
|
'&:hover': { backgroundColor: '#2e2e2e' },
|
||||||
|
'&.Mui-disabled': { backgroundColor: '#ccc' }
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Überprüfung Annehmen
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Dialog
|
||||||
|
open={showConfirmDialog}
|
||||||
|
onClose={handleCancelDiscard}
|
||||||
|
maxWidth="sm"
|
||||||
|
fullWidth
|
||||||
|
>
|
||||||
|
<DialogTitle sx={{ fontSize: '1.25rem', fontWeight: 'bold' }}>
|
||||||
|
Achtung
|
||||||
|
</DialogTitle>
|
||||||
|
<DialogContent>
|
||||||
|
<DialogContentText sx={{ fontSize: '1rem' }}>
|
||||||
|
Alle vorgenommenen Änderungen werden verworfen.
|
||||||
|
</DialogContentText>
|
||||||
|
</DialogContent>
|
||||||
|
<DialogActions sx={{ p: 3, gap: 2 }}>
|
||||||
|
<Button
|
||||||
|
onClick={handleCancelDiscard}
|
||||||
|
variant="outlined"
|
||||||
|
sx={{
|
||||||
|
color: '#666',
|
||||||
|
borderColor: '#ddd',
|
||||||
|
'&:hover': { backgroundColor: '#f5f5f5' }
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Abbrechen
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={handleConfirmDiscard}
|
||||||
|
variant="contained"
|
||||||
|
sx={{
|
||||||
|
backgroundColor: '#383838',
|
||||||
|
'&:hover': { backgroundColor: '#2e2e2e' }
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Bestätigen
|
||||||
|
</Button>
|
||||||
|
</DialogActions>
|
||||||
|
</Dialog>
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue