Skip to content

Commit

Permalink
feat-#178: enum added
Browse files Browse the repository at this point in the history
  • Loading branch information
devsharmag99 committed Jun 13, 2024
1 parent e3177a0 commit 5a19104
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions frontend/src/pages/admin-users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import { useEffect, useState } from 'react';
import { toast } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

interface User {
_id: string;
fullName: string;
role: 'ADMIN' | 'USER';
email: string;
}

enum role {
admin = 'ADMIN',
user = 'USER',
}

type User = {
_id: string;
fullName: string;
role: role;
email: string;
};

const AdminUsers = () => {
const [users, setUsers] = useState<User[]>([]);

Expand Down Expand Up @@ -64,15 +64,15 @@ const AdminUsers = () => {
{user?.email}
</p>
</div>
{user.role === 'ADMIN' && (
{user.role === role.admin && (
<button
onClick={() => handleClick(user._id, role.user)}
className="h-fit rounded-xl border border-black bg-black px-4 py-2 text-sm font-semibold text-white"
>
Admin
</button>
)}
{user.role === 'USER' && (
{user.role === role.user && (
<button
onClick={() => handleClick(user._id, role.admin)}
className="h-fit rounded-xl border border-black bg-transparent px-4 py-2 text-sm font-semibold text-white"
Expand Down

0 comments on commit 5a19104

Please sign in to comment.