first commit
This commit is contained in:
38
frontend/app/utils/api/workingDays/index.ts
Normal file
38
frontend/app/utils/api/workingDays/index.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { baseApiRequest } from "../apiRequests/baseApiRequest";
|
||||
import { WorkingDaysResponse } from "./type";
|
||||
|
||||
const PROJECT_MANAGEMENT_BASE_URL = `${process.env.NEXT_PUBLIC_PROJECT_MANAGEMENT_API_URL}/api/v1`;
|
||||
|
||||
export const getAllWorkingDays = async (): Promise<WorkingDaysResponse> => {
|
||||
return await baseApiRequest(
|
||||
`${PROJECT_MANAGEMENT_BASE_URL}/working-days`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: ["/working-days"],
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const getWorkingDaysByYear = async (
|
||||
year: string,
|
||||
): Promise<WorkingDaysResponse> => {
|
||||
return await baseApiRequest(
|
||||
`${PROJECT_MANAGEMENT_BASE_URL}/working-days/year/${year}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
credentials: "include",
|
||||
},
|
||||
{
|
||||
isAccessTokenRequird: true,
|
||||
revalidatePaths: [`/working-days/year/${year}`],
|
||||
},
|
||||
);
|
||||
};
|
||||
40
frontend/app/utils/api/workingDays/type.ts
Normal file
40
frontend/app/utils/api/workingDays/type.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
export interface WorkingDaysMonthDto {
|
||||
year: string;
|
||||
month: string;
|
||||
workingDays: number;
|
||||
}
|
||||
|
||||
export interface WorkingDaysResponseDto {
|
||||
workingId: string;
|
||||
accountIdentifier: string;
|
||||
workingDaysDetails: Record<string, Record<string, WorkingDaysMonthDto>>;
|
||||
}
|
||||
|
||||
export interface WorkingDaysPageableInfo {
|
||||
offset: number;
|
||||
sort: SortInfo;
|
||||
pageSize: number;
|
||||
paged: boolean;
|
||||
unpaged: boolean;
|
||||
pageNumber: number;
|
||||
}
|
||||
|
||||
export interface SortInfo {
|
||||
empty: boolean;
|
||||
sorted: boolean;
|
||||
unsorted: boolean;
|
||||
}
|
||||
|
||||
export interface WorkingDaysResponse {
|
||||
content: WorkingDaysResponseDto[];
|
||||
pageable: WorkingDaysPageableInfo;
|
||||
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