@omniumretail/shared-resources 0.1.82 → 0.1.83

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.
@@ -0,0 +1,11 @@
1
+ import { UseQueryOptions } from "@tanstack/react-query";
2
+ import { AnswerType, ResponseList } from "../../../../interfaces";
3
+ export interface AnswerTypeQueryProps extends UseQueryOptions<ResponseList<"Value", AnswerType>> {
4
+ tags?: string;
5
+ page?: number;
6
+ records?: number;
7
+ sortBy?: string;
8
+ sortDirection?: string;
9
+ query?: string;
10
+ }
11
+ export declare const getAllAnswerTypeQueryHook: ({ tags, page, records, sortBy, sortDirection, query }: AnswerTypeQueryProps) => import("@tanstack/react-query").UseQueryResult<ResponseList<"Value", AnswerType>, unknown>;
@@ -0,0 +1,2 @@
1
+ import { HeadersInterface } from "../../../../interfaces";
2
+ export declare const getAnswerColorsQueryHook: () => import("@tanstack/react-query").UseQueryResult<HeadersInterface[], unknown>;
@@ -0,0 +1,2 @@
1
+ import { AnswerType } from "../../../../interfaces";
2
+ export declare const getAnswerTypeByIdQueryHook: (answerTypeId: string) => import("@tanstack/react-query").UseQueryResult<AnswerType, unknown>;
@@ -0,0 +1,2 @@
1
+ import { AnswerType } from '../../../../interfaces';
2
+ export declare const useAnswerTypeMutateHook: () => import("@tanstack/react-query").UseMutationResult<AnswerType, unknown, AnswerType, unknown>;
@@ -0,0 +1,6 @@
1
+ import { UseQueryOptions } from '@tanstack/react-query';
2
+ import { AnswerType } from '../../../../interfaces';
3
+ export interface DeleteAnswerTypeProps extends UseQueryOptions<AnswerType> {
4
+ answerTypeIds: string[];
5
+ }
6
+ export declare const deleteAnswerTypeHook: ({ answerTypeIds }: DeleteAnswerTypeProps) => import("@tanstack/react-query").UseMutationResult<AnswerType, unknown, string[], unknown>;
@@ -0,0 +1,2 @@
1
+ import { AnswerType } from '../../../../interfaces';
2
+ export declare const finishAnswerTypeQueryHook: () => import("@tanstack/react-query").UseMutationResult<AnswerType, unknown, AnswerType, unknown>;
@@ -80,6 +80,13 @@ export * from './Asta/Answer/mutate/useAstaAnswersMutateQuery.hook';
80
80
  export * from './Asta/Answer/others/finishAstaAnswersQuery.hook';
81
81
  export * from './Asta/Answer/others/putAnswerImageQuery.hook';
82
82
  export * from './Asta/AnswerType/get/getAnswerTypeQuery.hook';
83
+ export * from './Asta/AnswerType/get/getAllAnswerTypeQuery.hook';
84
+ export * from './Asta/AnswerType/get/getAnswerColorsQuery.hook';
85
+ export * from './Asta/AnswerType/get/getAnswerTypeByIdQuery.hook';
86
+ export * from './Asta/AnswerType/mutate/useAnswerTypeMutateQuery.hook';
87
+ export * from './Asta/AnswerType/mutate/useAnswerTypeMutateQuery.hook';
88
+ export * from './Asta/AnswerType/others/deleteAnswerTypeQuery.hook';
89
+ export * from './Asta/AnswerType/others/finishAnswerTypeQuery.hook';
83
90
  export * from './Asta/Actions/get/getActionByIdQuery.hook';
84
91
  export * from './Asta/Actions/get/getActionPriorityQuery.hook';
85
92
  export * from './Asta/Actions/get/getActionQuery.hook';
