@@ -120,101 +63,116 @@ export default function BasicTableOne() {
{/* Table Header */}
-
- User
+
+ onSort("display_name")}>
+ Người dùng
+
+
-
- Project Name
+
+
+ onSort("email")}>
+ Email
+
+
-
- Team
+
+
+ Vai trò (Role)
-
- Status
+
+
+ Trạng thái
-
- Budget
+
+
+ onSort("created_at")}>
+ Ngày tham gia
+
+
+
+
+ {/* Thêm cột Ngày cập nhật */}
+
+ onSort("updated_at")}>
+ Cập nhật lần cuối
+
+
{/* Table Body */}
- {tableData.map((order) => (
-
+ {data.map((user) => (
+
+
+ {/* Cột User */}
-
-
+
+ {user.profile?.avatar_url ? (
+
+ ) : (
+
+ {user.profile?.display_name?.charAt(0) || "U"}
+
+ )}
- {order.user.name}
-
-
- {order.user.role}
+ {user.profile?.display_name || "Chưa cập nhật tên"}
+ {user.profile?.phone && (
+
+ {user.profile.phone}
+
+ )}
+
+ {/* Cột Email */}
- {order.projectName}
+ {user.email}
+
+ {/* Cột Roles */}
-
- {order.team.images.map((teamImage, index) => (
-
-
-
- ))}
-
+ {user.roles && user.roles.length > 0 ? (
+ user.roles.map((role: any) => (
+
+ {role.name}
+
+ ))
+ ) : (
+ Chưa cấp quyền
+ )}
+
+ {/* Cột Trạng thái */}
-
- {order.status}
+
+ {user.is_deleted ? "Bị khóa" : "Hoạt động"}
+
+ {/* Cột Ngày tham gia */}
- {order.budget}
+ {formatDate(user.created_at)}
+
+ {/* Cột Ngày cập nhật */}
+
+ {formatDate(user.updated_at)}
+
+
))}
@@ -223,4 +181,4 @@ export default function BasicTableOne() {
);
-}
+}
\ No newline at end of file
diff --git a/src/interface/admin.ts b/src/interface/admin.ts
new file mode 100644
index 0000000..5f6659b
--- /dev/null
+++ b/src/interface/admin.ts
@@ -0,0 +1,26 @@
+import { Profile, UserRole } from "@/interface/user";
+
+export interface getUserDto {
+ cursor?: string;
+ limit: number;
+ is_deleted?: boolean;
+ order?: "asc" | "desc";
+ role_ids?: string[];
+ search?: string;
+ sort?: "created_at" | "updated_at" | "display_name" | "email";
+}
+
+export interface fullDataUser {
+ auth_provider: string;
+ id: string;
+ email: string;
+ google_id: string;
+ display_name: string;
+ created_at: string;
+ updated_at: string;
+ is_deleted: boolean;
+ password_hash: string;
+ roles: UserRole[];
+ profile: Profile;
+ token_version: number;
+}
\ No newline at end of file
diff --git a/src/layout/AppSidebar.tsx b/src/layout/AppSidebar.tsx
index b610ed4..8f309f9 100644
--- a/src/layout/AppSidebar.tsx
+++ b/src/layout/AppSidebar.tsx
@@ -1,5 +1,5 @@
"use client";
-import React, { useEffect, useRef, useState,useCallback } from "react";
+import React, { useEffect, useRef, useState, useCallback } from "react";
import Link from "next/link";
import Image from "next/image";
import { usePathname } from "next/navigation";
@@ -51,7 +51,10 @@ const navItems: NavItem[] = [
{
name: "Tables",
icon:
,
- subItems: [{ name: "Basic Tables", path: "/basic-tables", pro: false }],
+ subItems: [
+ { name: "Basic Tables", path: "/basic-tables", pro: false },
+ { name: "User Tables", path: "/user-table", pro: false },
+ ],
},
{
name: "Pages",
@@ -100,7 +103,7 @@ const AppSidebar: React.FC = () => {
const renderMenuItems = (
navItems: NavItem[],
- menuType: "main" | "others"
+ menuType: "main" | "others",
) => (
{navItems.map((nav, index) => (
@@ -229,12 +232,12 @@ const AppSidebar: React.FC = () => {
index: number;
} | null>(null);
const [subMenuHeight, setSubMenuHeight] = useState>(
- {}
+ {},
);
const subMenuRefs = useRef>({});
// const isActive = (path: string) => path === pathname;
- const isActive = useCallback((path: string) => path === pathname, [pathname]);
+ const isActive = useCallback((path: string) => path === pathname, [pathname]);
useEffect(() => {
// Check if the current path matches any submenu item
@@ -260,7 +263,7 @@ const AppSidebar: React.FC = () => {
if (!submenuMatched) {
setOpenSubmenu(null);
}
- }, [pathname,isActive]);
+ }, [pathname, isActive]);
useEffect(() => {
// Set the height of the submenu items when the submenu is opened
@@ -295,8 +298,8 @@ const AppSidebar: React.FC = () => {
isExpanded || isMobileOpen
? "w-[290px]"
: isHovered
- ? "w-[290px]"
- : "w-[90px]"
+ ? "w-[290px]"
+ : "w-[90px]"
}
${isMobileOpen ? "translate-x-0" : "-translate-x-full"}
lg:translate-x-0`}
diff --git a/src/service/adminService.ts b/src/service/adminService.ts
new file mode 100644
index 0000000..918f914
--- /dev/null
+++ b/src/service/adminService.ts
@@ -0,0 +1,10 @@
+import api from "@/config/config";
+import { API } from "../../api";
+import { getUserDto } from "@/interface/admin";
+
+export const apiGetListUser = async (payload: getUserDto) => {
+ const response = await api.get(API.Admin.GET_LIST_USERS, {
+ params: payload,
+ });
+ return response?.data;
+};