first commit
This commit is contained in:
36
frontend/app/utils/api/companyData/roleApi.ts/index.ts
Normal file
36
frontend/app/utils/api/companyData/roleApi.ts/index.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { baseApiRequest } from "../../apiRequests/baseApiRequest";
|
||||
import { RoleResponse, RoleResponseDto } from "./type";
|
||||
|
||||
const PROJECT_MANAGEMENT_BASE_URL = `${process.env.NEXT_PUBLIC_PROJECT_MANAGEMENT_API_URL}/api/v1`;
|
||||
|
||||
export const getAllRoles = async (): Promise<RoleResponse> => {
|
||||
return await baseApiRequest(
|
||||
`${PROJECT_MANAGEMENT_BASE_URL}/roles`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: ["/roles"],
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const getRoleById = async (id: string): Promise<RoleResponseDto> => {
|
||||
return await baseApiRequest(
|
||||
`${PROJECT_MANAGEMENT_BASE_URL}/roles/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: [`/roles/${id}`],
|
||||
},
|
||||
);
|
||||
};
|
||||
34
frontend/app/utils/api/companyData/roleApi.ts/type.ts
Normal file
34
frontend/app/utils/api/companyData/roleApi.ts/type.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
export interface RoleResponseDto {
|
||||
id: string;
|
||||
accountId: string;
|
||||
role: string;
|
||||
}
|
||||
|
||||
export interface SortInfo {
|
||||
empty: boolean;
|
||||
sorted: boolean;
|
||||
unsorted: boolean;
|
||||
}
|
||||
|
||||
export interface PageableInfo {
|
||||
pageNumber: number;
|
||||
pageSize: number;
|
||||
sort: SortInfo;
|
||||
offset: number;
|
||||
paged: boolean;
|
||||
unpaged: boolean;
|
||||
}
|
||||
|
||||
export interface RoleResponse {
|
||||
content: RoleResponseDto[];
|
||||
pageable: PageableInfo;
|
||||
last: boolean;
|
||||
totalPages: number;
|
||||
totalElements: number;
|
||||
sort: SortInfo;
|
||||
first: boolean;
|
||||
number: number;
|
||||
size: number;
|
||||
numberOfElements: number;
|
||||
empty: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user