Added state setting of default index

This commit is contained in:
Khalim Conn-Kowlessar 2023-07-27 19:01:16 +01:00
parent ac6ecf3299
commit e4f29efbd2

View file

@ -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 (