@omniumretail/shared-resources 0.1.59 → 0.1.60
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/package.json +1 -1
- package/src/enums/attendence-type.enum.ts +5 -0
- package/src/enums/employees-order.enum.ts +7 -0
- package/src/helpers/codeMutation.tsx +19 -0
- package/src/helpers/date-unix.helper.ts +29 -0
- package/src/helpers/formatted-date.helper.ts +15 -0
- package/src/helpers/getChildrenByType.helper.ts +5 -0
- package/src/hooks/ATIM/PicaPonto/get/getEmployeesWithTimekeeping.hook.ts +35 -0
- package/src/hooks/ATIM/PicaPonto/mutate/postAttendance.hook.ts +32 -0
- package/src/hooks/ATIM/PicaPonto/mutate/postTogglePinCode.ts +33 -0
- package/src/hooks/{Others → ATIM/PicaPonto/mutate}/postVerifyUserQuery.hook.ts +3 -3
- package/src/hooks/Asta/Answer/get/getAstaAnswerQuery.hook.ts +29 -0
- package/src/hooks/Asta/Answer/mutate/useAstaAnswersMutateQuery.hook.ts +17 -0
- package/src/hooks/Asta/Answer/others/finishAstaAnswersQuery.hook.ts +15 -0
- package/src/hooks/Asta/Answer/others/putAnswerImageQuery.hook.ts +15 -0
- package/src/hooks/Asta/Inspection/get/getInspectionQuery.hook.ts +29 -0
- package/src/hooks/Asta/Inspection/mutate/useInspectionMutateQuery.hook.ts +17 -0
- package/src/hooks/Asta/Inspection/others/deleteInspectionQuery.hook.ts +15 -0
- package/src/hooks/Asta/Inspection/others/finishInspectionQuery.hook.ts +15 -0
- package/src/hooks/Asta/Template/get/getTemplateByIdQuery.hook.ts +13 -0
- package/src/hooks/Asta/Template/get/getTemplateHeadersQuery.hook.ts +10 -0
- package/src/hooks/Asta/Template/get/getTemplateQuery.hook.ts +29 -0
- package/src/hooks/Asta/Template/mutate/useEvaluationCycleMutateQuery.hook.ts +17 -0
- package/src/hooks/Asta/Template/others/deleteTemplateQuery.hook.ts +15 -0
- package/src/hooks/Asta/Template/others/finishTemplateQuery.hook.ts +15 -0
- package/src/hooks/Store/useStoreByCodeQuery.hook.ts +1 -1
- package/src/hooks/index.ts +23 -1
- package/src/interfaces/Answer.ts +1 -0
- package/src/interfaces/AstaQuestions.ts +10 -0
- package/src/interfaces/Employee.ts +11 -0
- package/src/interfaces/Inspection.ts +21 -0
- package/src/interfaces/Responses.ts +28 -0
- package/src/interfaces/Template.ts +28 -0
- package/src/interfaces/TimeKeeping.ts +16 -0
- package/src/interfaces/index.ts +3 -0
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MenuProps } from 'antd';
|
|
2
|
+
|
|
3
|
+
export type MenuItem = Required<MenuProps>['items'][number];
|
|
4
|
+
|
|
5
|
+
export function getItem(
|
|
6
|
+
label: React.ReactNode,
|
|
7
|
+
key: React.Key,
|
|
8
|
+
icon?: React.ReactNode,
|
|
9
|
+
children?: MenuItem[],
|
|
10
|
+
type?: 'group',
|
|
11
|
+
): MenuItem {
|
|
12
|
+
return {
|
|
13
|
+
key,
|
|
14
|
+
icon,
|
|
15
|
+
children,
|
|
16
|
+
label,
|
|
17
|
+
type,
|
|
18
|
+
} as MenuItem;
|
|
19
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import dayjs, { Dayjs } from 'dayjs';
|
|
3
|
+
|
|
4
|
+
export const getDateFromUnix = <T = Dayjs | string | null>(unixDate: number, formatStr?: string): T => {
|
|
5
|
+
const date = unixDate ? dayjs.unix(unixDate) : null;
|
|
6
|
+
|
|
7
|
+
return (formatStr && date ? date.format(formatStr) : date) as T;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const getDateToUnix = (date: Date): number | null => {
|
|
11
|
+
return date ? moment(date).unix() : null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getUnixFromDateString = (dateString: string): number | null => {
|
|
15
|
+
const date = dayjs(dateString, 'YYYY-MM-DD');
|
|
16
|
+
|
|
17
|
+
return date.isValid() ? date.unix() : null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getDateStringToUnix = (dateUnix: number) => {
|
|
21
|
+
const dateObject = new Date(dateUnix * 1000);
|
|
22
|
+
|
|
23
|
+
const day = dateObject?.getDate()?.toString()?.padStart(2, '0');
|
|
24
|
+
const month = (dateObject?.getMonth() + 1)?.toString()?.padStart(2, '0');
|
|
25
|
+
const year = dateObject?.getFullYear();
|
|
26
|
+
|
|
27
|
+
return `${day}/${month}/${year}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
|
|
3
|
+
export const getFormattedDate = (seconds: number, defaultValue = ''): string => {
|
|
4
|
+
if (!seconds) {
|
|
5
|
+
return defaultValue;
|
|
6
|
+
}
|
|
7
|
+
const date = new Date();
|
|
8
|
+
date.setUTCSeconds(seconds);
|
|
9
|
+
const finalDate = moment();
|
|
10
|
+
finalDate.set('minutes', date.getUTCMinutes());
|
|
11
|
+
finalDate.set('seconds', date.getUTCSeconds());
|
|
12
|
+
finalDate.set('hours', date.getUTCHours());
|
|
13
|
+
|
|
14
|
+
return finalDate.format('HH:mm');
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useQuery , UseQueryOptions} from '@tanstack/react-query';
|
|
2
|
+
import { EmployeeTimeKeeping } from "../../../../interfaces/Responses";
|
|
3
|
+
import { EmployeeOrder } from '../../../../enums/employees-order.enum';
|
|
4
|
+
import { getDateToUnix } from "../../../../helpers/date-unix.helper";
|
|
5
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
6
|
+
import { ResponseList} from '../../../../interfaces';
|
|
7
|
+
|
|
8
|
+
interface EmployeesWithTimekeepingProps extends UseQueryOptions<ResponseList<"EmployeesWorkLogs", EmployeeTimeKeeping>> {
|
|
9
|
+
storeId?: string;
|
|
10
|
+
date?: number;
|
|
11
|
+
search?: string;
|
|
12
|
+
page?: number;
|
|
13
|
+
records?: number;
|
|
14
|
+
sortBy?: string;
|
|
15
|
+
sortDirection?: string;
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const getEmployeesWithTimekeeping = ({storeId, date, search, page, records, sortBy, sortDirection}: EmployeesWithTimekeepingProps) => {
|
|
20
|
+
return useQuery(
|
|
21
|
+
['EMPLOYEES_WITH_TIMEKEEPING', storeId, date, search, page, records, sortBy, sortDirection],
|
|
22
|
+
() => getAuth0<ResponseList<"EmployeesWorkLogs", EmployeeTimeKeeping>>('/EmployeesWorklog', {
|
|
23
|
+
pStoreId: storeId,
|
|
24
|
+
pDate: date || getDateToUnix(new Date()),
|
|
25
|
+
pPage: page || 1,
|
|
26
|
+
pRecords: records || 50,
|
|
27
|
+
pSortBy: sortBy || "Name",
|
|
28
|
+
pSortDirection: sortDirection || "asc",
|
|
29
|
+
pSearch: search
|
|
30
|
+
}),
|
|
31
|
+
{
|
|
32
|
+
keepPreviousData: true,
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useQuery, useQueryOptions, useMutation } from '@tanstack/react-query';
|
|
2
|
+
import { TogglePinCode } from "../../../../interfaces/Responses";
|
|
3
|
+
import { AttendanceType} from "../../../../enums/attendence-type.enum";
|
|
4
|
+
import { getDateToUnix } from "../../../../helpers/date-unix.helper";
|
|
5
|
+
import { postAuth0} from "../../../../services/ApiService";
|
|
6
|
+
|
|
7
|
+
export interface PostAttendance extends useQueryOptions<TogglePinCode>{
|
|
8
|
+
storeId: string;
|
|
9
|
+
employeeId: string;
|
|
10
|
+
isWorking: boolean;
|
|
11
|
+
type: AttendanceType;
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const usePostAttendance = ({ storeId, employeeId, type, isWorking}: PostAttendance) => {
|
|
16
|
+
const queryClient = useQuery();
|
|
17
|
+
return useMutation<TogglePinCode, unknown, TogglePinCode>((data: TogglePinCode) => {
|
|
18
|
+
return postAuth0(`/Attendance?`, {
|
|
19
|
+
storeId: storeId,
|
|
20
|
+
employeeId: employeeId,
|
|
21
|
+
Date: getDateToUnix(new Date()),
|
|
22
|
+
type: isWorking ? AttendanceType.EXIT : AttendanceType.ENTER,
|
|
23
|
+
},
|
|
24
|
+
data);
|
|
25
|
+
}, {
|
|
26
|
+
onSuccess: (data: TogglePinCode) => {
|
|
27
|
+
queryClient.setQueryData(
|
|
28
|
+
['POST_ATTENDANCE_QUERY'], data);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useQueryClient, useMutation, UseQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import { TogglePinCode } from "../../../../interfaces/Responses";
|
|
3
|
+
import { postAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
interface TogglePinCodeMutateProps extends UseQueryOptions<TogglePinCode>{
|
|
6
|
+
pinCode?: string;
|
|
7
|
+
storeId?: string;
|
|
8
|
+
employeeId?: string;
|
|
9
|
+
isWorking?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export const postTogglePinCode = ({pinCode, storeId, employeeId, isWorking }: TogglePinCodeMutateProps) => {
|
|
12
|
+
const queryClient = useQueryClient();
|
|
13
|
+
return useMutation<TogglePinCode, unknown, TogglePinCode>((data: TogglePinCode) =>{
|
|
14
|
+
return postAuth0(`/EmployeesPinCode/`, {
|
|
15
|
+
pinCode: pinCode,
|
|
16
|
+
storeId: storeId,
|
|
17
|
+
employeeId: employeeId,
|
|
18
|
+
isWorking: isWorking
|
|
19
|
+
|
|
20
|
+
}, data);
|
|
21
|
+
},{
|
|
22
|
+
onSuccess: (data: TogglePinCode) => {
|
|
23
|
+
queryClient.setQueryData(
|
|
24
|
+
['TOGGLE_PIN_CODE_QUERY'], data);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { VerifyUser } from '
|
|
3
|
-
import { post } from '
|
|
2
|
+
import { VerifyUser } from '../../../../interfaces';
|
|
3
|
+
import { post } from '../../../../services/ApiService';
|
|
4
4
|
|
|
5
5
|
export const postVerifyUserQueryHook = () => {
|
|
6
6
|
const queryClient = useQueryClient();
|
|
7
7
|
return useMutation<VerifyUser, unknown, VerifyUser>((data: VerifyUser) => {
|
|
8
|
-
return post('/
|
|
8
|
+
return post('/Youverse/Verify_User', data);
|
|
9
9
|
}, {
|
|
10
10
|
onSuccess: (data: VerifyUser) => {
|
|
11
11
|
queryClient.setQueryData(
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import { Answer, ResponseList } from "../../../../interfaces";
|
|
3
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
export interface AstaAnswersQueryProps extends UseQueryOptions<ResponseList<"Answers", Answer>> {
|
|
6
|
+
tags?: string;
|
|
7
|
+
page?: number;
|
|
8
|
+
records?: number;
|
|
9
|
+
sortBy?: string;
|
|
10
|
+
sortDirection?: string;
|
|
11
|
+
query?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getAstaAnswersQueryHook = ({ tags, page, records, sortBy, sortDirection, query }: AstaAnswersQueryProps) => {
|
|
15
|
+
return useQuery(
|
|
16
|
+
['ASTA_ANSWERS_QUERY', tags, page, records, sortBy, sortDirection, query],
|
|
17
|
+
() => getAuth0<ResponseList<"Answers", Answer>>('/ASTA/Answers/GetInspection', {
|
|
18
|
+
pPage: page || 1,
|
|
19
|
+
pRecords: records || 50,
|
|
20
|
+
pSortBy: sortBy || 'Type',
|
|
21
|
+
pSortDirection: sortDirection || 'asc',
|
|
22
|
+
pTerms: tags,
|
|
23
|
+
pQuery: query
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
keepPreviousData: true,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Answer } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0, postAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const useAstaAnswersMutateHook = (inpsectionId: string) => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Answer, unknown, Answer>((data: Answer) => {
|
|
8
|
+
return data.Id ?
|
|
9
|
+
putAuth0(`/ASTA/Answers/${data.Id}`, undefined, data) :
|
|
10
|
+
postAuth0(`/ASTA/Answers?pInspectionId=${inpsectionId}`, undefined, data);
|
|
11
|
+
}, {
|
|
12
|
+
onSuccess: (data: Answer) => {
|
|
13
|
+
queryClient.setQueryData(
|
|
14
|
+
['ASTA_ANSWERS_ID_QUERY'], data);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Answer } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const finishAstaAnswersQueryHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Answer, unknown, Answer>((data: Answer) => {
|
|
8
|
+
return putAuth0(`/ASTA/Answers/FinishQuestionnaire/${data.Id}`, undefined, data)
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: (data: Answer) => {
|
|
11
|
+
queryClient.setQueryData(
|
|
12
|
+
['ASTA_ANSWERS_ID_QUERY'], data);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Answer } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const putAnswerImageMutateHook = (questionnaireId: string) => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Answer, unknown, Answer>((data: Answer) => {
|
|
8
|
+
return putAuth0(`/ASTA/Answers/Image/${questionnaireId}`, undefined, data)
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: (data: Answer) => {
|
|
11
|
+
queryClient.setQueryData(
|
|
12
|
+
['ASTA_ANSWER_ID_QUERY'], data);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import { Inspection, ResponseList } from "../../../../interfaces";
|
|
3
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
export interface InspectionQueryProps extends UseQueryOptions<ResponseList<"Inspection", Inspection>> {
|
|
6
|
+
tags?: string;
|
|
7
|
+
page?: number;
|
|
8
|
+
records?: number;
|
|
9
|
+
sortBy?: string;
|
|
10
|
+
sortDirection?: string;
|
|
11
|
+
query?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getInspectionQueryHook = ({ tags, page, records, sortBy, sortDirection, query }: InspectionQueryProps) => {
|
|
15
|
+
return useQuery(
|
|
16
|
+
['INSPECTION_QUERY', tags, page, records, sortBy, sortDirection, query],
|
|
17
|
+
() => getAuth0<ResponseList<"Inspection", Inspection>>('/ASTA/Inspection/GetInspection', {
|
|
18
|
+
pPage: page || 1,
|
|
19
|
+
pRecords: records || 50,
|
|
20
|
+
pSortBy: sortBy || 'Type',
|
|
21
|
+
pSortDirection: sortDirection || 'asc',
|
|
22
|
+
pTerms: tags,
|
|
23
|
+
pQuery: query
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
keepPreviousData: true,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Inspection } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0, postAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const useInspectionMutateHook = (templateId: string) => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Inspection, unknown, Inspection>((data: Inspection) => {
|
|
8
|
+
return data.Id ?
|
|
9
|
+
putAuth0(`/ASTA/Inspection/FileInspection?pId=${data.Id}`, undefined, data) :
|
|
10
|
+
postAuth0(`/ASTA/Inspection?pId=${templateId}`, undefined, data);
|
|
11
|
+
}, {
|
|
12
|
+
onSuccess: (data: Inspection) => {
|
|
13
|
+
queryClient.setQueryData(
|
|
14
|
+
['INSPECTION_ID_QUERY'], data);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Inspection } from '../../../../interfaces';
|
|
3
|
+
import { toDeleteAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const deleteInspectionMutateHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Inspection, unknown, Inspection>((data: Inspection) => {
|
|
8
|
+
return toDeleteAuth0(`/ASTA/Inspection/DeleteInspection?pId=${data.Id}`)
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: () => {
|
|
11
|
+
queryClient.invalidateQueries(
|
|
12
|
+
['INSPECTION_QUERY']);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Inspection } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const finishInspectionQueryHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Inspection, unknown, Inspection>((data: Inspection) => {
|
|
8
|
+
return putAuth0(`/ASTA/Inspection/FinishInspection?pId=${data.Id}`, undefined, data)
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: (data: Inspection) => {
|
|
11
|
+
queryClient.setQueryData(
|
|
12
|
+
['INSPECTION_ID_QUERY'], data);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { Template } from "../../../../interfaces";
|
|
3
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
export const getTemplateByIdQueryHook = (templateId: string) => {
|
|
6
|
+
return useQuery(
|
|
7
|
+
['TEMPLATE_ID_QUERY', templateId],
|
|
8
|
+
() => getAuth0<Template>(`/ASTA/Template/GetById?pId=${templateId}`),
|
|
9
|
+
{
|
|
10
|
+
enabled: !!(templateId),
|
|
11
|
+
},
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { Headers } from "../../../../interfaces";
|
|
3
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
export const getTemplateHeadersQueryHook = () => {
|
|
6
|
+
return useQuery(
|
|
7
|
+
['TEMPLATE_HEADERS_QUERY'],
|
|
8
|
+
() => getAuth0<Headers[]>(`/ASTA/Template/GetHeaders`),
|
|
9
|
+
);
|
|
10
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useQuery, UseQueryOptions } from "@tanstack/react-query";
|
|
2
|
+
import { Template, ResponseList } from "../../../../interfaces";
|
|
3
|
+
import { getAuth0 } from "../../../../services/ApiService";
|
|
4
|
+
|
|
5
|
+
export interface TemplateQueryProps extends UseQueryOptions<ResponseList<"Templates", Template>> {
|
|
6
|
+
tags?: string;
|
|
7
|
+
page?: number;
|
|
8
|
+
records?: number;
|
|
9
|
+
sortBy?: string;
|
|
10
|
+
sortDirection?: string;
|
|
11
|
+
query?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const getTemplateQueryHook = ({ tags, page, records, sortBy, sortDirection, query }: TemplateQueryProps) => {
|
|
15
|
+
return useQuery(
|
|
16
|
+
['TEMPLATES_QUERY', tags, page, records, sortBy, sortDirection, query],
|
|
17
|
+
() => getAuth0<ResponseList<"Templates", Template>>('/ASTA/Template/GetByQuery', {
|
|
18
|
+
pPage: page || 1,
|
|
19
|
+
pRecords: records || 50,
|
|
20
|
+
pSortBy: sortBy || 'Type',
|
|
21
|
+
pSortDirection: sortDirection || 'asc',
|
|
22
|
+
pTerms: tags,
|
|
23
|
+
pQuery: query
|
|
24
|
+
}),
|
|
25
|
+
{
|
|
26
|
+
keepPreviousData: true,
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Template } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0, postAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const useTemplateMutateHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Template, unknown, Template>((data: Template) => {
|
|
8
|
+
return data.Id ?
|
|
9
|
+
putAuth0(`/ASTA/Template/FileTemplate?pId=${data.Id}`, undefined, data) :
|
|
10
|
+
postAuth0('/ASTA/Template', undefined, data);
|
|
11
|
+
}, {
|
|
12
|
+
onSuccess: (data: Template) => {
|
|
13
|
+
queryClient.setQueryData(
|
|
14
|
+
['TEMPLATE_ID_QUERY'], data);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Template } from '../../../../interfaces';
|
|
3
|
+
import { toDeleteAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const deleteTemplateMutateHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Template, unknown, Template>((data: Template) => {
|
|
8
|
+
return toDeleteAuth0(`/ASTA/Template/DeleteTemplate?pId=${data.Id}`)
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: () => {
|
|
11
|
+
queryClient.invalidateQueries(
|
|
12
|
+
['TEMPLATE_QUERY']);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { Template } from '../../../../interfaces';
|
|
3
|
+
import { putAuth0 } from '../../../../services/ApiService';
|
|
4
|
+
|
|
5
|
+
export const finishTemplateQueryHook = () => {
|
|
6
|
+
const queryClient = useQueryClient();
|
|
7
|
+
return useMutation<Template, unknown, Template>((data: Template) => {
|
|
8
|
+
return putAuth0(`/ASTA/Template/FinishTemplate?pId=${data.Id}`, undefined, data)
|
|
9
|
+
}, {
|
|
10
|
+
onSuccess: (data: Template) => {
|
|
11
|
+
queryClient.setQueryData(
|
|
12
|
+
['TEMPLATE_ID_QUERY'], data);
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -76,6 +76,29 @@ export * from './Astt/get/getReportsBuilderQuery.hook';
|
|
|
76
76
|
export * from './Astt/get/getRfidQuery.hook';
|
|
77
77
|
export * from './Astt/get/getProductsListingQuery.hook';
|
|
78
78
|
|
|
79
|
+
//ATIM
|
|
80
|
+
export * from './ATIM/PicaPonto/get/getEmployeesWithTimekeeping.hook';
|
|
81
|
+
export * from './ATIM/PicaPonto/mutate/postVerifyUserQuery.hook';
|
|
82
|
+
export * from './ATIM/PicaPonto/mutate/postAttendance.hook';
|
|
83
|
+
|
|
84
|
+
//ASTA
|
|
85
|
+
export * from './Asta/Template/get/getTemplateByIdQuery.hook';
|
|
86
|
+
export * from './Asta/Template/get/getTemplateHeadersQuery.hook';
|
|
87
|
+
export * from './Asta/Template/get/getTemplateQuery.hook';
|
|
88
|
+
export * from './Asta/Template/mutate/useEvaluationCycleMutateQuery.hook';
|
|
89
|
+
export * from './Asta/Template/others/deleteTemplateQuery.hook';
|
|
90
|
+
export * from './Asta/Template/others/finishTemplateQuery.hook';
|
|
91
|
+
|
|
92
|
+
export * from './Asta/Inspection/get/getInspectionQuery.hook';
|
|
93
|
+
export * from './Asta/Inspection/mutate/useInspectionMutateQuery.hook';
|
|
94
|
+
export * from './Asta/Inspection/others/deleteInspectionQuery.hook';
|
|
95
|
+
export * from './Asta/Inspection/others/finishInspectionQuery.hook';
|
|
96
|
+
|
|
97
|
+
export * from './Asta/Answer/get/getAstaAnswerQuery.hook';
|
|
98
|
+
export * from './Asta/Answer/mutate/useAstaAnswersMutateQuery.hook';
|
|
99
|
+
export * from './Asta/Answer/others/finishAstaAnswersQuery.hook';
|
|
100
|
+
export * from './Asta/Answer/others/putAnswerImageQuery.hook';
|
|
101
|
+
|
|
79
102
|
//Others
|
|
80
103
|
export * from './Others/useJobTitlesQuery.hook';
|
|
81
104
|
export * from './Others/useContractStatesQuery.hook';
|
|
@@ -85,7 +108,6 @@ export * from './Others/useCustomersQuery.hook';
|
|
|
85
108
|
export * from './Others/useCountriesQuery.hook';
|
|
86
109
|
export * from './Others/useCreateNotification.hook';
|
|
87
110
|
export * from './Others/postCheckoutsMutateQuery.hook';
|
|
88
|
-
export * from './Others/postVerifyUserQuery.hook';
|
|
89
111
|
export * from './Others/postVerifyImageQuery.hook';
|
|
90
112
|
export * from './Others/getWeeklyWorkloadQuery.hook';
|
|
91
113
|
export * from './Others/getNotificationTitleQuery.hook';
|
package/src/interfaces/Answer.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AstaCategories, HeadersInterface } from "./Template";
|
|
2
|
+
|
|
3
|
+
export interface Inspection {
|
|
4
|
+
Id: string;
|
|
5
|
+
TemplateId: string;
|
|
6
|
+
UserId: string;
|
|
7
|
+
UserName: string;
|
|
8
|
+
LocationName: string;
|
|
9
|
+
LocationId: string;
|
|
10
|
+
Name: string;
|
|
11
|
+
Type: string;
|
|
12
|
+
Headers: HeadersInterface[];
|
|
13
|
+
StoreId: string;
|
|
14
|
+
Store: any;
|
|
15
|
+
Total: number;
|
|
16
|
+
Date: number;
|
|
17
|
+
UpdateDate: number;
|
|
18
|
+
EmployeeId: string;
|
|
19
|
+
EmployeeName: string;
|
|
20
|
+
CategoriesDTO: AstaCategories[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Employee} from './Employee';
|
|
2
|
+
import { WorkLog } from './TimeKeeping';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
//Response Interfaces
|
|
6
|
+
|
|
7
|
+
export interface EmployeeTimeKeeping {
|
|
8
|
+
Count?: number;
|
|
9
|
+
EmployeesWorklog?: Employee[];
|
|
10
|
+
error?: string[];
|
|
11
|
+
success: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TogglePinCode {
|
|
15
|
+
|
|
16
|
+
workLog?: WorkLog;
|
|
17
|
+
error?: string[];
|
|
18
|
+
success: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AstaQuestions } from "./AstaQuestions";
|
|
2
|
+
|
|
3
|
+
export interface Template {
|
|
4
|
+
Id: string;
|
|
5
|
+
Name: string;
|
|
6
|
+
Type: string;
|
|
7
|
+
Headers: HeadersInterface[];
|
|
8
|
+
StoreId: string;
|
|
9
|
+
Store: any;
|
|
10
|
+
Total: number;
|
|
11
|
+
Date: number;
|
|
12
|
+
UpdateDate: number;
|
|
13
|
+
EmployeeId: string;
|
|
14
|
+
EmployeeName: string;
|
|
15
|
+
CategoriesDTO: AstaCategories[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AstaCategories {
|
|
19
|
+
Name: string;
|
|
20
|
+
Questions: AstaQuestions[];
|
|
21
|
+
SubCategoriesDTO: AstaCategories[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface HeadersInterface {
|
|
25
|
+
Id: string;
|
|
26
|
+
Name: string;
|
|
27
|
+
Value: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//Time Keeping Interfaces
|
|
2
|
+
|
|
3
|
+
export enum WorkingStatus {
|
|
4
|
+
WORKING = 'working',
|
|
5
|
+
NOT_WORKING = 'not_working',
|
|
6
|
+
IN_BREAK = 'in_break',
|
|
7
|
+
NOT_STARTED = 'not_started',
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface WorkLog {
|
|
11
|
+
LastEntry: number;
|
|
12
|
+
LastExit: number;
|
|
13
|
+
TimeWorked: number;
|
|
14
|
+
Breaks: number;
|
|
15
|
+
}
|
|
16
|
+
|
package/src/interfaces/index.ts
CHANGED