@@ -5,6 +5,8 @@ export interface AnswerType {
5
5
  IsCheckBox: boolean;
6
6
  IsNumeric: boolean;
7
7
  HasGrade: boolean;
8
+ isMandatory: boolean;
9
+ isEmphasis: boolean;
8
10
  State: string;
9
11
  Grade: number;
10
12
  Options: AnswerTypeOptions[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/shared-resources",
3
- "version": "0.1.82",
3
+ "version": "0.1.83",
4
4
  "private": false,
5
5
  "description": "Shared Components and services or utils to the frontend versions",
6
6
  "main": "dist/bundle.js",
@@ -0,0 +1,29 @@
1
+ import { useQuery, UseQueryOptions } from "@tanstack/react-query";
2
+ import { AnswerType, ResponseList } from "../../../../interfaces";
3
+ import { getAuth0 } from "../../../../services/ApiService";
4
+
5
+ export interface AnswerTypeQueryProps extends UseQueryOptions<ResponseList<"Value", AnswerType>> {
6
+ tags?: string;
7
+ page?: number;
8
+ records?: number;
9
+ sortBy?: string;
10
+ sortDirection?: string;
11
+ query?: string;
12
+ }
13
+
14
+ export const getAllAnswerTypeQueryHook = ({ tags, page, records, sortBy, sortDirection, query }: AnswerTypeQueryProps) => {
15
+ return useQuery(
16
+ ['ALL_ANSWER_TYPE_QUERY', tags, page, records, sortBy, sortDirection, query],
17
+ () => getAuth0<ResponseList<"Value", AnswerType>>('/ASTA/AnswerType/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,10 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { HeadersInterface } from "../../../../interfaces";
3
+ import { getAuth0 } from "../../../../services/ApiService";
4
+
5
+ export const getAnswerColorsQueryHook = () => {
6
+ return useQuery(
7
+ ['ANSWER_COLORS_QUERY'],
8
+ () => getAuth0<HeadersInterface[]>(`/ASTA/AnswerType/Colors`),
9
+ );
10
+ }
@@ -0,0 +1,15 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { AnswerType } from "../../../../interfaces";
3
+ import { getAuth0 } from "../../../../services/ApiService";
4
+
5
+ export const getAnswerTypeByIdQueryHook = (answerTypeId: string) => {
6
+ return useQuery(
7
+ ['ANSWER_TYPE_ID_QUERY', answerTypeId],
8
+ () => getAuth0<AnswerType>(`/ASTA/AnswerType/GetById`, {
9
+ pId: answerTypeId
10
+ }),
11
+ {
12
+ enabled: !!(answerTypeId),
13
+ },
14
+ );
15
+ }
@@ -0,0 +1,20 @@
1
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { AnswerType } from '../../../../interfaces';
3
+ import { putAuth0, postAuth0 } from '../../../../services/ApiService';
4
+
5
+ export const useAnswerTypeMutateHook = () => {
6
+ const queryClient = useQueryClient();
7
+ return useMutation<AnswerType, unknown, AnswerType>((data: AnswerType) => {
8
+ return data.Id ?
9
+ putAuth0(`/ASTA/AnswerType?`, {
10
+ pId: data.Id
11
+ }, data)
12
+
13
+ : postAuth0('/ASTA/AnswerType', undefined, data);
14
+ }, {
15
+ onSuccess: (data: AnswerType) => {
16
+ queryClient.setQueryData(
17
+ ['ANSWER_TYPE_ID_QUERY'], data);
18
+ },
19
+ });
20
+ }
@@ -0,0 +1,19 @@
1
+ import { UseQueryOptions, useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { AnswerType } from '../../../../interfaces';
3
+ import { toDeleteAuth0 } from '../../../../services/ApiService';
4
+
5
+ export interface DeleteAnswerTypeProps extends UseQueryOptions<AnswerType> {
6
+ answerTypeIds: string[];
7
+ }
8
+
9
+ export const deleteAnswerTypeHook = ({ answerTypeIds }: DeleteAnswerTypeProps) => {
10
+ const queryClient = useQueryClient();
11
+ return useMutation<AnswerType, unknown, string[]>(() => {
12
+ return toDeleteAuth0(`/ASTA/AnswerType/Delete`, undefined, answerTypeIds)
13
+ }, {
14
+ onSuccess: () => {
15
+ queryClient.invalidateQueries(
16
+ ['ALL_ANSWER_TYPE_QUERY']);
17
+ },
18
+ });
19
+ }
@@ -0,0 +1,17 @@
1
+ import { useMutation, useQueryClient } from '@tanstack/react-query';
2
+ import { AnswerType } from '../../../../interfaces';
3
+ import { putAuth0 } from '../../../../services/ApiService';
4
+
5
+ export const finishAnswerTypeQueryHook = () => {
6
+ const queryClient = useQueryClient();
7
+ return useMutation<AnswerType, unknown, AnswerType>((data: AnswerType) => {
8
+ return putAuth0(`/ASTA/AnswerType/Finished?`, {
9
+ pId: data.Id
10
+ }, data);
11
+ }, {
12
+ onSuccess: (data: AnswerType) => {
13
+ queryClient.setQueryData(
14
+ ['ANSWER_TYPE_ID_QUERY'], data);
15
+ },
16
+ });
17
+ }
@@ -106,6 +106,13 @@ export * from './Asta/Answer/others/finishAstaAnswersQuery.hook';
106
106
  export * from './Asta/Answer/others/putAnswerImageQuery.hook';
107
107
 
108
108
  export * from './Asta/AnswerType/get/getAnswerTypeQuery.hook';
109
+ export * from './Asta/AnswerType/get/getAllAnswerTypeQuery.hook';
110
+ export * from './Asta/AnswerType/get/getAnswerColorsQuery.hook';
111
+ export * from './Asta/AnswerType/get/getAnswerTypeByIdQuery.hook';
112
+ export * from './Asta/AnswerType/mutate/useAnswerTypeMutateQuery.hook';
113
+ export * from './Asta/AnswerType/mutate/useAnswerTypeMutateQuery.hook';
114
+ export * from './Asta/AnswerType/others/deleteAnswerTypeQuery.hook';
115
+ export * from './Asta/AnswerType/others/finishAnswerTypeQuery.hook';
109
116
 
110
117
  export * from './Asta/Actions/get/getActionByIdQuery.hook';
111
118
  export * from './Asta/Actions/get/getActionPriorityQuery.hook';
@@ -6,6 +6,8 @@ export interface AnswerType {
6
6
  IsCheckBox: boolean;
7
7
  IsNumeric: boolean;
8
8
  HasGrade: boolean;
9
+ isMandatory: boolean;
10
+ isEmphasis: boolean;
9
11
  State: string;
10
12
  Grade: number;
11
13
  Options: AnswerTypeOptions[];