s
This commit is contained in:
parent
e1121da7b9
commit
abf15a7a7d
@ -28,6 +28,8 @@ export async function GET(request: Request) {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
|
console.log("[Users] - data FROM ROUTE", data);
|
||||||
|
|
||||||
return NextResponse.json(data, { status: response.status });
|
return NextResponse.json(data, { status: response.status });
|
||||||
} catch (err: unknown) {
|
} catch (err: unknown) {
|
||||||
console.error("Proxy GET /api/v1/users/list error:", err);
|
console.error("Proxy GET /api/v1/users/list error:", err);
|
||||||
|
|||||||
@ -15,7 +15,6 @@ interface IPageLinksProps extends ISidebarLink {
|
|||||||
// PageLinks component
|
// PageLinks component
|
||||||
export default function PageLinks({ title, path, icon }: IPageLinksProps) {
|
export default function PageLinks({ title, path, icon }: IPageLinksProps) {
|
||||||
const Icon = resolveIcon(icon);
|
const Icon = resolveIcon(icon);
|
||||||
console.log("Icon", Icon);
|
|
||||||
return (
|
return (
|
||||||
<Link href={path} className={clsx("page-link", "page-link__container")}>
|
<Link href={path} className={clsx("page-link", "page-link__container")}>
|
||||||
{Icon && <Icon />}
|
{Icon && <Icon />}
|
||||||
|
|||||||
@ -151,8 +151,6 @@ export default function AuditTableClient({
|
|||||||
|
|
||||||
const loading = isNavigating;
|
const loading = isNavigating;
|
||||||
|
|
||||||
console.log("LOADING", loading);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="audits-page">
|
<div className="audits-page">
|
||||||
<Box sx={{ display: "flex", gap: 2, mt: 5 }}>
|
<Box sx={{ display: "flex", gap: 2, mt: 5 }}>
|
||||||
|
|||||||
@ -230,7 +230,6 @@ export const addUser = createAsyncThunk<
|
|||||||
try {
|
try {
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const currentUserId = state.auth.user?.id;
|
const currentUserId = state.auth.user?.id;
|
||||||
console.log("[DEBUG] [ADD-USER] [currentUserId]: ", currentUserId);
|
|
||||||
const res = await fetch("/api/auth/register", {
|
const res = await fetch("/api/auth/register", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
@ -239,8 +238,6 @@ export const addUser = createAsyncThunk<
|
|||||||
|
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
console.log("[DEBUG] [ADD-USER] [data]: ", data);
|
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
return rejectWithValue(data.message || "Failed to create user");
|
return rejectWithValue(data.message || "Failed to create user");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,17 @@ import {
|
|||||||
USERS_CACHE_TAG,
|
USERS_CACHE_TAG,
|
||||||
} from "./constants";
|
} from "./constants";
|
||||||
|
|
||||||
export async function fetchUsers(): Promise<IUser[]> {
|
const DEFAULT_PAGE_SIZE = 25;
|
||||||
|
|
||||||
|
interface FetchUsersParams {
|
||||||
|
limit?: number;
|
||||||
|
page?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchUsers({
|
||||||
|
limit = DEFAULT_PAGE_SIZE,
|
||||||
|
page = 1,
|
||||||
|
}: FetchUsersParams = {}): Promise<IUser[]> {
|
||||||
const cookieStore = await cookies();
|
const cookieStore = await cookies();
|
||||||
const token = cookieStore.get(AUTH_COOKIE_NAME)?.value;
|
const token = cookieStore.get(AUTH_COOKIE_NAME)?.value;
|
||||||
|
|
||||||
@ -16,8 +26,14 @@ export async function fetchUsers(): Promise<IUser[]> {
|
|||||||
throw new Error("Missing auth token");
|
throw new Error("Missing auth token");
|
||||||
}
|
}
|
||||||
|
|
||||||
const backendUrl = `${BE_BASE_URL}/api/v1/users`;
|
const params = new URLSearchParams();
|
||||||
|
params.set("limit", String(limit));
|
||||||
|
params.set("page", String(page));
|
||||||
|
|
||||||
|
const backendUrl = `${BE_BASE_URL}/api/v1/users${
|
||||||
|
params.size ? `?${params.toString()}` : ""
|
||||||
|
}`;
|
||||||
|
console.log("[Users] - backendUrl", backendUrl);
|
||||||
const response = await fetch(backendUrl, {
|
const response = await fetch(backendUrl, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import AccountBalanceIcon from "@mui/icons-material/AccountBalance";
|
|||||||
import PaymentIcon from "@mui/icons-material/Payment";
|
import PaymentIcon from "@mui/icons-material/Payment";
|
||||||
import CurrencyExchangeIcon from "@mui/icons-material/CurrencyExchange";
|
import CurrencyExchangeIcon from "@mui/icons-material/CurrencyExchange";
|
||||||
import ViewSidebarIcon from "@mui/icons-material/ViewSidebar";
|
import ViewSidebarIcon from "@mui/icons-material/ViewSidebar";
|
||||||
|
import CompareArrowsIcon from "@mui/icons-material/CompareArrows";
|
||||||
|
|
||||||
const IconMap = {
|
const IconMap = {
|
||||||
HomeIcon,
|
HomeIcon,
|
||||||
@ -53,6 +54,7 @@ const IconMap = {
|
|||||||
PaymentIcon,
|
PaymentIcon,
|
||||||
CurrencyExchangeIcon,
|
CurrencyExchangeIcon,
|
||||||
ViewSidebarIcon,
|
ViewSidebarIcon,
|
||||||
|
CompareArrowsIcon,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default IconMap;
|
export default IconMap;
|
||||||
|
|||||||
@ -56,7 +56,6 @@ async function validateToken(token: string) {
|
|||||||
algorithms: ["HS256"],
|
algorithms: ["HS256"],
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[middleware] payload", payload);
|
|
||||||
return payload as {
|
return payload as {
|
||||||
exp?: number;
|
exp?: number;
|
||||||
MustChangePassword?: boolean;
|
MustChangePassword?: boolean;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user