Added new page overview of all pitchbooks.
parent
41a37b3d7d
commit
935cf0c176
|
|
@ -6,7 +6,11 @@ import type { Kennzahl } from "../types/kpi";
|
||||||
import { getDisplayType } from "../types/kpi";
|
import { getDisplayType } from "../types/kpi";
|
||||||
import { fetchKennzahlen as fetchK } from "../util/api";
|
import { fetchKennzahlen as fetchK } from "../util/api";
|
||||||
|
|
||||||
export function ConfigTable() {
|
type ConfigTableProps = {
|
||||||
|
from?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ConfigTable({ from }: ConfigTableProps) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [kennzahlen, setKennzahlen] = useState<Kennzahl[]>([]);
|
const [kennzahlen, setKennzahlen] = useState<Kennzahl[]>([]);
|
||||||
const [draggedItem, setDraggedItem] = useState<Kennzahl | null>(null);
|
const [draggedItem, setDraggedItem] = useState<Kennzahl | null>(null);
|
||||||
|
|
@ -160,12 +164,10 @@ export function ConfigTable() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Navigating to detail page for KPI:", kennzahl);
|
|
||||||
console.log("KPI ID:", kennzahl.id);
|
|
||||||
|
|
||||||
navigate({
|
navigate({
|
||||||
to: `/config-detail/$kpiId`,
|
to: `/config-detail/$kpiId`,
|
||||||
params: { kpiId: kennzahl.id.toString() },
|
params: { kpiId: kennzahl.id.toString() },
|
||||||
|
search: from ? { from } : undefined,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,186 @@
|
||||||
|
import { Box, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography, CircularProgress, Chip } from "@mui/material";
|
||||||
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { pitchBooksQueryOptions } from "../util/query";
|
||||||
|
import PictureAsPdfIcon from '@mui/icons-material/PictureAsPdf';
|
||||||
|
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
||||||
|
import HourglassEmptyIcon from '@mui/icons-material/HourglassEmpty';
|
||||||
|
|
||||||
|
interface PitchBook {
|
||||||
|
id: number;
|
||||||
|
filename: string;
|
||||||
|
created_at: string;
|
||||||
|
kpi?: string | {
|
||||||
|
[key: string]: {
|
||||||
|
label: string;
|
||||||
|
entity: string;
|
||||||
|
page: number;
|
||||||
|
status: string;
|
||||||
|
source: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
status?: 'processing' | 'completed';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function PitchBooksTable() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { data: pitchBooks, isLoading } = useSuspenseQuery(pitchBooksQueryOptions());
|
||||||
|
|
||||||
|
const handleRowClick = (pitchBookId: number) => {
|
||||||
|
navigate({
|
||||||
|
to: "/extractedResult/$pitchBook",
|
||||||
|
params: { pitchBook: pitchBookId.toString() },
|
||||||
|
search: { from: "overview" }
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const getKPIValue = (pitchBook: PitchBook, fieldName: string): string => {
|
||||||
|
if (!pitchBook.kpi || typeof pitchBook.kpi === 'string') {
|
||||||
|
try {
|
||||||
|
const parsedKPI = JSON.parse(pitchBook.kpi as string);
|
||||||
|
// Convert array to object format if needed
|
||||||
|
const kpiObj = Array.isArray(parsedKPI) ?
|
||||||
|
parsedKPI.reduce((acc: any, item: any) => {
|
||||||
|
if (!acc[item.label]) acc[item.label] = [];
|
||||||
|
acc[item.label].push(item);
|
||||||
|
return acc;
|
||||||
|
}, {}) : parsedKPI;
|
||||||
|
|
||||||
|
return kpiObj[fieldName]?.[0]?.entity || 'N/A';
|
||||||
|
} catch {
|
||||||
|
return 'N/A';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (pitchBook.kpi as any)[fieldName]?.[0]?.entity || 'N/A';
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStatus = (pitchBook: PitchBook) => {
|
||||||
|
if (pitchBook.kpi &&
|
||||||
|
((typeof pitchBook.kpi === 'string' && pitchBook.kpi !== '{}') ||
|
||||||
|
(typeof pitchBook.kpi === 'object' && Object.keys(pitchBook.kpi).length > 0))) {
|
||||||
|
return 'completed';
|
||||||
|
}
|
||||||
|
return 'processing';
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return (
|
||||||
|
<Box display="flex" justifyContent="center" alignItems="center" height="400px">
|
||||||
|
<CircularProgress sx={{ color: "#383838" }} />
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableContainer
|
||||||
|
component={Paper}
|
||||||
|
sx={{
|
||||||
|
width: "85%",
|
||||||
|
maxWidth: 1200,
|
||||||
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Table>
|
||||||
|
<TableHead>
|
||||||
|
<TableRow sx={{ backgroundColor: "#f5f5f5" }}>
|
||||||
|
<TableCell sx={{ width: "60px" }}></TableCell>
|
||||||
|
<TableCell sx={{ fontWeight: "bold" }}>Fondsname</TableCell>
|
||||||
|
<TableCell sx={{ fontWeight: "bold" }}>Fondsmanager</TableCell>
|
||||||
|
<TableCell sx={{ fontWeight: "bold" }}>Dateiname</TableCell>
|
||||||
|
<TableCell sx={{ fontWeight: "bold", width: "120px" }}>Status</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableHead>
|
||||||
|
<TableBody>
|
||||||
|
{pitchBooks.map((pitchBook: PitchBook) => {
|
||||||
|
const status = getStatus(pitchBook);
|
||||||
|
const fundName = getKPIValue(pitchBook, 'FONDSNAME') ||
|
||||||
|
getKPIValue(pitchBook, 'FUND_NAME') ||
|
||||||
|
getKPIValue(pitchBook, 'NAME');
|
||||||
|
|
||||||
|
const manager = getKPIValue(pitchBook, 'FONDSMANAGER') ||
|
||||||
|
getKPIValue(pitchBook, 'MANAGER') ||
|
||||||
|
getKPIValue(pitchBook, 'PORTFOLIO_MANAGER');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableRow
|
||||||
|
key={pitchBook.id}
|
||||||
|
onClick={() => handleRowClick(pitchBook.id)}
|
||||||
|
sx={{
|
||||||
|
cursor: "pointer",
|
||||||
|
"&:hover": {
|
||||||
|
backgroundColor: "#f9f9f9",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TableCell>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: 40,
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: "#f0f0f0",
|
||||||
|
borderRadius: 1,
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
border: "1px solid #e0e0e0",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PictureAsPdfIcon fontSize="small" sx={{ color: "#666" }} />
|
||||||
|
</Box>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Typography variant="body2" fontWeight="medium">
|
||||||
|
{fundName}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>{manager}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Typography variant="body2" color="text.secondary" fontSize="0.875rem">
|
||||||
|
{pitchBook.filename}
|
||||||
|
</Typography>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
{status === 'completed' ? (
|
||||||
|
<Chip
|
||||||
|
icon={<CheckCircleIcon />}
|
||||||
|
label="Abgeschlossen"
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "#e8f5e9",
|
||||||
|
color: "#2e7d32",
|
||||||
|
"& .MuiChip-icon": {
|
||||||
|
color: "#2e7d32",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Chip
|
||||||
|
icon={<HourglassEmptyIcon />}
|
||||||
|
label="In Bearbeitung"
|
||||||
|
size="small"
|
||||||
|
sx={{
|
||||||
|
backgroundColor: "#fff3e0",
|
||||||
|
color: "#e65100",
|
||||||
|
"& .MuiChip-icon": {
|
||||||
|
color: "#e65100",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
{pitchBooks.length === 0 && (
|
||||||
|
<Box p={4} textAlign="center">
|
||||||
|
<Typography color="text.secondary">
|
||||||
|
Keine Pitch Books vorhanden
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</TableContainer>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -178,6 +178,19 @@ export default function UploadPage() {
|
||||||
>
|
>
|
||||||
Kennzahlen extrahieren
|
Kennzahlen extrahieren
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="contained"
|
||||||
|
sx={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: 32,
|
||||||
|
left: 32,
|
||||||
|
backgroundColor: "#383838",
|
||||||
|
"&:hover": { backgroundColor: "#2e2e2e" },
|
||||||
|
}}
|
||||||
|
onClick={() => navigate({ to: "/pitchbooks" })}
|
||||||
|
>
|
||||||
|
Alle Pitch Books anzeigen
|
||||||
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@
|
||||||
// Import Routes
|
// Import Routes
|
||||||
|
|
||||||
import { Route as rootRoute } from './routes/__root'
|
import { Route as rootRoute } from './routes/__root'
|
||||||
|
import { Route as PitchbooksImport } from './routes/pitchbooks'
|
||||||
import { Route as ConfigAddImport } from './routes/config-add'
|
import { Route as ConfigAddImport } from './routes/config-add'
|
||||||
import { Route as ConfigImport } from './routes/config'
|
import { Route as ConfigImport } from './routes/config'
|
||||||
import { Route as IndexImport } from './routes/index'
|
import { Route as IndexImport } from './routes/index'
|
||||||
|
|
@ -20,6 +21,12 @@ import { Route as ExtractedResultPitchBookKpiImport } from './routes/extractedRe
|
||||||
|
|
||||||
// Create/Update Routes
|
// Create/Update Routes
|
||||||
|
|
||||||
|
const PitchbooksRoute = PitchbooksImport.update({
|
||||||
|
id: '/pitchbooks',
|
||||||
|
path: '/pitchbooks',
|
||||||
|
getParentRoute: () => rootRoute,
|
||||||
|
} as any)
|
||||||
|
|
||||||
const ConfigAddRoute = ConfigAddImport.update({
|
const ConfigAddRoute = ConfigAddImport.update({
|
||||||
id: '/config-add',
|
id: '/config-add',
|
||||||
path: '/config-add',
|
path: '/config-add',
|
||||||
|
|
@ -82,6 +89,13 @@ declare module '@tanstack/react-router' {
|
||||||
preLoaderRoute: typeof ConfigAddImport
|
preLoaderRoute: typeof ConfigAddImport
|
||||||
parentRoute: typeof rootRoute
|
parentRoute: typeof rootRoute
|
||||||
}
|
}
|
||||||
|
'/pitchbooks': {
|
||||||
|
id: '/pitchbooks'
|
||||||
|
path: '/pitchbooks'
|
||||||
|
fullPath: '/pitchbooks'
|
||||||
|
preLoaderRoute: typeof PitchbooksImport
|
||||||
|
parentRoute: typeof rootRoute
|
||||||
|
}
|
||||||
'/config-detail/$kpiId': {
|
'/config-detail/$kpiId': {
|
||||||
id: '/config-detail/$kpiId'
|
id: '/config-detail/$kpiId'
|
||||||
path: '/config-detail/$kpiId'
|
path: '/config-detail/$kpiId'
|
||||||
|
|
@ -112,6 +126,7 @@ export interface FileRoutesByFullPath {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/config': typeof ConfigRoute
|
'/config': typeof ConfigRoute
|
||||||
'/config-add': typeof ConfigAddRoute
|
'/config-add': typeof ConfigAddRoute
|
||||||
|
'/pitchbooks': typeof PitchbooksRoute
|
||||||
'/config-detail/$kpiId': typeof ConfigDetailKpiIdRoute
|
'/config-detail/$kpiId': typeof ConfigDetailKpiIdRoute
|
||||||
'/extractedResult/$pitchBook': typeof ExtractedResultPitchBookRoute
|
'/extractedResult/$pitchBook': typeof ExtractedResultPitchBookRoute
|
||||||
'/extractedResult/$pitchBook/$kpi': typeof ExtractedResultPitchBookKpiRoute
|
'/extractedResult/$pitchBook/$kpi': typeof ExtractedResultPitchBookKpiRoute
|
||||||
|
|
@ -121,6 +136,7 @@ export interface FileRoutesByTo {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/config': typeof ConfigRoute
|
'/config': typeof ConfigRoute
|
||||||
'/config-add': typeof ConfigAddRoute
|
'/config-add': typeof ConfigAddRoute
|
||||||
|
'/pitchbooks': typeof PitchbooksRoute
|
||||||
'/config-detail/$kpiId': typeof ConfigDetailKpiIdRoute
|
'/config-detail/$kpiId': typeof ConfigDetailKpiIdRoute
|
||||||
'/extractedResult/$pitchBook': typeof ExtractedResultPitchBookRoute
|
'/extractedResult/$pitchBook': typeof ExtractedResultPitchBookRoute
|
||||||
'/extractedResult/$pitchBook/$kpi': typeof ExtractedResultPitchBookKpiRoute
|
'/extractedResult/$pitchBook/$kpi': typeof ExtractedResultPitchBookKpiRoute
|
||||||
|
|
@ -131,6 +147,7 @@ export interface FileRoutesById {
|
||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/config': typeof ConfigRoute
|
'/config': typeof ConfigRoute
|
||||||
'/config-add': typeof ConfigAddRoute
|
'/config-add': typeof ConfigAddRoute
|
||||||
|
'/pitchbooks': typeof PitchbooksRoute
|
||||||
'/config-detail/$kpiId': typeof ConfigDetailKpiIdRoute
|
'/config-detail/$kpiId': typeof ConfigDetailKpiIdRoute
|
||||||
'/extractedResult/$pitchBook': typeof ExtractedResultPitchBookRoute
|
'/extractedResult/$pitchBook': typeof ExtractedResultPitchBookRoute
|
||||||
'/extractedResult_/$pitchBook/$kpi': typeof ExtractedResultPitchBookKpiRoute
|
'/extractedResult_/$pitchBook/$kpi': typeof ExtractedResultPitchBookKpiRoute
|
||||||
|
|
@ -142,6 +159,7 @@ export interface FileRouteTypes {
|
||||||
| '/'
|
| '/'
|
||||||
| '/config'
|
| '/config'
|
||||||
| '/config-add'
|
| '/config-add'
|
||||||
|
| '/pitchbooks'
|
||||||
| '/config-detail/$kpiId'
|
| '/config-detail/$kpiId'
|
||||||
| '/extractedResult/$pitchBook'
|
| '/extractedResult/$pitchBook'
|
||||||
| '/extractedResult/$pitchBook/$kpi'
|
| '/extractedResult/$pitchBook/$kpi'
|
||||||
|
|
@ -150,6 +168,7 @@ export interface FileRouteTypes {
|
||||||
| '/'
|
| '/'
|
||||||
| '/config'
|
| '/config'
|
||||||
| '/config-add'
|
| '/config-add'
|
||||||
|
| '/pitchbooks'
|
||||||
| '/config-detail/$kpiId'
|
| '/config-detail/$kpiId'
|
||||||
| '/extractedResult/$pitchBook'
|
| '/extractedResult/$pitchBook'
|
||||||
| '/extractedResult/$pitchBook/$kpi'
|
| '/extractedResult/$pitchBook/$kpi'
|
||||||
|
|
@ -158,6 +177,7 @@ export interface FileRouteTypes {
|
||||||
| '/'
|
| '/'
|
||||||
| '/config'
|
| '/config'
|
||||||
| '/config-add'
|
| '/config-add'
|
||||||
|
| '/pitchbooks'
|
||||||
| '/config-detail/$kpiId'
|
| '/config-detail/$kpiId'
|
||||||
| '/extractedResult/$pitchBook'
|
| '/extractedResult/$pitchBook'
|
||||||
| '/extractedResult_/$pitchBook/$kpi'
|
| '/extractedResult_/$pitchBook/$kpi'
|
||||||
|
|
@ -168,6 +188,7 @@ export interface RootRouteChildren {
|
||||||
IndexRoute: typeof IndexRoute
|
IndexRoute: typeof IndexRoute
|
||||||
ConfigRoute: typeof ConfigRoute
|
ConfigRoute: typeof ConfigRoute
|
||||||
ConfigAddRoute: typeof ConfigAddRoute
|
ConfigAddRoute: typeof ConfigAddRoute
|
||||||
|
PitchbooksRoute: typeof PitchbooksRoute
|
||||||
ConfigDetailKpiIdRoute: typeof ConfigDetailKpiIdRoute
|
ConfigDetailKpiIdRoute: typeof ConfigDetailKpiIdRoute
|
||||||
ExtractedResultPitchBookRoute: typeof ExtractedResultPitchBookRoute
|
ExtractedResultPitchBookRoute: typeof ExtractedResultPitchBookRoute
|
||||||
ExtractedResultPitchBookKpiRoute: typeof ExtractedResultPitchBookKpiRoute
|
ExtractedResultPitchBookKpiRoute: typeof ExtractedResultPitchBookKpiRoute
|
||||||
|
|
@ -177,6 +198,7 @@ const rootRouteChildren: RootRouteChildren = {
|
||||||
IndexRoute: IndexRoute,
|
IndexRoute: IndexRoute,
|
||||||
ConfigRoute: ConfigRoute,
|
ConfigRoute: ConfigRoute,
|
||||||
ConfigAddRoute: ConfigAddRoute,
|
ConfigAddRoute: ConfigAddRoute,
|
||||||
|
PitchbooksRoute: PitchbooksRoute,
|
||||||
ConfigDetailKpiIdRoute: ConfigDetailKpiIdRoute,
|
ConfigDetailKpiIdRoute: ConfigDetailKpiIdRoute,
|
||||||
ExtractedResultPitchBookRoute: ExtractedResultPitchBookRoute,
|
ExtractedResultPitchBookRoute: ExtractedResultPitchBookRoute,
|
||||||
ExtractedResultPitchBookKpiRoute: ExtractedResultPitchBookKpiRoute,
|
ExtractedResultPitchBookKpiRoute: ExtractedResultPitchBookKpiRoute,
|
||||||
|
|
@ -195,6 +217,7 @@ export const routeTree = rootRoute
|
||||||
"/",
|
"/",
|
||||||
"/config",
|
"/config",
|
||||||
"/config-add",
|
"/config-add",
|
||||||
|
"/pitchbooks",
|
||||||
"/config-detail/$kpiId",
|
"/config-detail/$kpiId",
|
||||||
"/extractedResult/$pitchBook",
|
"/extractedResult/$pitchBook",
|
||||||
"/extractedResult_/$pitchBook/$kpi"
|
"/extractedResult_/$pitchBook/$kpi"
|
||||||
|
|
@ -209,6 +232,9 @@ export const routeTree = rootRoute
|
||||||
"/config-add": {
|
"/config-add": {
|
||||||
"filePath": "config-add.tsx"
|
"filePath": "config-add.tsx"
|
||||||
},
|
},
|
||||||
|
"/pitchbooks": {
|
||||||
|
"filePath": "pitchbooks.tsx"
|
||||||
|
},
|
||||||
"/config-detail/$kpiId": {
|
"/config-detail/$kpiId": {
|
||||||
"filePath": "config-detail.$kpiId.tsx"
|
"filePath": "config-detail.$kpiId.tsx"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,23 @@ import type { Kennzahl } from "../types/kpi";
|
||||||
|
|
||||||
export const Route = createFileRoute("/config-add")({
|
export const Route = createFileRoute("/config-add")({
|
||||||
component: ConfigAddPage,
|
component: ConfigAddPage,
|
||||||
|
validateSearch: (search: Record<string, unknown>): { from?: string } => {
|
||||||
|
return {
|
||||||
|
from: search.from as string | undefined,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function ConfigAddPage() {
|
function ConfigAddPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { from } = Route.useSearch();
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
navigate({
|
||||||
|
to: "/config",
|
||||||
|
search: from ? { from } : undefined,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const handleSave = async (formData: Partial<Kennzahl>) => {
|
const handleSave = async (formData: Partial<Kennzahl>) => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -68,7 +81,7 @@ function ConfigAddPage() {
|
||||||
mb={4}
|
mb={4}
|
||||||
>
|
>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<IconButton onClick={() => navigate({ to: "/config" })}>
|
<IconButton onClick={handleBack}>
|
||||||
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography variant="h5" fontWeight="bold" ml={3}>
|
<Typography variant="h5" fontWeight="bold" ml={3}>
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,29 @@ import { typeDisplayMapping } from "../types/kpi";
|
||||||
|
|
||||||
export const Route = createFileRoute("/config-detail/$kpiId")({
|
export const Route = createFileRoute("/config-detail/$kpiId")({
|
||||||
component: KPIDetailPage,
|
component: KPIDetailPage,
|
||||||
|
validateSearch: (search: Record<string, unknown>): { from?: string } => {
|
||||||
|
return {
|
||||||
|
from: search.from as string | undefined,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function KPIDetailPage() {
|
function KPIDetailPage() {
|
||||||
const { kpiId } = Route.useParams();
|
const { kpiId } = Route.useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { from } = Route.useSearch();
|
||||||
const [kennzahl, setKennzahl] = useState<Kennzahl | null>(null);
|
const [kennzahl, setKennzahl] = useState<Kennzahl | null>(null);
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
navigate({
|
||||||
|
to: "/config",
|
||||||
|
search: from ? { from } : undefined
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchKennzahl = async () => {
|
const fetchKennzahl = async () => {
|
||||||
try {
|
try {
|
||||||
|
|
@ -138,7 +151,7 @@ function KPIDetailPage() {
|
||||||
mb={4}
|
mb={4}
|
||||||
>
|
>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<IconButton onClick={() => navigate({ to: "/config" })}>
|
<IconButton onClick={handleBack}>
|
||||||
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography variant="h5" fontWeight="bold" ml={3}>
|
<Typography variant="h5" fontWeight="bold" ml={3}>
|
||||||
|
|
@ -249,7 +262,7 @@ function KPIDetailPage() {
|
||||||
mb={4}
|
mb={4}
|
||||||
>
|
>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<IconButton onClick={() => navigate({ to: "/config" })}>
|
<IconButton onClick={handleBack}>
|
||||||
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography variant="h5" fontWeight="bold" ml={3}>
|
<Typography variant="h5" fontWeight="bold" ml={3}>
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,29 @@ import { ConfigTable } from "../components/ConfigTable";
|
||||||
|
|
||||||
export const Route = createFileRoute("/config")({
|
export const Route = createFileRoute("/config")({
|
||||||
component: ConfigPage,
|
component: ConfigPage,
|
||||||
|
validateSearch: (search: Record<string, unknown>): { from?: string } => {
|
||||||
|
const from = typeof search.from === "string" ? search.from : undefined;
|
||||||
|
return { from };
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function ConfigPage() {
|
function ConfigPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { from } = Route.useSearch();
|
||||||
|
|
||||||
const handleAddNewKPI = () => {
|
const handleAddNewKPI = () => {
|
||||||
navigate({ to: "/config-add" });
|
navigate({
|
||||||
|
to: "/config-add",
|
||||||
|
search: from ? { from } : undefined
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (from === "pitchbooks") {
|
||||||
|
navigate({ to: "/pitchbooks" });
|
||||||
|
} else {
|
||||||
|
navigate({ to: "/" });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -34,7 +50,7 @@ function ConfigPage() {
|
||||||
px={4}
|
px={4}
|
||||||
>
|
>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<IconButton onClick={() => navigate({ to: "/" })}>
|
<IconButton onClick={handleBack}>
|
||||||
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<Typography variant="h5" fontWeight="bold" ml={3}>
|
<Typography variant="h5" fontWeight="bold" ml={3}>
|
||||||
|
|
@ -53,7 +69,7 @@ function ConfigPage() {
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ width: "100%", mt: 4, display: "flex", justifyContent: "center" }}>
|
<Box sx={{ width: "100%", mt: 4, display: "flex", justifyContent: "center" }}>
|
||||||
<ConfigTable />
|
<ConfigTable from={from} />
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import ContentPasteIcon from "@mui/icons-material/ContentPaste";
|
import ContentPasteIcon from "@mui/icons-material/ContentPaste";
|
||||||
import { Box, Button, Paper, Typography } from "@mui/material";
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||||
|
import { Box, Button, Paper, Typography, IconButton } from "@mui/material";
|
||||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
@ -9,6 +10,11 @@ import { kpiQueryOptions, settingsQueryOptions } from "../util/query";
|
||||||
|
|
||||||
export const Route = createFileRoute("/extractedResult/$pitchBook")({
|
export const Route = createFileRoute("/extractedResult/$pitchBook")({
|
||||||
component: ExtractedResultsPage,
|
component: ExtractedResultsPage,
|
||||||
|
validateSearch: (search: Record<string, unknown>): { from?: string } => {
|
||||||
|
return {
|
||||||
|
from: search.from as string | undefined,
|
||||||
|
};
|
||||||
|
},
|
||||||
loader: ({ context: { queryClient }, params: { pitchBook } }) =>
|
loader: ({ context: { queryClient }, params: { pitchBook } }) =>
|
||||||
Promise.allSettled([
|
Promise.allSettled([
|
||||||
queryClient.ensureQueryData(kpiQueryOptions(pitchBook)),
|
queryClient.ensureQueryData(kpiQueryOptions(pitchBook)),
|
||||||
|
|
@ -19,6 +25,7 @@ export const Route = createFileRoute("/extractedResult/$pitchBook")({
|
||||||
function ExtractedResultsPage() {
|
function ExtractedResultsPage() {
|
||||||
const { pitchBook } = Route.useParams();
|
const { pitchBook } = Route.useParams();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const { from } = Route.useSearch();
|
||||||
const status: "green" | "yellow" | "red" = "red";
|
const status: "green" | "yellow" | "red" = "red";
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
|
||||||
|
|
@ -34,6 +41,14 @@ function ExtractedResultsPage() {
|
||||||
return (
|
return (
|
||||||
<Box p={4}>
|
<Box p={4}>
|
||||||
<Box display="flex" alignItems="center" gap={3}>
|
<Box display="flex" alignItems="center" gap={3}>
|
||||||
|
{from === "overview" && (
|
||||||
|
<IconButton
|
||||||
|
onClick={() => navigate({ to: "/pitchbooks" })}
|
||||||
|
sx={{ ml: -1 }}
|
||||||
|
>
|
||||||
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
||||||
|
</IconButton>
|
||||||
|
)}
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: 45,
|
width: 45,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { Box, Typography, IconButton } from "@mui/material";
|
||||||
|
import ArrowBackIcon from "@mui/icons-material/ArrowBack";
|
||||||
|
import SettingsIcon from "@mui/icons-material/Settings";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
|
import { PitchBooksTable } from "../components/PitchBooksTable";
|
||||||
|
import { pitchBooksQueryOptions } from "../util/query";
|
||||||
|
|
||||||
|
export const Route = createFileRoute("/pitchbooks")({
|
||||||
|
component: PitchBooksPage,
|
||||||
|
loader: ({ context: { queryClient } }) =>
|
||||||
|
queryClient.ensureQueryData(pitchBooksQueryOptions()),
|
||||||
|
});
|
||||||
|
|
||||||
|
function PitchBooksPage() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
minHeight="100vh"
|
||||||
|
width="100vw"
|
||||||
|
bgcolor="white"
|
||||||
|
display="flex"
|
||||||
|
flexDirection="column"
|
||||||
|
alignItems="center"
|
||||||
|
pt={3}
|
||||||
|
pb={4}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
width="100%"
|
||||||
|
display="flex"
|
||||||
|
justifyContent="space-between"
|
||||||
|
alignItems="center"
|
||||||
|
px={4}
|
||||||
|
mb={4}
|
||||||
|
>
|
||||||
|
<Box display="flex" alignItems="center">
|
||||||
|
<IconButton onClick={() => navigate({ to: "/" })}>
|
||||||
|
<ArrowBackIcon fontSize="large" sx={{ color: '#383838' }}/>
|
||||||
|
</IconButton>
|
||||||
|
<Typography variant="h5" fontWeight="bold" ml={3}>
|
||||||
|
Übersicht aller Pitch Books
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<IconButton
|
||||||
|
onClick={() => navigate({
|
||||||
|
to: "/config",
|
||||||
|
search: { from: "pitchbooks" }
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<SettingsIcon fontSize="large" sx={{ color: '#383838' }} />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ width: "100%", display: "flex", justifyContent: "center" }}>
|
||||||
|
<PitchBooksTable />
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -107,3 +107,11 @@ export const fetchKennzahlen = async (): Promise<Kennzahl[]> => {
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
return data;
|
return data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function fetchPitchBooks() {
|
||||||
|
const response = await fetch("http://localhost:5050/api/pitch_book/");
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Failed to fetch pitch books");
|
||||||
|
}
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { queryOptions } from "@tanstack/react-query";
|
import { queryOptions } from "@tanstack/react-query";
|
||||||
import { fetchKPI, fetchKennzahlen } from "./api";
|
import { fetchKPI, fetchKennzahlen, fetchPitchBooks } from "./api";
|
||||||
|
|
||||||
export const kpiQueryOptions = (pitchBookId: string) =>
|
export const kpiQueryOptions = (pitchBookId: string) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
|
|
@ -12,3 +12,10 @@ export const settingsQueryOptions = () =>
|
||||||
queryKey: ["pitchBookSettings"],
|
queryKey: ["pitchBookSettings"],
|
||||||
queryFn: () => fetchKennzahlen(),
|
queryFn: () => fetchKennzahlen(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const pitchBooksQueryOptions = () =>
|
||||||
|
queryOptions({
|
||||||
|
queryKey: ["pitchBooks"],
|
||||||
|
queryFn: fetchPitchBooks,
|
||||||
|
staleTime: 30000,
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue