Skip to content

Commit

Permalink
add users panel
Browse files Browse the repository at this point in the history
  • Loading branch information
shadrach-tayo committed Jan 15, 2025
1 parent fc6e0ce commit b77983f
Show file tree
Hide file tree
Showing 13 changed files with 429 additions and 1,023 deletions.
15 changes: 0 additions & 15 deletions src/app/(auth)/communities/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
import Communities from "@/components/organisms/Communities";
// import { ApiResponse, Community } from "@/lib/api";
// import { NODES_API_URL } from "@/lib/config";
// import { cookies } from "next/headers";

export default async function CommunityPage() {
// const cookie = cookies().getAll();
// console.log('cookies', cookie)
// const response = await fetch(`${NODES_API_URL}/v1/admin/communities`, {
// headers: { 'cookie': cookies().toString()},
// credentials: "include",
// });
// console.log("get list", response.ok, response.status);
// // if (response.ok) {
// const json = (await response.json()) as ApiResponse<Community[]>;
// const data = json.data;

// console.log('COMMUNITY', data )
return <Communities />;
}
29 changes: 17 additions & 12 deletions src/app/(auth)/users/page.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
"use client";
import { DataTable } from "@/components/organisms/users-datatable/data-table";
import { tasks } from "@/components/organisms/users-datatable/data/tasks";
import { users } from "@/components/organisms/users-datatable/data/users";
import { columns } from "@/components/organisms/users-datatable/columns";
import { searchUsers } from "@/lib/api";
import { useQuery } from "@tanstack/react-query";
import { getQueryClient } from "@/lib/get-query-client";
import { LoaderCircleIcon } from "lucide-react";

interface User {
id: string;
name: string;
email: string;
}
const mockUsers: User[] = [
{ id: "1", name: "John Doe", email: "john@example.com" },
{ id: "2", name: "Jane Smith", email: "jane@example.com" },
];
const queryClient = getQueryClient();

export default function UsersTable() {
const { data, isLoading, error } = useQuery(searchUsers, queryClient);

return (
<>
<div className="mb-2 flex items-center justify-between space-y-2">
<div>
<h2 className="text-2xl font-bold tracking-tight">Welcome back!</h2>
<p className="text-muted-foreground">
Here&apos;s a list of your tasks for this month!
Here&apos;s a list of your users on nodes platform
</p>
</div>
</div>
<div className="-mx-4 flex-1 overflow-auto px-4 py-1 lg:flex-row lg:space-x-12 lg:space-y-0">
<DataTable data={tasks} columns={columns} />
{isLoading ? (
<div className="">
<LoaderCircleIcon className="w-18 h-18" />
</div>
) : (
<DataTable data={data?.data?.data ?? []} columns={columns} />
)}
</div>
</>
);
Expand Down
6 changes: 0 additions & 6 deletions src/app/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ export async function login(prevState: any, formData: FormData) {
const email = formData.get("email") ?? prevState?.email;
const code = formData.get("code");

if (!email?.endsWith("@desci.com"))
return {
ok: false,
error: "Unauthorised email domain (only desci.com emails are allowed)",
};

const res = await fetch(`${API_URL}/v1/auth/magic`, {
method: "POST",
body: JSON.stringify({ email, code }),
Expand Down
4 changes: 2 additions & 2 deletions src/components/molecules/CommunityMembers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
CommandList,
} from "@/components/ui/command";
import { Check, ChevronsUpDown, X, Settings } from "lucide-react";
import { addMember, Community, removeMember, searchUsers } from "@/lib/api";
import { addMember, Community, removeMember, searchUsers, searchUsersProfiles } from "@/lib/api";
import { useMutation, useQuery } from "@tanstack/react-query";
import { getQueryClient } from "@/lib/get-query-client";
import { tags } from "@/lib/tags";
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function CommunityMembers({
const { mutate } = useMutation(
{
mutationKey: [tags.users],
mutationFn: searchUsers,
mutationFn: searchUsersProfiles,
},
queryClient
);
Expand Down
94 changes: 47 additions & 47 deletions src/components/organisms/community-datatable/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,23 @@ export const columns: ColumnDef<Community>[] = [
},
enableSorting: false,
},
{
accessorKey: "description",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Description" />
),
cell: ({ row }) => {
const label = row.original.description;
// {
// accessorKey: "description",
// header: ({ column }) => (
// <DataTableColumnHeader column={column} title="Description" />
// ),
// cell: ({ row }) => {
// const label = row.original.description;

return (
<div className="flex space-x-2">
<span className="max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]">
{label}
</span>
</div>
);
},
},
// return (
// <div className="flex space-x-2">
// <span className="max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]">
// {label}
// </span>
// </div>
// );
// },
// },
{
accessorKey: "keywords",
header: ({ column }) => (
Expand Down Expand Up @@ -200,22 +200,22 @@ export const columns: ColumnDef<Community>[] = [
enableSorting: false,
// enableResizing: true,
},
{
accessorKey: "image_url",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Image url" />
),
cell: ({ row }) => {
return (
<div className="flex space-x-2">
<span className="max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]">
{row.getValue("image_url")}
</span>
</div>
);
},
enableSorting: false,
},
// {
// accessorKey: "image_url",
// header: ({ column }) => (
// <DataTableColumnHeader column={column} title="Image url" />
// ),
// cell: ({ row }) => {
// return (
// <div className="flex space-x-2">
// <span className="max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]">
// {row.getValue("image_url")}
// </span>
// </div>
// );
// },
// enableSorting: false,
// },
{
accessorKey: "createdAt",
header: ({ column }) => (
Expand All @@ -231,21 +231,21 @@ export const columns: ColumnDef<Community>[] = [
);
},
},
{
accessorKey: "updatedAt",
header: ({ column }) => (
<DataTableColumnHeader column={column} title="Last Updated" />
),
cell: ({ row }) => {
return (
<div className="flex space-x-2">
<span className="max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]">
{row.getValue("updatedAt")}
</span>
</div>
);
},
},
// {
// accessorKey: "updatedAt",
// header: ({ column }) => (
// <DataTableColumnHeader column={column} title="Last Updated" />
// ),
// cell: ({ row }) => {
// return (
// <div className="flex space-x-2">
// <span className="max-w-32 truncate font-medium sm:max-w-72 md:max-w-[31rem]">
// {row.getValue("updatedAt")}
// </span>
// </div>
// );
// },
// },
{
id: "actions",
cell: ({ row }) => <DataTableRowActions row={row} />,
Expand Down
Loading

0 comments on commit b77983f

Please sign in to comment.