Fixed multiple values being the same logic error.
parent
d8342304c1
commit
b3805b2afe
|
|
@ -50,7 +50,7 @@ function ExtractedResultsPage() {
|
|||
sx={{
|
||||
width: "100vw",
|
||||
maxWidth: "100%",
|
||||
height: "80vh",
|
||||
height: "85vh",
|
||||
mt: 4,
|
||||
}}
|
||||
>
|
||||
|
|
@ -76,10 +76,9 @@ function ExtractedResultsPage() {
|
|||
display="flex"
|
||||
flexDirection="column"
|
||||
justifyContent="space-between"
|
||||
gap={5}
|
||||
gap={3}
|
||||
sx={{
|
||||
width: "55%",
|
||||
height: "100%",
|
||||
maxHeight: "95%"
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ function ExtractedResultsPage() {
|
|||
} = useSuspenseQuery(kpiQueryOptions(pitchBook));
|
||||
|
||||
const kpiValues = kpiData[kpi.toUpperCase()] || [];
|
||||
|
||||
const [selectedValue, setSelectedValue] = useState(kpiValues[0]?.entity || '');
|
||||
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);
|
||||
|
|
@ -78,8 +78,11 @@ function ExtractedResultsPage() {
|
|||
|
||||
const handleRadioChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.target.value;
|
||||
setSelectedValue(value);
|
||||
if (value !== 'custom') {
|
||||
if (value === 'custom') {
|
||||
setSelectedIndex(-1);
|
||||
} else {
|
||||
const index = parseInt(value);
|
||||
setSelectedIndex(index);
|
||||
setCustomValue('');
|
||||
}
|
||||
};
|
||||
|
|
@ -87,7 +90,12 @@ function ExtractedResultsPage() {
|
|||
const handleCustomValueChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = event.target.value;
|
||||
setCustomValue(value);
|
||||
setSelectedValue(value);
|
||||
setSelectedIndex(-1);
|
||||
};
|
||||
|
||||
const handleRowClick = (index: number) => {
|
||||
setSelectedIndex(index);
|
||||
setCustomValue('');
|
||||
};
|
||||
|
||||
const handleBackClick = () => {
|
||||
|
|
@ -134,7 +142,7 @@ function ExtractedResultsPage() {
|
|||
sx={{
|
||||
width: "100vw",
|
||||
maxWidth: "100%",
|
||||
height: "80vh",
|
||||
height: "85vh",
|
||||
mt: 4,
|
||||
}}
|
||||
>
|
||||
|
|
@ -170,7 +178,7 @@ function ExtractedResultsPage() {
|
|||
'&:hover': { backgroundColor: '#f9f9f9' },
|
||||
cursor: 'pointer'
|
||||
}}
|
||||
onClick={() => setSelectedValue(item.entity)}
|
||||
onClick={() => handleRowClick(index)}
|
||||
>
|
||||
<TableCell>
|
||||
<Box
|
||||
|
|
@ -187,8 +195,8 @@ function ExtractedResultsPage() {
|
|||
}}
|
||||
>
|
||||
<Radio
|
||||
value={item.entity}
|
||||
checked={selectedValue === item.entity}
|
||||
value={index.toString()}
|
||||
checked={selectedIndex === index}
|
||||
onChange={handleRadioChange}
|
||||
sx={{
|
||||
color: '#383838',
|
||||
|
|
@ -232,14 +240,12 @@ function ExtractedResultsPage() {
|
|||
}
|
||||
}}
|
||||
onClick={() => {
|
||||
if (customValue) {
|
||||
setSelectedValue(customValue);
|
||||
}
|
||||
setSelectedIndex(-1);
|
||||
}}
|
||||
>
|
||||
<Radio
|
||||
value={customValue}
|
||||
checked={selectedValue === customValue && customValue !== ''}
|
||||
value="custom"
|
||||
checked={selectedIndex === -1 && customValue !== ''}
|
||||
onChange={handleRadioChange}
|
||||
sx={{
|
||||
color: '#383838',
|
||||
|
|
@ -280,7 +286,7 @@ function ExtractedResultsPage() {
|
|||
display="flex"
|
||||
flexDirection="column"
|
||||
justifyContent="space-between"
|
||||
gap={5}
|
||||
gap={3}
|
||||
sx={{ width: "55%", height: "95%" }}
|
||||
>
|
||||
<Paper
|
||||
|
|
@ -311,9 +317,7 @@ function ExtractedResultsPage() {
|
|||
sx={{
|
||||
backgroundColor: '#383838',
|
||||
'&:hover': { backgroundColor: '#2e2e2e' },
|
||||
'&.Mui-disabled': { backgroundColor: '#ccc' },
|
||||
px: 4,
|
||||
py: 1.5
|
||||
'&.Mui-disabled': { backgroundColor: '#ccc' }
|
||||
}}
|
||||
>
|
||||
Überprüfung Annehmen
|
||||
|
|
|
|||
Loading…
Reference in New Issue