@omniumretail/shared-resources 0.2.20 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/dist/types/hooks/ATIM/BackOffice/get/useEmployeeTimekeepingDetails.hook.d.ts +15 -0
- package/dist/types/hooks/ATIM/BackOffice/get/useStoresQueryHook.hook.d.ts +11 -0
- package/dist/types/hooks/ATIM/BackOffice/mutate/postAttendanceRange.hook.d.ts +2 -0
- package/dist/types/hooks/index.d.ts +3 -0
- package/dist/types/interfaces/BackofficeAtim.d.ts +35 -0
- package/dist/types/interfaces/Configuration.d.ts +1 -0
- package/dist/types/interfaces/Responses.d.ts +6 -0
- package/dist/types/interfaces/index.d.ts +1 -0
- package/dist/types/services/ApiService/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/hooks/ATIM/BackOffice/get/useEmployeeTimekeepingDetails.hook.ts +38 -0
- package/src/hooks/ATIM/BackOffice/get/useStoresQueryHook.hook.ts +27 -0
- package/src/hooks/ATIM/BackOffice/mutate/postAttendanceRange.hook.ts +16 -0
- package/src/hooks/OSUA/get/vouchers/getSitooVouchers.hook.ts +2 -2
- package/src/hooks/index.ts +7 -0
- package/src/interfaces/BackofficeAtim.ts +48 -0
- package/src/interfaces/Configuration.ts +1 -0
- package/src/interfaces/Responses.ts +7 -0
- package/src/interfaces/index.ts +2 -1
- package/src/services/ApiService/index.ts +42 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { ResponseList, EmployeesWorklog } from '../../../../interfaces';
|
|
3
|
+
interface EmployeesWithTimekeepingProps extends UseQueryOptions<ResponseList<"EmployeesWorkLog", EmployeesWorklog>> {
|
|
4
|
+
storeId?: string;
|
|
5
|
+
startDate?: number;
|
|
6
|
+
endDate?: number;
|
|
7
|
+
search?: string;
|
|
8
|
+
page?: number;
|
|
9
|
+
records?: number;
|
|
10
|
+
sortBy?: string;
|
|
11
|
+
sortDirection?: string;
|
|
12
|
+
employeeId?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const useEmployeeTimekeepingDetails: ({ storeId, startDate, endDate, search, employeeId, page, records, sortBy, sortDirection, ...options }: EmployeesWithTimekeepingProps) => import("@tanstack/react-query").UseQueryResult<ResponseList<"EmployeesWorklog", EmployeesWorklog>, unknown>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import { ResponseList, Store } from "../../../../interfaces";
|
|
3
|
+
interface StoreQueryOptions extends UseQueryOptions<ResponseList<'Locations', Store>> {
|
|
4
|
+
page: number;
|
|
5
|
+
records: number;
|
|
6
|
+
sortBy: string;
|
|
7
|
+
sortDirection: string;
|
|
8
|
+
query: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const useStoresQueryHook: ({ page, records, sortBy, sortDirection, query, ...options }: StoreQueryOptions) => import("@tanstack/react-query").UseQueryResult<ResponseList<"Locations", Store>, unknown>;
|
|
11
|
+
export {};
|
|
@@ -117,6 +117,9 @@ export * from './OSUA/get/vouchers/getGngVoucher.hook';
|
|
|
117
117
|
export * from './OSUA/get/vouchers/getSitooVouchers.hook';
|
|
118
118
|
export * from './OSUA/get/vouchers/getVoucherIntegrationRequestStatus.hook';
|
|
119
119
|
export * from './OSUA/mutate/postCreateIntegrationRequest.hook';
|
|
120
|
+
export * from './ATIM/BackOffice/get/useEmployeeTimekeepingDetails.hook';
|
|
121
|
+
export * from './ATIM/BackOffice/get/useStoresQueryHook.hook';
|
|
122
|
+
export * from './ATIM/BackOffice/mutate/postAttendanceRange.hook';
|
|
120
123
|
export * from './Others/useJobTitlesQuery.hook';
|
|
121
124
|
export * from './Others/useContractStatesQuery.hook';
|
|
122
125
|
export * from './Others/useApplicationDataQuery.hook';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface WorkLogDetail {
|
|
2
|
+
Id: string;
|
|
3
|
+
Type: number;
|
|
4
|
+
Date: number;
|
|
5
|
+
}
|
|
6
|
+
export interface Breaks {
|
|
7
|
+
Number: number;
|
|
8
|
+
Time: number;
|
|
9
|
+
}
|
|
10
|
+
export interface WorkDayLog {
|
|
11
|
+
WorkDay: number;
|
|
12
|
+
TimeWorked: number;
|
|
13
|
+
Breaks: Breaks;
|
|
14
|
+
Details: WorkLogDetail[];
|
|
15
|
+
}
|
|
16
|
+
export interface EmployeesWorklog {
|
|
17
|
+
Id: string;
|
|
18
|
+
Code: string;
|
|
19
|
+
Name: string;
|
|
20
|
+
JobTitle: string;
|
|
21
|
+
IsWorking: boolean;
|
|
22
|
+
TimeWorked: number;
|
|
23
|
+
Breaks: Breaks;
|
|
24
|
+
WorkDayLogs: WorkDayLog[];
|
|
25
|
+
}
|
|
26
|
+
export interface Location {
|
|
27
|
+
Id: string;
|
|
28
|
+
Name: string;
|
|
29
|
+
Code: string;
|
|
30
|
+
Status: string;
|
|
31
|
+
}
|
|
32
|
+
export interface UserBackoffice {
|
|
33
|
+
UserId: string;
|
|
34
|
+
FullName: string;
|
|
35
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'whatwg-fetch';
|
|
2
2
|
export declare const get: <T>(path: string, params?: Record<string, unknown>) => Promise<T>;
|
|
3
3
|
export declare const getAuth0: <T>(path: string, params?: Record<string, unknown>) => Promise<T>;
|
|
4
|
+
export declare const getBasic: <T>(path: string, params?: Record<string, unknown>) => Promise<T>;
|
|
4
5
|
export declare const putAuth0: <T>(path: string, params?: Record<string, unknown>, body?: unknown, bodyType?: string) => Promise<T>;
|
|
5
6
|
export declare const patchAuth0: <T>(path: string, params?: Record<string, unknown>, body?: unknown, bodyType?: string) => Promise<T>;
|
|
6
7
|
export declare const postAuth0: <T>(path: string, params?: Record<string, unknown>, body?: unknown, bodyType?: string) => Promise<T>;
|
package/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useQuery , UseQueryOptions} from '@tanstack/react-query';
|
|
2
|
+
import { getDateToUnix } from "../../../../helpers/date-unix.helper";
|
|
3
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
import { ResponseList, EmployeesWorklog } from '../../../../interfaces';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
interface EmployeesWithTimekeepingProps extends UseQueryOptions<ResponseList<"EmployeesWorkLog", EmployeesWorklog>> {
|
|
8
|
+
storeId?: string;
|
|
9
|
+
startDate?: number;
|
|
10
|
+
endDate?: number;
|
|
11
|
+
search?: string;
|
|
12
|
+
page?: number;
|
|
13
|
+
records?: number;
|
|
14
|
+
sortBy?: string;
|
|
15
|
+
sortDirection?: string;
|
|
16
|
+
employeeId?: string;
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const useEmployeeTimekeepingDetails = ({storeId, startDate, endDate, search, employeeId, page, records, sortBy, sortDirection, ...options}: EmployeesWithTimekeepingProps) => {
|
|
21
|
+
return useQuery(
|
|
22
|
+
['EMPLOYEES_WITH_TIMEKEEPING', storeId, startDate, endDate, search, page, records, sortBy, sortDirection],
|
|
23
|
+
() => getAuth0<ResponseList<"EmployeesWorklog", EmployeesWorklog>>('/ATIM/EmployeesWorklogDetails', {
|
|
24
|
+
pStoreId: storeId,
|
|
25
|
+
pStartDate: startDate || getDateToUnix(new Date()),
|
|
26
|
+
pEndDate: endDate || getDateToUnix(new Date()),
|
|
27
|
+
pEmployeeId: employeeId,
|
|
28
|
+
pPage: page || 1,
|
|
29
|
+
pRecords: records,
|
|
30
|
+
pSortBy: sortBy,
|
|
31
|
+
pSortDirection: sortDirection,
|
|
32
|
+
pSearch: search
|
|
33
|
+
}),
|
|
34
|
+
{
|
|
35
|
+
keepPreviousData: true,
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import { get } from "../../../../services";
|
|
3
|
+
import { ResponseList, Store } from "../../../../interfaces";
|
|
4
|
+
|
|
5
|
+
interface StoreQueryOptions extends UseQueryOptions<ResponseList<'Locations', Store>> {
|
|
6
|
+
page: number;
|
|
7
|
+
records: number;
|
|
8
|
+
sortBy: string;
|
|
9
|
+
sortDirection: string;
|
|
10
|
+
query: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const useStoresQueryHook = ({page, records, sortBy, sortDirection, query, ...options }:StoreQueryOptions) => {
|
|
14
|
+
return useQuery<ResponseList<'Locations', Store>>(
|
|
15
|
+
['STORE_QUERY'],
|
|
16
|
+
() => get('/Franchise/Locations', {
|
|
17
|
+
pPage: page,
|
|
18
|
+
pRecords: records,
|
|
19
|
+
pSortBy: sortBy,
|
|
20
|
+
pSortDirection: sortDirection,
|
|
21
|
+
pQuery: query,
|
|
22
|
+
}),
|
|
23
|
+
{
|
|
24
|
+
...options
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useQueryClient, useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { AttendanceRange } from "../../../../interfaces";
|
|
3
|
+
import { postAuth0} from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const postAttendanceRange = () => {
|
|
7
|
+
const queryClient = useQueryClient();
|
|
8
|
+
return useMutation<AttendanceRange, unknown, AttendanceRange>((data: AttendanceRange) => {
|
|
9
|
+
return postAuth0('/ATIM/Attendances/Range', undefined, data);
|
|
10
|
+
}, {
|
|
11
|
+
onSuccess: (data: AttendanceRange) => {
|
|
12
|
+
queryClient.setQueryData(
|
|
13
|
+
['POST_ATTENDANCE'], data);
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useQuery, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
-
import {
|
|
2
|
+
import { getBasic } from "../../../../services/ApiService";
|
|
3
3
|
import { SitooVoucher } from '../../../../interfaces';
|
|
4
4
|
|
|
5
5
|
interface GetSitooVouchersProps extends UseQueryOptions<SitooVoucher>{
|
|
@@ -10,7 +10,7 @@ export const getSitooVouchers = ({ id, ...options }: GetSitooVouchersProps) => {
|
|
|
10
10
|
return useQuery(
|
|
11
11
|
['SITOO_VOUCHERS', id],
|
|
12
12
|
|
|
13
|
-
() =>
|
|
13
|
+
() => getBasic<SitooVoucher>(`/GNG/GiftCard/SPIGiftCard/giftcards/${id}.json`),
|
|
14
14
|
{
|
|
15
15
|
...options,
|
|
16
16
|
retry: false,
|
package/src/hooks/index.ts
CHANGED
|
@@ -157,6 +157,13 @@ export * from './OSUA/get/vouchers/getVoucherIntegrationRequestStatus.hook';
|
|
|
157
157
|
|
|
158
158
|
export * from './OSUA/mutate/postCreateIntegrationRequest.hook';
|
|
159
159
|
|
|
160
|
+
//BackofficeAtim
|
|
161
|
+
|
|
162
|
+
export * from './ATIM/BackOffice/get/useEmployeeTimekeepingDetails.hook';
|
|
163
|
+
export * from './ATIM/BackOffice/get/useStoresQueryHook.hook';
|
|
164
|
+
export * from './ATIM/BackOffice/mutate/postAttendanceRange.hook';
|
|
165
|
+
|
|
166
|
+
|
|
160
167
|
//Others
|
|
161
168
|
export * from './Others/useJobTitlesQuery.hook';
|
|
162
169
|
export * from './Others/useContractStatesQuery.hook';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Store } from './Store';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export interface WorkLogDetail {
|
|
6
|
+
Id: string;
|
|
7
|
+
Type: number;
|
|
8
|
+
Date: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Breaks {
|
|
12
|
+
Number: number;
|
|
13
|
+
Time: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface WorkDayLog {
|
|
17
|
+
WorkDay: number;
|
|
18
|
+
TimeWorked: number;
|
|
19
|
+
Breaks: Breaks;
|
|
20
|
+
Details: WorkLogDetail[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface EmployeesWorklog {
|
|
24
|
+
Id: string;
|
|
25
|
+
Code: string;
|
|
26
|
+
Name: string;
|
|
27
|
+
JobTitle: string;
|
|
28
|
+
IsWorking: boolean;
|
|
29
|
+
TimeWorked: number;
|
|
30
|
+
Breaks: Breaks;
|
|
31
|
+
WorkDayLogs: WorkDayLog[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
export interface Location {
|
|
36
|
+
Id: string;
|
|
37
|
+
Name: string;
|
|
38
|
+
Code: string;
|
|
39
|
+
Status: string;
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface UserBackoffice {
|
|
44
|
+
UserId: string;
|
|
45
|
+
FullName: string;
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
}
|
package/src/interfaces/index.ts
CHANGED
|
@@ -9,6 +9,10 @@ export const getAuth0 = <T>(path: string, params?: Record<string, unknown>): Pro
|
|
|
9
9
|
return buildApiRequestForAuth0<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export const getBasic = <T>(path: string, params?: Record<string, unknown>): Promise<T> => {
|
|
13
|
+
return buildApiRequestForBasic<T>(`${path}?${buildParams(params || {})}`, 'GET');
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
export const putAuth0 = <T>(path: string, params?: Record<string, unknown>, body?: unknown, bodyType?: string): Promise<T> => {
|
|
13
17
|
return buildApiRequestForAuth0<T>(`${path}${buildParams(params || {})}`, 'PUT', body, bodyType);
|
|
14
18
|
}
|
|
@@ -128,6 +132,44 @@ const buildApiRequestForAuth0 = <T>(path: string, method = 'GET', data?: unknown
|
|
|
128
132
|
});
|
|
129
133
|
}
|
|
130
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Build the api request with auth
|
|
137
|
+
* @param path
|
|
138
|
+
* @param method
|
|
139
|
+
* @param data
|
|
140
|
+
* @returns
|
|
141
|
+
*/
|
|
142
|
+
const buildApiRequestForBasic = <T>(path: string, method = 'GET', data?: unknown, bodyType?: string): Promise<T> => {
|
|
143
|
+
const requestUri = buildPath(path);
|
|
144
|
+
|
|
145
|
+
const headers: HeadersInit = {
|
|
146
|
+
Authorization: appConfig.basic ? `Basic ${appConfig.basic}` : undefined,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
let body: FormData | string | undefined | any;
|
|
150
|
+
|
|
151
|
+
if (['POST', 'PUT', 'PATCH'].includes(method)) {
|
|
152
|
+
if (bodyType === 'formdata') {
|
|
153
|
+
// Não é necessário dar set do contentType porque o fetch faz isso por nós quando usamos o fetch
|
|
154
|
+
body = data;
|
|
155
|
+
} else {
|
|
156
|
+
headers['Content-Type'] = 'application/json';
|
|
157
|
+
body = JSON.stringify(data);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return fetch(requestUri, {
|
|
162
|
+
method,
|
|
163
|
+
headers,
|
|
164
|
+
body,
|
|
165
|
+
}).then((response) => {
|
|
166
|
+
if (response.status >= 200 && response.status <= 300) {
|
|
167
|
+
return response.json();
|
|
168
|
+
}
|
|
169
|
+
return response.json().then((data) => Promise.reject(data));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
131
173
|
/**
|
|
132
174
|
* Builds the path to access the api
|
|
133
175
|
* @param path
|