Skip to content

Commit

Permalink
Admin Promotion Removal
Browse files Browse the repository at this point in the history
  • Loading branch information
roshanbellary committed Jan 17, 2025
1 parent a5499ed commit bc46568
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
30 changes: 8 additions & 22 deletions client/src/Home/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
toggleAdmin,
selectUser,
} from '../util/redux/userSlice.ts';
import { logout as logoutApi, selfUpgrade } from './api.tsx';
import { logout as logoutApi } from './api.tsx';
import ScreenGrid from '../components/ScreenGrid.tsx';
import PrimaryButton from '../components/buttons/PrimaryButton.tsx';

Expand Down Expand Up @@ -78,13 +78,13 @@ function HomePage() {
}
};

const handleSelfPromote = async () => {
const newAdminStatus = await selfUpgrade(user.email as string);
if (newAdminStatus) {
dispatch(toggleAdmin());
setAdmin(true);
}
};
// const handleSelfPromote = async () => {
// const newAdminStatus = await selfUpgrade(user.email as string);
// if (newAdminStatus) {
// dispatch(toggleAdmin());
// setAdmin(true);
// }
// };

const message = `Welcome to Catalyst Kitchens, ${user.firstName} ${user.lastName}!`;

Expand Down Expand Up @@ -205,20 +205,6 @@ function HomePage() {
</Typography>
</Grid>

{/* Promote Button or Admin Actions */}
<Grid
item
container
justifyContent="center"
sx={{ marginBottom: '20px' }}
>
<PromoteButton
admin={admin}
handleSelfPromote={handleSelfPromote}
navigator={navigator}
/>
</Grid>

{/* Logout Button */}
<Grid item container justifyContent="center">
<PrimaryButton
Expand Down
12 changes: 6 additions & 6 deletions client/src/Home/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ async function logout() {
* @returns true if successful, false otherwise
* PLEASE REMOVE THIS FUNCTION AND BACKEND ENDPOINT UPON DEPLOYMENT
*/
async function selfUpgrade(email: string) {
const res = await putData('admin/autopromote', { email });
if (res.error) return false;
return true;
}
// async function selfUpgrade(email: string) {
// const res = await putData('admin/autopromote', { email });
// if (res.error) return false;
// return true;
// }

// eslint-disable-next-line import/prefer-default-export
export { logout, selfUpgrade };
export { logout };

0 comments on commit bc46568

Please sign in to comment.