Skip to content

Commit

Permalink
#46
Browse files Browse the repository at this point in the history
  • Loading branch information
rickyraup committed Jan 12, 2023
1 parent 1fa2a71 commit ee9cf94
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client/src/AdminDashboard/EnableUserSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import Switch from '@mui/material/Switch';
import useAlert from '../util/hooks/useAlert';

interface EnableUserSwitchProps {
admin: boolean;
Expand All @@ -18,8 +19,14 @@ interface EnableUserSwitchProps {
*/
function EnableUserSwitch({ admin, email, enableUser }: EnableUserSwitchProps) {
const [checked, setChecked] = useState(true);
const { setAlert } = useAlert();

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (checked) {
setAlert('User Disabled', 'success');
} else {
setAlert('User Enabled', 'success');
}
setChecked(event.target.checked);
enableUser(email);
};
Expand Down

0 comments on commit ee9cf94

Please sign in to comment.