first commit
This commit is contained in:
65
frontend/app/utils/api/user-dashboard-platform/index.tsx
Normal file
65
frontend/app/utils/api/user-dashboard-platform/index.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
import { baseApiRequest } from "../apiRequests/baseApiRequest";
|
||||
import { Role, User, RoleMembership } from "./type";
|
||||
|
||||
const API_BASE_URL = process.env.NEXT_PUBLIC_PROJECT_MANAGEMENT_API_URL;
|
||||
const IKON_API_URL = process.env.NEXT_PUBLIC_IKON_API_URL;
|
||||
|
||||
export const getAllRoles = async (): Promise<Role[]> => {
|
||||
return await baseApiRequest(
|
||||
`${API_BASE_URL}/role`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: ["/roles"],
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const getAllUsers = async (): Promise<User[]> => {
|
||||
return await baseApiRequest(
|
||||
`${IKON_API_URL}/platform/user/current`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: ["/platform/user/current"],
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const getUserById = async (userId: string): Promise<User | null> => {
|
||||
return await baseApiRequest(
|
||||
`${IKON_API_URL}/platform/user/${userId}`, // Assuming this endpoint pattern
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: [`/platform/user/${userId}`],
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const getRoleMemberships = async (roleId: string): Promise<RoleMembership[]> => {
|
||||
return await baseApiRequest(
|
||||
`${API_BASE_URL}/role/${roleId}/membership`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
}
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user