mirror of
https://github.com/Hestia-Homes/assessment-model.git
synced 2026-06-08 11:37:25 +00:00
Added state setting of default index
This commit is contained in:
parent
ac6ecf3299
commit
e4f29efbd2
1 changed files with 5 additions and 1 deletions
|
|
@ -56,7 +56,9 @@ export function RecommendationModal({
|
|||
const [saveButtonDisabled, setSaveButtonDisabled] = useState(true);
|
||||
|
||||
// Find the row where default is true
|
||||
const defaultRowIndex = recommendationData.findIndex((d) => d.default);
|
||||
const [defaultRowIndex, setDefaultRowIndex] = useState(
|
||||
recommendationData.findIndex((d) => d.default)
|
||||
);
|
||||
|
||||
// Initialise the state with the default row index
|
||||
const [rowSelection, setRowSelection] = useState(
|
||||
|
|
@ -78,6 +80,8 @@ export function RecommendationModal({
|
|||
const newIndex = parseInt(Object.keys(rowSelection)[0]);
|
||||
|
||||
setCardComponent(recommendationData[newIndex]);
|
||||
// Set the default index
|
||||
setDefaultRowIndex(newIndex);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue