Skip to content

Commit 8e4ad34

Browse files
created view user button
1 parent 37b3956 commit 8e4ad34

3 files changed

Lines changed: 23 additions & 48 deletions

File tree

src/components/columns/UserCol.tsx

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { banUnban } from "@/api/ban";
1010
import toast from "react-hot-toast";
1111
import { Button } from "../ui/button";
1212
import BanBtn from "../banButton";
13+
import { UserModal } from "../table/user-modal";
1314

1415
const columns: ColumnDef<User>[] = [
1516
// {
@@ -87,29 +88,7 @@ const columns: ColumnDef<User>[] = [
8788
),
8889
cell: ({ row }) => <span>{row.getValue("PhoneNo")}</span>,
8990
},
90-
// {
91-
// accessorKey: "Role",
92-
// header: ({ column }) => <DataTableColumnHeader column={column} title="Role" />,
93-
// cell: ({ row }) => <span>{row.getValue("Role")}</span>,
94-
// },
95-
// {
96-
// accessorKey: "IsLeader",
97-
// header: ({ column }) => <DataTableColumnHeader column={column} title="Leader" />,
98-
// cell: ({ row }) => (
99-
// <Badge variant={row.getValue("IsLeader") ? "default" : "outline"}>
100-
// {row.getValue("IsLeader") ? "Yes" : "No"}
101-
// </Badge>
102-
// ),
103-
// // },
104-
// {
105-
// accessorKey: "IsVerified",
106-
// header: ({ column }) => <DataTableColumnHeader column={column} title="Verified" />,
107-
// cell: ({ row }) => (
108-
// <Badge variant={row.getValue("IsVerified") ? "default" : "outline"}>
109-
// {row.getValue("IsVerified") ? "Yes" : "No"}
110-
// </Badge>
111-
// ),
112-
// },
91+
11392
{
11493
accessorKey: "IsBanned",
11594
header: ({ column }) => (
@@ -119,6 +98,17 @@ const columns: ColumnDef<User>[] = [
11998
<BanBtn row={row}></BanBtn>
12099
),
121100
},
101+
{
102+
accessorKey: "ID",
103+
header: () => <p className="text-center">View</p>,
104+
cell: ({ row }) => {
105+
return (
106+
<div className="flex items-center justify-center">
107+
<UserModal user={row.original}></UserModal>
108+
</div>
109+
);
110+
},
111+
},
122112
// {
123113
// accessorKey: "IsProfileComplete",
124114
// header: ({ column }) => <DataTableColumnHeader column={column} title="Profile Complete" />,

src/components/login-form.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export function LoginForm({
3535
router.push("/users");
3636
}
3737
} catch (err) {
38-
console.error("Login failed", err);
38+
toast.error("Error logging you in")
39+
3940
} finally {
4041
setLoading(false); // Reset loading state after login attempt
4142
}

src/components/table/user-modal.tsx

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,17 @@ import { Toggle } from "@/components/ui/toggle";
1616
import { banUnban } from "@/api/ban";
1717

1818
interface TeamModalProps {
19-
open: boolean;
20-
onClose: () => void;
19+
2120
user: User;
2221
}
2322

24-
export const UserModal = ({ open, onClose, user }: TeamModalProps) => {
25-
const [isBanned, setIsBanned] = useState(user.IsBanned);
26-
const handleToggleBan =async (e: { preventDefault: () => void }) => {
27-
e.preventDefault();
28-
try {
29-
const response = await banUnban({ ban: !isBanned, email: user.Email });
30-
if (response.message === "success") {
31-
console.log("user is now " + !isBanned)
32-
setIsBanned(!isBanned);
33-
}
34-
} catch (err) {
35-
throw err;
36-
}
37-
};
23+
export const UserModal = ({ user }: TeamModalProps) => {
24+
3825
return (
39-
<Dialog open={open} onOpenChange={onClose}>
26+
<Dialog >
27+
<DialogTrigger asChild>
28+
<Button >View</Button>
29+
</DialogTrigger>
4030
<DialogContent className="sm:max-w-[600px]">
4131
<DialogHeader>
4232
<DialogTitle>User Details</DialogTitle>
@@ -117,13 +107,7 @@ export const UserModal = ({ open, onClose, user }: TeamModalProps) => {
117107
{user.IsProfileComplete ? "Yes" : "No"}
118108
</div>
119109
</div>
120-
<Toggle
121-
onClick={
122-
handleToggleBan}
123-
isBanned={isBanned}
124-
>
125-
{isBanned ? "Unban" : "Ban"}
126-
</Toggle>
110+
127111
</div>
128112
<div className="flex justify-end">
129113
<DialogClose asChild>

0 commit comments

Comments
 (0)