Skip to content

Commit

Permalink
fixed button + added disabled function
Browse files Browse the repository at this point in the history
  • Loading branch information
hams7504 committed Sep 6, 2023
1 parent 6ae56a4 commit c329c0b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/pages/user_profile/RequestRole.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function RequestRole(props) {
}
];

const [hasSupportRequests, setHasSupportRequests] = useState(false);
const [supportRequests, setSupportRequests] = useState({
checkRegisterDataset: false,
checkRequestDataAccess: false,
Expand All @@ -47,6 +48,8 @@ export default function RequestRole(props) {
const handleSupportRequestsChange = ({ key, value }) => {
let newSupportRequests = Object.assign({}, supportRequests, { [key]: value });
setSupportRequests(newSupportRequests);
const hasAnyRequests = possibleSupportRequests.some(request => newSupportRequests[request.key]);
setHasSupportRequests(hasAnyRequests);
};

const submitForm = async (event) => {
Expand Down Expand Up @@ -160,20 +163,19 @@ export default function RequestRole(props) {
</div>
<button
id='btn_save'
onClick={submitForm}
className='f-left btn-primary common-background'
style={{
marginTop: '50px',
}}>
onClick={goToPrevPage}
className='f-left btn-primary btn-back'
style={{ marginTop: '50px' }}>
Back
</button>
<button
id='btn_save'
onClick={goToPrevPage}
className='f-right btn-primary btn-back'
onClick={submitForm}
className='f-right btn-primary common-background'
style={{
marginTop: '50px',
}}>
}}
disabled={!hasSupportRequests}>
Submit
</button>
</div>;
Expand Down

0 comments on commit c329c0b

Please sign in to comment.