Fixed multiple values being the same logic error.

pull/61/head
s8613 2025-06-13 12:50:27 +02:00
parent d8342304c1
commit b3805b2afe
2 changed files with 24 additions and 21 deletions

View File

@ -50,7 +50,7 @@ function ExtractedResultsPage() {
sx={{ sx={{
width: "100vw", width: "100vw",
maxWidth: "100%", maxWidth: "100%",
height: "80vh", height: "85vh",
mt: 4, mt: 4,
}} }}
> >
@ -76,10 +76,9 @@ function ExtractedResultsPage() {
display="flex" display="flex"
flexDirection="column" flexDirection="column"
justifyContent="space-between" justifyContent="space-between"
gap={5} gap={3}
sx={{ sx={{
width: "55%", width: "55%",
height: "100%",
maxHeight: "95%" maxHeight: "95%"
}} }}
> >

View File

@ -41,13 +41,13 @@ function ExtractedResultsPage() {
} = useSuspenseQuery(kpiQueryOptions(pitchBook)); } = useSuspenseQuery(kpiQueryOptions(pitchBook));
const kpiValues = kpiData[kpi.toUpperCase()] || []; const kpiValues = kpiData[kpi.toUpperCase()] || [];
const [selectedIndex, setSelectedIndex] = useState(0);
const [selectedValue, setSelectedValue] = useState(kpiValues[0]?.entity || '');
const [currentPage, setCurrentPage] = useState(kpiValues[0]?.page || 1); const [currentPage, setCurrentPage] = useState(kpiValues[0]?.page || 1);
const [showConfirmDialog, setShowConfirmDialog] = useState(false); const [showConfirmDialog, setShowConfirmDialog] = useState(false);
const [hasChanges, setHasChanges] = useState(false); const [hasChanges, setHasChanges] = useState(false);
const [customValue, setCustomValue] = useState(''); const [customValue, setCustomValue] = useState('');
const originalValue = kpiValues[0]?.entity || ''; const originalValue = kpiValues[0]?.entity || '';
const selectedValue = selectedIndex === -1 ? customValue : (kpiValues[selectedIndex]?.entity || '');
useEffect(() => { useEffect(() => {
setHasChanges(selectedValue !== originalValue); setHasChanges(selectedValue !== originalValue);
@ -78,8 +78,11 @@ function ExtractedResultsPage() {
const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.target.value; const value = event.target.value;
setSelectedValue(value); if (value === 'custom') {
if (value !== 'custom') { setSelectedIndex(-1);
} else {
const index = parseInt(value);
setSelectedIndex(index);
setCustomValue(''); setCustomValue('');
} }
}; };
@ -87,7 +90,12 @@ function ExtractedResultsPage() {
const handleCustomValueChange = (event: React.ChangeEvent<HTMLInputElement>) => { const handleCustomValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const value = event.target.value; const value = event.target.value;
setCustomValue(value); setCustomValue(value);
setSelectedValue(value); setSelectedIndex(-1);
};
const handleRowClick = (index: number) => {
setSelectedIndex(index);
setCustomValue('');
}; };
const handleBackClick = () => { const handleBackClick = () => {
@ -134,7 +142,7 @@ function ExtractedResultsPage() {
sx={{ sx={{
width: "100vw", width: "100vw",
maxWidth: "100%", maxWidth: "100%",
height: "80vh", height: "85vh",
mt: 4, mt: 4,
}} }}
> >
@ -170,7 +178,7 @@ function ExtractedResultsPage() {
'&:hover': { backgroundColor: '#f9f9f9' }, '&:hover': { backgroundColor: '#f9f9f9' },
cursor: 'pointer' cursor: 'pointer'
}} }}
onClick={() => setSelectedValue(item.entity)} onClick={() => handleRowClick(index)}
> >
<TableCell> <TableCell>
<Box <Box
@ -187,8 +195,8 @@ function ExtractedResultsPage() {
}} }}
> >
<Radio <Radio
value={item.entity} value={index.toString()}
checked={selectedValue === item.entity} checked={selectedIndex === index}
onChange={handleRadioChange} onChange={handleRadioChange}
sx={{ sx={{
color: '#383838', color: '#383838',
@ -232,14 +240,12 @@ function ExtractedResultsPage() {
} }
}} }}
onClick={() => { onClick={() => {
if (customValue) { setSelectedIndex(-1);
setSelectedValue(customValue);
}
}} }}
> >
<Radio <Radio
value={customValue} value="custom"
checked={selectedValue === customValue && customValue !== ''} checked={selectedIndex === -1 && customValue !== ''}
onChange={handleRadioChange} onChange={handleRadioChange}
sx={{ sx={{
color: '#383838', color: '#383838',
@ -280,7 +286,7 @@ 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%", height: "95%" }}
> >
<Paper <Paper
@ -311,9 +317,7 @@ function ExtractedResultsPage() {
sx={{ sx={{
backgroundColor: '#383838', backgroundColor: '#383838',
'&:hover': { backgroundColor: '#2e2e2e' }, '&:hover': { backgroundColor: '#2e2e2e' },
'&.Mui-disabled': { backgroundColor: '#ccc' }, '&.Mui-disabled': { backgroundColor: '#ccc' }
px: 4,
py: 1.5
}} }}
> >
Überprüfung Annehmen Überprüfung Annehmen