diff --git a/components/konstitisyon/create/handle-create.js b/components/konstitisyon/create/handle-create.js index 4bfd525..4f4cc21 100644 --- a/components/konstitisyon/create/handle-create.js +++ b/components/konstitisyon/create/handle-create.js @@ -22,7 +22,7 @@ export default function HandleCreate({ useEffect(() => { if (listItems && listItems.length > 0) { - setSelectValue(listItems[0].id) + setSelectValue(listItems.at(-1).id) } }, [listItems]) @@ -142,6 +142,7 @@ export default function HandleCreate({ collection={collection} listItems={listItems} handleFormSubmit={handleFormSubmit} + selectValue={selectValue} setSelectValue={setSelectValue} title='Article' dialogText='Écrivez votre article' diff --git a/components/konstitisyon/create/list-items.js b/components/konstitisyon/create/list-items.js index 6e88a88..5063b04 100644 --- a/components/konstitisyon/create/list-items.js +++ b/components/konstitisyon/create/list-items.js @@ -4,7 +4,7 @@ import InputLabel from '@mui/material/InputLabel' import FormControl from '@mui/material/FormControl' import NativeSelect from '@mui/material/NativeSelect' -export default function ListItems({items, selectLabel, setSelectValue}) { +export default function ListItems({items, selectLabel, selectValue, setSelectValue}) { const handleChange = event => { setSelectValue(event.target.value) } @@ -16,7 +16,7 @@ export default function ListItems({items, selectLabel, setSelectValue}) { {selectLabel} )} @@ -94,6 +96,7 @@ FormHandler.propTypes = { setError: PropTypes.func.isRequired, setIsErrorAlertOpen: PropTypes.func.isRequired, handleFormSubmit: PropTypes.func.isRequired, + selectValue: PropTypes.string, setSelectValue: PropTypes.func.isRequired, dialogText: PropTypes.string.isRequired, title: PropTypes.string.isRequired,