Skip to content

Commit

Permalink
simplify user-management table
Browse files Browse the repository at this point in the history
  • Loading branch information
d-ivashchuk committed Apr 4, 2024
1 parent 22c67ac commit b0278b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
14 changes: 2 additions & 12 deletions src/app/(super-admin-routes)/user-management/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@
import React from "react";
import { UserTableProvider } from "~/components/patterns/data-table/data-table-provider";
import { UserTable } from "~/components/patterns/data-table/user-table/user-table";
import { searchParamsSchema } from "~/components/patterns/data-table/validations";

import { type SearchParams } from "~/types/data-table";

export interface UserManagementPageProps {
searchParams: SearchParams;
}

const UserManagement = ({ searchParams }: UserManagementPageProps) => {
const search = searchParamsSchema.parse(searchParams);
console.log({ parsedSearch: search, searchParams });

const UserManagement = () => {
return (
<div>
<h1 className="mb-4 text-2xl">User Management</h1>

<UserTableProvider>
<UserTable search={search} />
<UserTable />
</UserTableProvider>
</div>
);
Expand Down
16 changes: 8 additions & 8 deletions src/components/patterns/data-table/user-table/user-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ import {
filterableColumns,
} from "./user-table-columns";
import { TableSkeleton } from "../table-skeleton";
import { type z } from "zod";
import { type searchParamsSchema } from "../validations";

export function UserTable({
search,
}: {
search: z.infer<typeof searchParamsSchema>;
}) {
import { searchParamsSchema } from "../validations";
import { useSearchParams } from "next/navigation";

export function UserTable() {
const { enableAdvancedFilter } = useUserTable();
const searchParams = useSearchParams();

console.log({ search });
const search = searchParamsSchema.parse(
Object.fromEntries(searchParams.entries()),
);

const { data, isLoading } = api.superAdmin.getUserData.useQuery(
{
Expand Down

0 comments on commit b0278b7

Please sign in to comment.