Skip to content

Commit

Permalink
Rename variables to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
samau3 committed Oct 20, 2024
1 parent 318df73 commit 92184ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ export default function HealthcareChoicesSearch({ form, choice, initialData }) {
{choice === 'physician' && (
<RegisterPhysician
setPhysician={handleSelectValue}
opened={registerPhysicianOpened}
close={closeRegisterPhysician}
registerPhysicianOpened={registerPhysicianOpened}
closeRegisterPhysician={closeRegisterPhysician}
fetchOptions={fetchOptions}
/>
)}
Expand Down
26 changes: 15 additions & 11 deletions client/src/pages/patients/register/inputs/RegisterPhysician.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { StatusCodes } from 'http-status-codes';

const registerPhysicianProps = {
setPhysician: PropTypes.func.isRequired,
opened: PropTypes.bool.isRequired,
close: PropTypes.func.isRequired,
registerPhysicianOpened: PropTypes.bool.isRequired,
closeRegisterPhysician: PropTypes.func.isRequired,
fetchOptions: PropTypes.func.isRequired,
};

Expand All @@ -29,8 +29,8 @@ const registerPhysicianProps = {
*/
export default function RegisterPhysician({
setPhysician,
opened,
close,
registerPhysicianOpened,
closeRegisterPhysician,
fetchOptions,
}) {
const [
Expand Down Expand Up @@ -62,7 +62,11 @@ export default function RegisterPhysician({
},
});

const { error, reset, mutateAsync } = useMutation({
const {
error,
reset: mutationReset,
mutateAsync,
} = useMutation({
mutationKey: ['physician'],
mutationFn: async (data) => {
const res = await LifelineAPI.registerPhysician(data);
Expand All @@ -81,10 +85,10 @@ export default function RegisterPhysician({
const { firstName, middleName, lastName } = result;
const fullName = `${firstName}${middleName ? ' ' + middleName + ' ' : ' '}${lastName}`;
setPhysician(result.id, fullName);
form.reset();
reset();
close();
fetchOptions(fullName);
form.reset();
mutationReset();
closeRegisterPhysician();
} catch (error) {
console.error(error.message);
}
Expand All @@ -94,19 +98,19 @@ export default function RegisterPhysician({
if (form.isDirty() && confirmed) {
closeConfirmationModal();
form.reset();
reset();
mutationReset();
}
if (form.isDirty()) {
openConfirmationModal();
} else {
close();
closeRegisterPhysician();
}
};

return (
<>
<Modal
opened={opened}
opened={registerPhysicianOpened}
onClose={confirmClose}
title="Register a new physician"
>
Expand Down

0 comments on commit 92184ca

Please sign in to comment.