@voyant-travel/quotes-react 0.119.2
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/LICENSE +201 -0
- package/README.md +39 -0
- package/dist/client.d.ts +31 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +71 -0
- package/dist/components/create-quote-dialog.d.ts +10 -0
- package/dist/components/create-quote-dialog.d.ts.map +1 -0
- package/dist/components/create-quote-dialog.js +45 -0
- package/dist/components/create-quote-version-dialog.d.ts +9 -0
- package/dist/components/create-quote-version-dialog.d.ts.map +1 -0
- package/dist/components/create-quote-version-dialog.js +108 -0
- package/dist/components/crm-format.d.ts +7 -0
- package/dist/components/crm-format.d.ts.map +1 -0
- package/dist/components/crm-format.js +40 -0
- package/dist/components/inline-currency-field.d.ts +12 -0
- package/dist/components/inline-currency-field.d.ts.map +1 -0
- package/dist/components/inline-currency-field.js +46 -0
- package/dist/components/inline-field.d.ts +16 -0
- package/dist/components/inline-field.d.ts.map +1 -0
- package/dist/components/inline-field.js +45 -0
- package/dist/components/inline-language-field.d.ts +12 -0
- package/dist/components/inline-language-field.d.ts.map +1 -0
- package/dist/components/inline-language-field.js +46 -0
- package/dist/components/inline-number-field.d.ts +15 -0
- package/dist/components/inline-number-field.d.ts.map +1 -0
- package/dist/components/inline-number-field.js +58 -0
- package/dist/components/inline-select-field.d.ts +19 -0
- package/dist/components/inline-select-field.d.ts.map +1 -0
- package/dist/components/inline-select-field.js +34 -0
- package/dist/components/quote-summary-card.d.ts +11 -0
- package/dist/components/quote-summary-card.d.ts.map +1 -0
- package/dist/components/quote-summary-card.js +11 -0
- package/dist/components/quote-version-detail-sections.d.ts +22 -0
- package/dist/components/quote-version-detail-sections.d.ts.map +1 -0
- package/dist/components/quote-version-detail-sections.js +87 -0
- package/dist/components/quote-versions-page.d.ts +8 -0
- package/dist/components/quote-versions-page.d.ts.map +1 -0
- package/dist/components/quote-versions-page.js +30 -0
- package/dist/components/quotes-board.d.ts +8 -0
- package/dist/components/quotes-board.d.ts.map +1 -0
- package/dist/components/quotes-board.js +24 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/use-pipeline-mutation.d.ts +76 -0
- package/dist/hooks/use-pipeline-mutation.d.ts.map +1 -0
- package/dist/hooks/use-pipeline-mutation.js +76 -0
- package/dist/hooks/use-pipelines.d.ts +31 -0
- package/dist/hooks/use-pipelines.d.ts.map +1 -0
- package/dist/hooks/use-pipelines.js +42 -0
- package/dist/hooks/use-quote-mutation.d.ts +72 -0
- package/dist/hooks/use-quote-mutation.d.ts.map +1 -0
- package/dist/hooks/use-quote-mutation.js +50 -0
- package/dist/hooks/use-quote-version-mutation.d.ts +272 -0
- package/dist/hooks/use-quote-version-mutation.d.ts.map +1 -0
- package/dist/hooks/use-quote-version-mutation.js +164 -0
- package/dist/hooks/use-quote-version.d.ts +37 -0
- package/dist/hooks/use-quote-version.d.ts.map +1 -0
- package/dist/hooks/use-quote-version.js +34 -0
- package/dist/hooks/use-quote-versions.d.ts +30 -0
- package/dist/hooks/use-quote-versions.d.ts.map +1 -0
- package/dist/hooks/use-quote-versions.js +27 -0
- package/dist/hooks/use-quote.d.ts +26 -0
- package/dist/hooks/use-quote.d.ts.map +1 -0
- package/dist/hooks/use-quote.js +23 -0
- package/dist/hooks/use-quotes.d.ts +36 -0
- package/dist/hooks/use-quotes.d.ts.map +1 -0
- package/dist/hooks/use-quotes.js +44 -0
- package/dist/hooks/use-stages.d.ts +37 -0
- package/dist/hooks/use-stages.d.ts.map +1 -0
- package/dist/hooks/use-stages.js +45 -0
- package/dist/i18n/en/base.d.ts +189 -0
- package/dist/i18n/en/base.d.ts.map +1 -0
- package/dist/i18n/en/base.js +188 -0
- package/dist/i18n/en/commerce.d.ts +133 -0
- package/dist/i18n/en/commerce.d.ts.map +1 -0
- package/dist/i18n/en/commerce.js +132 -0
- package/dist/i18n/en/detail.d.ts +211 -0
- package/dist/i18n/en/detail.d.ts.map +1 -0
- package/dist/i18n/en/detail.js +210 -0
- package/dist/i18n/en/lists.d.ts +75 -0
- package/dist/i18n/en/lists.d.ts.map +1 -0
- package/dist/i18n/en/lists.js +74 -0
- package/dist/i18n/en.d.ts +599 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +10 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/messages.d.ts +577 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +15 -0
- package/dist/i18n/provider.d.ts +1220 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro/base.d.ts +189 -0
- package/dist/i18n/ro/base.d.ts.map +1 -0
- package/dist/i18n/ro/base.js +188 -0
- package/dist/i18n/ro/commerce.d.ts +133 -0
- package/dist/i18n/ro/commerce.d.ts.map +1 -0
- package/dist/i18n/ro/commerce.js +132 -0
- package/dist/i18n/ro/detail.d.ts +211 -0
- package/dist/i18n/ro/detail.d.ts.map +1 -0
- package/dist/i18n/ro/detail.js +210 -0
- package/dist/i18n/ro/lists.d.ts +75 -0
- package/dist/i18n/ro/lists.d.ts.map +1 -0
- package/dist/i18n/ro/lists.js +74 -0
- package/dist/i18n/ro.d.ts +599 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +10 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/provider.d.ts +2 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +1 -0
- package/dist/query-keys.d.ts +44 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +16 -0
- package/dist/query-options.d.ts +678 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +160 -0
- package/dist/schemas.d.ts +348 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +101 -0
- package/dist/ui.d.ts +8 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +7 -0
- package/package.json +117 -0
- package/src/styles.css +11 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { fetchWithValidation } from "../client.js";
|
|
5
|
+
import { useVoyantContext } from "../provider.js";
|
|
6
|
+
import { quotesQueryKeys } from "../query-keys.js";
|
|
7
|
+
import { acceptQuoteVersionResponse, listEnvelope, quoteVersionLineSingleResponse, quoteVersionRecordSchema, quoteVersionSingleResponse, } from "../schemas.js";
|
|
8
|
+
const deleteResponseSchema = z.object({ success: z.boolean() });
|
|
9
|
+
const quoteVersionArrayResponse = listEnvelope(quoteVersionRecordSchema);
|
|
10
|
+
export function useQuoteVersionMutation() {
|
|
11
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
12
|
+
const queryClient = useQueryClient();
|
|
13
|
+
const create = useMutation({
|
|
14
|
+
mutationFn: async ({ quoteId, input }) => {
|
|
15
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quotes/${quoteId}/versions`, quoteVersionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
16
|
+
return data;
|
|
17
|
+
},
|
|
18
|
+
onSuccess: (_data, vars) => {
|
|
19
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
20
|
+
void queryClient.invalidateQueries({
|
|
21
|
+
queryKey: quotesQueryKeys.quoteVersionsList({ quoteId: vars.quoteId }),
|
|
22
|
+
});
|
|
23
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quote(vars.quoteId) });
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
const update = useMutation({
|
|
27
|
+
mutationFn: async ({ id, input }) => {
|
|
28
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${id}`, quoteVersionSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
29
|
+
return data;
|
|
30
|
+
},
|
|
31
|
+
onSuccess: (data) => {
|
|
32
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
33
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(data.id), data);
|
|
34
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quote(data.quoteId) });
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
const remove = useMutation({
|
|
38
|
+
mutationFn: async (id) => {
|
|
39
|
+
return fetchWithValidation(`/v1/quotes/quote-versions/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" });
|
|
40
|
+
},
|
|
41
|
+
onSuccess: (_data, id) => {
|
|
42
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
43
|
+
queryClient.removeQueries({ queryKey: quotesQueryKeys.quoteVersion(id) });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
const send = useMutation({
|
|
47
|
+
mutationFn: async ({ id, input }) => {
|
|
48
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${id}/send`, quoteVersionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input ?? {}) });
|
|
49
|
+
return data;
|
|
50
|
+
},
|
|
51
|
+
onSuccess: (data) => {
|
|
52
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
53
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(data.id), data);
|
|
54
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quote(data.quoteId) });
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const view = useMutation({
|
|
58
|
+
mutationFn: async (id) => {
|
|
59
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${id}/view`, quoteVersionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({}) });
|
|
60
|
+
return data;
|
|
61
|
+
},
|
|
62
|
+
onSuccess: (data) => {
|
|
63
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(data.id), data);
|
|
64
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const decline = useMutation({
|
|
68
|
+
mutationFn: async (id) => {
|
|
69
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${id}/decline`, quoteVersionSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({}) });
|
|
70
|
+
return data;
|
|
71
|
+
},
|
|
72
|
+
onSuccess: (data) => {
|
|
73
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
74
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(data.id), data);
|
|
75
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quote(data.quoteId) });
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const accept = useMutation({
|
|
79
|
+
mutationFn: async (id) => {
|
|
80
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${id}/accept`, acceptQuoteVersionResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify({}) });
|
|
81
|
+
return data;
|
|
82
|
+
},
|
|
83
|
+
onSuccess: (data) => {
|
|
84
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
85
|
+
queryClient.setQueryData(quotesQueryKeys.quote(data.quote.id), data.quote);
|
|
86
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(data.quoteVersion.id), data.quoteVersion);
|
|
87
|
+
for (const quoteVersion of data.closedQuoteVersions) {
|
|
88
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(quoteVersion.id), quoteVersion);
|
|
89
|
+
}
|
|
90
|
+
void queryClient.invalidateQueries({
|
|
91
|
+
queryKey: quotesQueryKeys.quoteVersionsList({ quoteId: data.quote.id }),
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const expire = useMutation({
|
|
96
|
+
mutationFn: async (input) => {
|
|
97
|
+
const { data } = await fetchWithValidation("/v1/quotes/quote-versions/expire", quoteVersionArrayResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input ?? {}) });
|
|
98
|
+
return data;
|
|
99
|
+
},
|
|
100
|
+
onSuccess: (data) => {
|
|
101
|
+
void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quoteVersions() });
|
|
102
|
+
for (const quoteVersion of data) {
|
|
103
|
+
queryClient.setQueryData(quotesQueryKeys.quoteVersion(quoteVersion.id), quoteVersion);
|
|
104
|
+
void queryClient.invalidateQueries({
|
|
105
|
+
queryKey: quotesQueryKeys.quote(quoteVersion.quoteId),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
const createLine = useMutation({
|
|
111
|
+
mutationFn: async ({ quoteVersionId, input, }) => {
|
|
112
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${quoteVersionId}/lines`, quoteVersionLineSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
113
|
+
return data;
|
|
114
|
+
},
|
|
115
|
+
onSuccess: (_data, vars) => {
|
|
116
|
+
void queryClient.invalidateQueries({
|
|
117
|
+
queryKey: quotesQueryKeys.quoteVersionLines(vars.quoteVersionId),
|
|
118
|
+
});
|
|
119
|
+
void queryClient.invalidateQueries({
|
|
120
|
+
queryKey: quotesQueryKeys.quoteVersion(vars.quoteVersionId),
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
const updateLine = useMutation({
|
|
125
|
+
mutationFn: async ({ quoteVersionId: _quoteVersionId, lineId, input, }) => {
|
|
126
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-version-lines/${lineId}`, quoteVersionLineSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
127
|
+
return data;
|
|
128
|
+
},
|
|
129
|
+
onSuccess: (_data, vars) => {
|
|
130
|
+
void queryClient.invalidateQueries({
|
|
131
|
+
queryKey: quotesQueryKeys.quoteVersionLines(vars.quoteVersionId),
|
|
132
|
+
});
|
|
133
|
+
void queryClient.invalidateQueries({
|
|
134
|
+
queryKey: quotesQueryKeys.quoteVersion(vars.quoteVersionId),
|
|
135
|
+
});
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
const removeLine = useMutation({
|
|
139
|
+
mutationFn: async ({ quoteVersionId: _quoteVersionId, lineId, }) => {
|
|
140
|
+
return fetchWithValidation(`/v1/quotes/quote-version-lines/${lineId}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" });
|
|
141
|
+
},
|
|
142
|
+
onSuccess: (_data, vars) => {
|
|
143
|
+
void queryClient.invalidateQueries({
|
|
144
|
+
queryKey: quotesQueryKeys.quoteVersionLines(vars.quoteVersionId),
|
|
145
|
+
});
|
|
146
|
+
void queryClient.invalidateQueries({
|
|
147
|
+
queryKey: quotesQueryKeys.quoteVersion(vars.quoteVersionId),
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
create,
|
|
153
|
+
update,
|
|
154
|
+
remove,
|
|
155
|
+
send,
|
|
156
|
+
view,
|
|
157
|
+
decline,
|
|
158
|
+
accept,
|
|
159
|
+
expire,
|
|
160
|
+
createLine,
|
|
161
|
+
updateLine,
|
|
162
|
+
removeLine,
|
|
163
|
+
};
|
|
164
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface UseQuoteVersionOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useQuoteVersion(id: string | undefined, options?: UseQuoteVersionOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
quoteId: string;
|
|
7
|
+
label: string | null;
|
|
8
|
+
status: string;
|
|
9
|
+
supersedesId: string | null;
|
|
10
|
+
tripSnapshotId: string | null;
|
|
11
|
+
validUntil: string | null;
|
|
12
|
+
currency: string;
|
|
13
|
+
subtotalAmountCents: number;
|
|
14
|
+
taxAmountCents: number;
|
|
15
|
+
totalAmountCents: number;
|
|
16
|
+
notes: string | null;
|
|
17
|
+
sentAt: string | null;
|
|
18
|
+
viewedAt: string | null;
|
|
19
|
+
decidedAt: string | null;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
updatedAt: string;
|
|
22
|
+
archivedAt: string | null;
|
|
23
|
+
}, Error>;
|
|
24
|
+
export declare function useQuoteVersionLines(quoteVersionId: string | undefined, options?: UseQuoteVersionOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
25
|
+
id: string;
|
|
26
|
+
quoteVersionId: string;
|
|
27
|
+
productId: string | null;
|
|
28
|
+
supplierServiceId: string | null;
|
|
29
|
+
description: string;
|
|
30
|
+
quantity: number;
|
|
31
|
+
unitPriceAmountCents: number;
|
|
32
|
+
totalAmountCents: number;
|
|
33
|
+
currency: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
}[], Error>;
|
|
37
|
+
//# sourceMappingURL=use-quote-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quote-version.d.ts","sourceRoot":"","sources":["../../src/hooks/use-quote-version.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE,sBAA2B;;;;;;;;;;;;;;;;;;;UAiB3F;AAED,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,OAAO,GAAE,sBAA2B;;;;;;;;;;;;YAkBrC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantContext } from "../provider.js";
|
|
5
|
+
import { quotesQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { quoteVersionLineListResponse, quoteVersionSingleResponse } from "../schemas.js";
|
|
7
|
+
export function useQuoteVersion(id, options = {}) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
9
|
+
const { enabled = true } = options;
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: quotesQueryKeys.quoteVersion(id ?? ""),
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
if (!id)
|
|
14
|
+
throw new Error("useQuoteVersion requires an id");
|
|
15
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${id}`, quoteVersionSingleResponse, { baseUrl, fetcher });
|
|
16
|
+
return data;
|
|
17
|
+
},
|
|
18
|
+
enabled: enabled && Boolean(id),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function useQuoteVersionLines(quoteVersionId, options = {}) {
|
|
22
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
23
|
+
const { enabled = true } = options;
|
|
24
|
+
return useQuery({
|
|
25
|
+
queryKey: quotesQueryKeys.quoteVersionLines(quoteVersionId ?? ""),
|
|
26
|
+
queryFn: async () => {
|
|
27
|
+
if (!quoteVersionId)
|
|
28
|
+
throw new Error("useQuoteVersionLines requires a quoteVersionId");
|
|
29
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quote-versions/${quoteVersionId}/lines`, quoteVersionLineListResponse, { baseUrl, fetcher });
|
|
30
|
+
return data;
|
|
31
|
+
},
|
|
32
|
+
enabled: enabled && Boolean(quoteVersionId),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type QuoteVersionsListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseQuoteVersionsOptions extends QuoteVersionsListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useQuoteVersions(options?: UseQuoteVersionsOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
quoteId: string;
|
|
9
|
+
label: string | null;
|
|
10
|
+
status: string;
|
|
11
|
+
supersedesId: string | null;
|
|
12
|
+
tripSnapshotId: string | null;
|
|
13
|
+
validUntil: string | null;
|
|
14
|
+
currency: string;
|
|
15
|
+
subtotalAmountCents: number;
|
|
16
|
+
taxAmountCents: number;
|
|
17
|
+
totalAmountCents: number;
|
|
18
|
+
notes: string | null;
|
|
19
|
+
sentAt: string | null;
|
|
20
|
+
viewedAt: string | null;
|
|
21
|
+
decidedAt: string | null;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
archivedAt: string | null;
|
|
25
|
+
}[];
|
|
26
|
+
total: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
offset: number;
|
|
29
|
+
}, Error>;
|
|
30
|
+
//# sourceMappingURL=use-quote-versions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quote-versions.d.ts","sourceRoot":"","sources":["../../src/hooks/use-quote-versions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,wBAAwB,EAAmB,MAAM,kBAAkB,CAAA;AAGjF,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B;;;;;;;;;;;;;;;;;;;;;;;;UAqBrE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantContext } from "../provider.js";
|
|
5
|
+
import { quotesQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { quoteVersionListResponse } from "../schemas.js";
|
|
7
|
+
export function useQuoteVersions(options = {}) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
9
|
+
const { enabled = true, ...filters } = options;
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: quotesQueryKeys.quoteVersionsList(filters),
|
|
12
|
+
queryFn: () => {
|
|
13
|
+
const params = new URLSearchParams();
|
|
14
|
+
if (filters.quoteId)
|
|
15
|
+
params.set("quoteId", filters.quoteId);
|
|
16
|
+
if (filters.status)
|
|
17
|
+
params.set("status", filters.status);
|
|
18
|
+
if (filters.limit !== undefined)
|
|
19
|
+
params.set("limit", String(filters.limit));
|
|
20
|
+
if (filters.offset !== undefined)
|
|
21
|
+
params.set("offset", String(filters.offset));
|
|
22
|
+
const qs = params.toString();
|
|
23
|
+
return fetchWithValidation(`/v1/quotes/quote-versions${qs ? `?${qs}` : ""}`, quoteVersionListResponse, { baseUrl, fetcher });
|
|
24
|
+
},
|
|
25
|
+
enabled,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface UseQuoteOptions {
|
|
2
|
+
enabled?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export declare function useQuote(id: string | undefined, options?: UseQuoteOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
personId: string | null;
|
|
8
|
+
organizationId: string | null;
|
|
9
|
+
pipelineId: string;
|
|
10
|
+
stageId: string;
|
|
11
|
+
ownerId: string | null;
|
|
12
|
+
status: string;
|
|
13
|
+
acceptedVersionId: string | null;
|
|
14
|
+
valueAmountCents: number | null;
|
|
15
|
+
valueCurrency: string | null;
|
|
16
|
+
expectedCloseDate: string | null;
|
|
17
|
+
source: string | null;
|
|
18
|
+
sourceRef: string | null;
|
|
19
|
+
lostReason: string | null;
|
|
20
|
+
tags: string[];
|
|
21
|
+
createdAt: string;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
stageChangedAt: string;
|
|
24
|
+
closedAt: string | null;
|
|
25
|
+
}, Error>;
|
|
26
|
+
//# sourceMappingURL=use-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quote.d.ts","sourceRoot":"","sources":["../../src/hooks/use-quote.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE,eAAoB;;;;;;;;;;;;;;;;;;;;;UAgB7E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantContext } from "../provider.js";
|
|
5
|
+
import { quotesQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { quoteSingleResponse } from "../schemas.js";
|
|
7
|
+
export function useQuote(id, options = {}) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
9
|
+
const { enabled = true } = options;
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: quotesQueryKeys.quote(id ?? ""),
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
if (!id)
|
|
14
|
+
throw new Error("useQuote requires an id");
|
|
15
|
+
const { data } = await fetchWithValidation(`/v1/quotes/quotes/${id}`, quoteSingleResponse, {
|
|
16
|
+
baseUrl,
|
|
17
|
+
fetcher,
|
|
18
|
+
});
|
|
19
|
+
return data;
|
|
20
|
+
},
|
|
21
|
+
enabled: enabled && Boolean(id),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type QuotesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseQuotesOptions extends QuotesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Lists quotes with filters + pagination. Returns the raw
|
|
7
|
+
* `{ data, total, limit, offset }` envelope.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useQuotes(options?: UseQuotesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
10
|
+
data: {
|
|
11
|
+
id: string;
|
|
12
|
+
title: string;
|
|
13
|
+
personId: string | null;
|
|
14
|
+
organizationId: string | null;
|
|
15
|
+
pipelineId: string;
|
|
16
|
+
stageId: string;
|
|
17
|
+
ownerId: string | null;
|
|
18
|
+
status: string;
|
|
19
|
+
acceptedVersionId: string | null;
|
|
20
|
+
valueAmountCents: number | null;
|
|
21
|
+
valueCurrency: string | null;
|
|
22
|
+
expectedCloseDate: string | null;
|
|
23
|
+
source: string | null;
|
|
24
|
+
sourceRef: string | null;
|
|
25
|
+
lostReason: string | null;
|
|
26
|
+
tags: string[];
|
|
27
|
+
createdAt: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
stageChangedAt: string;
|
|
30
|
+
closedAt: string | null;
|
|
31
|
+
}[];
|
|
32
|
+
total: number;
|
|
33
|
+
limit: number;
|
|
34
|
+
offset: number;
|
|
35
|
+
}, Error>;
|
|
36
|
+
//# sourceMappingURL=use-quotes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-quotes.d.ts","sourceRoot":"","sources":["../../src/hooks/use-quotes.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,iBAAiB,EAAmB,MAAM,kBAAkB,CAAA;AAG1E,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;UAyBvD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantContext } from "../provider.js";
|
|
5
|
+
import { quotesQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { quoteListResponse } from "../schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* Lists quotes with filters + pagination. Returns the raw
|
|
9
|
+
* `{ data, total, limit, offset }` envelope.
|
|
10
|
+
*/
|
|
11
|
+
export function useQuotes(options = {}) {
|
|
12
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
13
|
+
const { enabled = true, ...filters } = options;
|
|
14
|
+
return useQuery({
|
|
15
|
+
queryKey: quotesQueryKeys.quotesList(filters),
|
|
16
|
+
queryFn: () => {
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
if (filters.search)
|
|
19
|
+
params.set("search", filters.search);
|
|
20
|
+
if (filters.personId)
|
|
21
|
+
params.set("personId", filters.personId);
|
|
22
|
+
if (filters.organizationId)
|
|
23
|
+
params.set("organizationId", filters.organizationId);
|
|
24
|
+
if (filters.pipelineId)
|
|
25
|
+
params.set("pipelineId", filters.pipelineId);
|
|
26
|
+
if (filters.stageId)
|
|
27
|
+
params.set("stageId", filters.stageId);
|
|
28
|
+
if (filters.ownerId)
|
|
29
|
+
params.set("ownerId", filters.ownerId);
|
|
30
|
+
if (filters.status)
|
|
31
|
+
params.set("status", filters.status);
|
|
32
|
+
if (filters.limit !== undefined)
|
|
33
|
+
params.set("limit", String(filters.limit));
|
|
34
|
+
if (filters.offset !== undefined)
|
|
35
|
+
params.set("offset", String(filters.offset));
|
|
36
|
+
const qs = params.toString();
|
|
37
|
+
return fetchWithValidation(`/v1/quotes/quotes${qs ? `?${qs}` : ""}`, quoteListResponse, {
|
|
38
|
+
baseUrl,
|
|
39
|
+
fetcher,
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
enabled,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type StagesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseStagesOptions extends StagesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useStages(options?: UseStagesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
id: string;
|
|
8
|
+
pipelineId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
sortOrder: number;
|
|
11
|
+
probability: number | null;
|
|
12
|
+
isClosed: boolean;
|
|
13
|
+
isWon: boolean;
|
|
14
|
+
isLost: boolean;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
updatedAt: string;
|
|
17
|
+
}[];
|
|
18
|
+
total: number;
|
|
19
|
+
limit: number;
|
|
20
|
+
offset: number;
|
|
21
|
+
}, Error>;
|
|
22
|
+
export interface UseStageOptions {
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare function useStage(id: string | undefined, options?: UseStageOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
26
|
+
id: string;
|
|
27
|
+
pipelineId: string;
|
|
28
|
+
name: string;
|
|
29
|
+
sortOrder: number;
|
|
30
|
+
probability: number | null;
|
|
31
|
+
isClosed: boolean;
|
|
32
|
+
isWon: boolean;
|
|
33
|
+
isLost: boolean;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
updatedAt: string;
|
|
36
|
+
}, Error>;
|
|
37
|
+
//# sourceMappingURL=use-stages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-stages.d.ts","sourceRoot":"","sources":["../../src/hooks/use-stages.ts"],"names":[],"mappings":"AAMA,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAG1E,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,SAAS,CAAC,OAAO,GAAE,gBAAqB;;;;;;;;;;;;;;;;UAmBvD;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE,eAAoB;;;;;;;;;;;UAgB7E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantContext } from "../provider.js";
|
|
5
|
+
import { quotesQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { stageListResponse, stageSingleResponse } from "../schemas.js";
|
|
7
|
+
export function useStages(options = {}) {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
9
|
+
const { enabled = true, ...filters } = options;
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: quotesQueryKeys.stagesList(filters),
|
|
12
|
+
queryFn: () => {
|
|
13
|
+
const params = new URLSearchParams();
|
|
14
|
+
if (filters.pipelineId)
|
|
15
|
+
params.set("pipelineId", filters.pipelineId);
|
|
16
|
+
if (filters.limit !== undefined)
|
|
17
|
+
params.set("limit", String(filters.limit));
|
|
18
|
+
if (filters.offset !== undefined)
|
|
19
|
+
params.set("offset", String(filters.offset));
|
|
20
|
+
const qs = params.toString();
|
|
21
|
+
return fetchWithValidation(`/v1/quotes/stages${qs ? `?${qs}` : ""}`, stageListResponse, {
|
|
22
|
+
baseUrl,
|
|
23
|
+
fetcher,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
enabled,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function useStage(id, options = {}) {
|
|
30
|
+
const { baseUrl, fetcher } = useVoyantContext();
|
|
31
|
+
const { enabled = true } = options;
|
|
32
|
+
return useQuery({
|
|
33
|
+
queryKey: quotesQueryKeys.stage(id ?? ""),
|
|
34
|
+
queryFn: async () => {
|
|
35
|
+
if (!id)
|
|
36
|
+
throw new Error("useStage requires an id");
|
|
37
|
+
const { data } = await fetchWithValidation(`/v1/quotes/stages/${id}`, stageSingleResponse, {
|
|
38
|
+
baseUrl,
|
|
39
|
+
fetcher,
|
|
40
|
+
});
|
|
41
|
+
return data;
|
|
42
|
+
},
|
|
43
|
+
enabled: enabled && Boolean(id),
|
|
44
|
+
});
|
|
45
|
+
}
|