@go-avro/avro-js 0.0.2-beta.100 → 0.0.2-beta.101
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/client/QueryClient.d.ts +5 -4
- package/dist/client/hooks/bills.js +9 -9
- package/dist/client/hooks/events.js +5 -5
- package/dist/client/hooks/jobs.js +3 -3
- package/dist/client/hooks/routes.js +5 -6
- package/dist/client/hooks/teams.js +11 -0
- package/dist/types/api.d.ts +0 -1
- package/package.json +1 -1
|
@@ -100,7 +100,6 @@ declare module '../client/QueryClient' {
|
|
|
100
100
|
useCreateEvent(): ReturnType<typeof useMutation<{
|
|
101
101
|
id: string;
|
|
102
102
|
}, StandardError, {
|
|
103
|
-
companyId: string;
|
|
104
103
|
eventData: Partial<_Event>;
|
|
105
104
|
}>>;
|
|
106
105
|
useCreateUserSession(): ReturnType<typeof useMutation<{
|
|
@@ -112,7 +111,6 @@ declare module '../client/QueryClient' {
|
|
|
112
111
|
id: string;
|
|
113
112
|
invoice_id: number;
|
|
114
113
|
}, StandardError, {
|
|
115
|
-
companyId: string;
|
|
116
114
|
data: {
|
|
117
115
|
line_items: LineItem[];
|
|
118
116
|
due_date: number;
|
|
@@ -130,15 +128,18 @@ declare module '../client/QueryClient' {
|
|
|
130
128
|
useCreateJob(): ReturnType<typeof useMutation<{
|
|
131
129
|
id: string;
|
|
132
130
|
}, StandardError, {
|
|
133
|
-
companyId: string;
|
|
134
131
|
jobData: Partial<Job>;
|
|
135
132
|
}>>;
|
|
136
133
|
useCreateRoute(): ReturnType<typeof useMutation<{
|
|
137
134
|
id: string;
|
|
138
135
|
}, StandardError, {
|
|
139
|
-
companyId: string;
|
|
140
136
|
routeData: Partial<Route>;
|
|
141
137
|
}>>;
|
|
138
|
+
useCreateTeam(): ReturnType<typeof useMutation<{
|
|
139
|
+
id: string;
|
|
140
|
+
}, StandardError, {
|
|
141
|
+
teamData: Partial<Team>;
|
|
142
|
+
}>>;
|
|
142
143
|
useCreateSelf(): ReturnType<typeof useMutation<{
|
|
143
144
|
msg: string;
|
|
144
145
|
}, StandardError, {
|
|
@@ -38,7 +38,7 @@ AvroQueryClient.prototype.useGetBill = function (billId) {
|
|
|
38
38
|
AvroQueryClient.prototype.useCreateBill = function () {
|
|
39
39
|
const queryClient = useQueryClient();
|
|
40
40
|
return useMutation({
|
|
41
|
-
mutationFn: async ({
|
|
41
|
+
mutationFn: async ({ data, }) => {
|
|
42
42
|
const body = {
|
|
43
43
|
events: data.line_items.filter(item => item.line_item_type === 'EVENT').map(item => item.id),
|
|
44
44
|
months: data.line_items.filter(item => item.line_item_type === 'SERVICE_MONTH').map(item => item.id),
|
|
@@ -47,13 +47,13 @@ AvroQueryClient.prototype.useCreateBill = function () {
|
|
|
47
47
|
users: data.users,
|
|
48
48
|
due_date: data.due_date,
|
|
49
49
|
};
|
|
50
|
-
return this.post(`/company/${companyId}/bill`, JSON.stringify(body), undefined, {
|
|
50
|
+
return this.post(`/company/${this.companyId}/bill`, JSON.stringify(body), undefined, {
|
|
51
51
|
'Content-Type': 'application/json',
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
|
-
onMutate: async (
|
|
55
|
-
await queryClient.cancelQueries({ queryKey: ['bills', companyId] });
|
|
56
|
-
const previousBills = queryClient.getQueryData(['bills', companyId]);
|
|
54
|
+
onMutate: async () => {
|
|
55
|
+
await queryClient.cancelQueries({ queryKey: ['bills', this.companyId] });
|
|
56
|
+
const previousBills = queryClient.getQueryData(['bills', this.companyId]);
|
|
57
57
|
// TODO: Create a fake bill object for optimistic update and update events and months accordingly
|
|
58
58
|
return { previousBills };
|
|
59
59
|
},
|
|
@@ -62,10 +62,10 @@ AvroQueryClient.prototype.useCreateBill = function () {
|
|
|
62
62
|
queryClient.setQueryData(['bills'], context.previousBills);
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
onSettled: (_data, _error
|
|
66
|
-
queryClient.invalidateQueries({ queryKey: ['bills',
|
|
67
|
-
queryClient.invalidateQueries({ queryKey: ['events',
|
|
68
|
-
queryClient.invalidateQueries({ queryKey: ['months',
|
|
65
|
+
onSettled: (_data, _error) => {
|
|
66
|
+
queryClient.invalidateQueries({ queryKey: ['bills', this.companyId] });
|
|
67
|
+
queryClient.invalidateQueries({ queryKey: ['events', this.companyId] });
|
|
68
|
+
queryClient.invalidateQueries({ queryKey: ['months', this.companyId] });
|
|
69
69
|
},
|
|
70
70
|
});
|
|
71
71
|
};
|
|
@@ -42,12 +42,12 @@ AvroQueryClient.prototype.useGetEvent = function (eventId) {
|
|
|
42
42
|
AvroQueryClient.prototype.useCreateEvent = function () {
|
|
43
43
|
const queryClient = useQueryClient();
|
|
44
44
|
return useMutation({
|
|
45
|
-
mutationFn: ({
|
|
46
|
-
return this.post(`/company/${companyId}/event`, JSON.stringify(eventData), undefined, {
|
|
45
|
+
mutationFn: ({ eventData }) => {
|
|
46
|
+
return this.post(`/company/${this.companyId}/event`, JSON.stringify(eventData), undefined, {
|
|
47
47
|
"Content-Type": "application/json",
|
|
48
48
|
});
|
|
49
49
|
},
|
|
50
|
-
onMutate: async ({
|
|
50
|
+
onMutate: async ({ eventData }) => {
|
|
51
51
|
await queryClient.cancelQueries({ queryKey: ['events'] });
|
|
52
52
|
const previousEvents = queryClient.getQueryData(['events']);
|
|
53
53
|
const previousJob = queryClient.getQueryData(['job', eventData.job_id]);
|
|
@@ -84,7 +84,7 @@ AvroQueryClient.prototype.useCreateEvent = function () {
|
|
|
84
84
|
{
|
|
85
85
|
...eventData,
|
|
86
86
|
id: Math.random().toString(36).substring(2, 11),
|
|
87
|
-
company_id: companyId,
|
|
87
|
+
company_id: this.companyId,
|
|
88
88
|
},
|
|
89
89
|
...firstPage,
|
|
90
90
|
],
|
|
@@ -97,7 +97,7 @@ AvroQueryClient.prototype.useCreateEvent = function () {
|
|
|
97
97
|
{
|
|
98
98
|
...eventData,
|
|
99
99
|
id: Math.random().toString(36).substring(2, 11),
|
|
100
|
-
company_id: companyId,
|
|
100
|
+
company_id: this.companyId,
|
|
101
101
|
},
|
|
102
102
|
...oldData,
|
|
103
103
|
];
|
|
@@ -47,12 +47,12 @@ AvroQueryClient.prototype.useGetJob = function (jobId) {
|
|
|
47
47
|
AvroQueryClient.prototype.useCreateJob = function () {
|
|
48
48
|
const queryClient = useQueryClient();
|
|
49
49
|
return useMutation({
|
|
50
|
-
mutationFn: ({
|
|
51
|
-
return this.post(`/company/${companyId}/job`, JSON.stringify(jobData), undefined, {
|
|
50
|
+
mutationFn: ({ jobData }) => {
|
|
51
|
+
return this.post(`/company/${this.companyId}/job`, JSON.stringify(jobData), undefined, {
|
|
52
52
|
"Content-Type": "application/json",
|
|
53
53
|
});
|
|
54
54
|
},
|
|
55
|
-
onMutate: async ({
|
|
55
|
+
onMutate: async ({ jobData }) => {
|
|
56
56
|
await queryClient.cancelQueries({ queryKey: ['jobs'] });
|
|
57
57
|
const previousJobs = queryClient.getQueryData(['jobs']);
|
|
58
58
|
queryClient.setQueryData(['jobs'], (oldData) => {
|
|
@@ -37,10 +37,10 @@ AvroQueryClient.prototype.useGetRoute = function (routeId) {
|
|
|
37
37
|
AvroQueryClient.prototype.useCreateRoute = function () {
|
|
38
38
|
const queryClient = useQueryClient();
|
|
39
39
|
return useMutation({
|
|
40
|
-
mutationFn: async ({
|
|
41
|
-
return this.post(`/company/${companyId}/route`, JSON.stringify(routeData), undefined, { "Content-Type": "application/json" });
|
|
40
|
+
mutationFn: async ({ routeData }) => {
|
|
41
|
+
return this.post(`/company/${this.companyId}/route`, JSON.stringify(routeData), undefined, { "Content-Type": "application/json" });
|
|
42
42
|
},
|
|
43
|
-
onMutate: async ({
|
|
43
|
+
onMutate: async ({ routeData }) => {
|
|
44
44
|
await queryClient.cancelQueries({ queryKey: ['routes'] });
|
|
45
45
|
const previousRoutes = queryClient.getQueryData(['routes']);
|
|
46
46
|
queryClient.setQueriesData({ queryKey: ['routes'] }, (oldData) => {
|
|
@@ -67,12 +67,11 @@ AvroQueryClient.prototype.useCreateRoute = function () {
|
|
|
67
67
|
queryClient.setQueryData(['routes'], context.previousRoutes);
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
onSettled: (_data, _error,
|
|
71
|
-
const { companyId } = variables;
|
|
70
|
+
onSettled: (_data, _error, _variables) => {
|
|
72
71
|
queryClient.invalidateQueries({ queryKey: ['routes'] });
|
|
73
72
|
queryClient.invalidateQueries({ queryKey: ['jobs'] });
|
|
74
73
|
queryClient.invalidateQueries({ queryKey: ['job'] });
|
|
75
|
-
queryClient.invalidateQueries({ queryKey: ['company', companyId] });
|
|
74
|
+
queryClient.invalidateQueries({ queryKey: ['company', this.companyId] });
|
|
76
75
|
},
|
|
77
76
|
});
|
|
78
77
|
};
|
|
@@ -26,6 +26,17 @@ AvroQueryClient.prototype.useGetTeams = function (body, total, onProgress) {
|
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
|
+
AvroQueryClient.prototype.useCreateTeam = function () {
|
|
30
|
+
const queryClient = useQueryClient();
|
|
31
|
+
return useMutation({
|
|
32
|
+
mutationFn: async ({ teamData }) => {
|
|
33
|
+
return this.post(`/company/${this.companyId}/team`, JSON.stringify(teamData), undefined, { "Content-Type": "application/json" });
|
|
34
|
+
},
|
|
35
|
+
onSettled: () => {
|
|
36
|
+
queryClient.invalidateQueries({ queryKey: ['teams'] });
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
29
40
|
AvroQueryClient.prototype.useUpdateTeam = function () {
|
|
30
41
|
const queryClient = useQueryClient();
|
|
31
42
|
return useMutation({
|
package/dist/types/api.d.ts
CHANGED