@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.
Files changed (130) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +39 -0
  3. package/dist/client.d.ts +31 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +71 -0
  6. package/dist/components/create-quote-dialog.d.ts +10 -0
  7. package/dist/components/create-quote-dialog.d.ts.map +1 -0
  8. package/dist/components/create-quote-dialog.js +45 -0
  9. package/dist/components/create-quote-version-dialog.d.ts +9 -0
  10. package/dist/components/create-quote-version-dialog.d.ts.map +1 -0
  11. package/dist/components/create-quote-version-dialog.js +108 -0
  12. package/dist/components/crm-format.d.ts +7 -0
  13. package/dist/components/crm-format.d.ts.map +1 -0
  14. package/dist/components/crm-format.js +40 -0
  15. package/dist/components/inline-currency-field.d.ts +12 -0
  16. package/dist/components/inline-currency-field.d.ts.map +1 -0
  17. package/dist/components/inline-currency-field.js +46 -0
  18. package/dist/components/inline-field.d.ts +16 -0
  19. package/dist/components/inline-field.d.ts.map +1 -0
  20. package/dist/components/inline-field.js +45 -0
  21. package/dist/components/inline-language-field.d.ts +12 -0
  22. package/dist/components/inline-language-field.d.ts.map +1 -0
  23. package/dist/components/inline-language-field.js +46 -0
  24. package/dist/components/inline-number-field.d.ts +15 -0
  25. package/dist/components/inline-number-field.d.ts.map +1 -0
  26. package/dist/components/inline-number-field.js +58 -0
  27. package/dist/components/inline-select-field.d.ts +19 -0
  28. package/dist/components/inline-select-field.d.ts.map +1 -0
  29. package/dist/components/inline-select-field.js +34 -0
  30. package/dist/components/quote-summary-card.d.ts +11 -0
  31. package/dist/components/quote-summary-card.d.ts.map +1 -0
  32. package/dist/components/quote-summary-card.js +11 -0
  33. package/dist/components/quote-version-detail-sections.d.ts +22 -0
  34. package/dist/components/quote-version-detail-sections.d.ts.map +1 -0
  35. package/dist/components/quote-version-detail-sections.js +87 -0
  36. package/dist/components/quote-versions-page.d.ts +8 -0
  37. package/dist/components/quote-versions-page.d.ts.map +1 -0
  38. package/dist/components/quote-versions-page.js +30 -0
  39. package/dist/components/quotes-board.d.ts +8 -0
  40. package/dist/components/quotes-board.d.ts.map +1 -0
  41. package/dist/components/quotes-board.js +24 -0
  42. package/dist/hooks/index.d.ts +10 -0
  43. package/dist/hooks/index.d.ts.map +1 -0
  44. package/dist/hooks/index.js +9 -0
  45. package/dist/hooks/use-pipeline-mutation.d.ts +76 -0
  46. package/dist/hooks/use-pipeline-mutation.d.ts.map +1 -0
  47. package/dist/hooks/use-pipeline-mutation.js +76 -0
  48. package/dist/hooks/use-pipelines.d.ts +31 -0
  49. package/dist/hooks/use-pipelines.d.ts.map +1 -0
  50. package/dist/hooks/use-pipelines.js +42 -0
  51. package/dist/hooks/use-quote-mutation.d.ts +72 -0
  52. package/dist/hooks/use-quote-mutation.d.ts.map +1 -0
  53. package/dist/hooks/use-quote-mutation.js +50 -0
  54. package/dist/hooks/use-quote-version-mutation.d.ts +272 -0
  55. package/dist/hooks/use-quote-version-mutation.d.ts.map +1 -0
  56. package/dist/hooks/use-quote-version-mutation.js +164 -0
  57. package/dist/hooks/use-quote-version.d.ts +37 -0
  58. package/dist/hooks/use-quote-version.d.ts.map +1 -0
  59. package/dist/hooks/use-quote-version.js +34 -0
  60. package/dist/hooks/use-quote-versions.d.ts +30 -0
  61. package/dist/hooks/use-quote-versions.d.ts.map +1 -0
  62. package/dist/hooks/use-quote-versions.js +27 -0
  63. package/dist/hooks/use-quote.d.ts +26 -0
  64. package/dist/hooks/use-quote.d.ts.map +1 -0
  65. package/dist/hooks/use-quote.js +23 -0
  66. package/dist/hooks/use-quotes.d.ts +36 -0
  67. package/dist/hooks/use-quotes.d.ts.map +1 -0
  68. package/dist/hooks/use-quotes.js +44 -0
  69. package/dist/hooks/use-stages.d.ts +37 -0
  70. package/dist/hooks/use-stages.d.ts.map +1 -0
  71. package/dist/hooks/use-stages.js +45 -0
  72. package/dist/i18n/en/base.d.ts +189 -0
  73. package/dist/i18n/en/base.d.ts.map +1 -0
  74. package/dist/i18n/en/base.js +188 -0
  75. package/dist/i18n/en/commerce.d.ts +133 -0
  76. package/dist/i18n/en/commerce.d.ts.map +1 -0
  77. package/dist/i18n/en/commerce.js +132 -0
  78. package/dist/i18n/en/detail.d.ts +211 -0
  79. package/dist/i18n/en/detail.d.ts.map +1 -0
  80. package/dist/i18n/en/detail.js +210 -0
  81. package/dist/i18n/en/lists.d.ts +75 -0
  82. package/dist/i18n/en/lists.d.ts.map +1 -0
  83. package/dist/i18n/en/lists.js +74 -0
  84. package/dist/i18n/en.d.ts +599 -0
  85. package/dist/i18n/en.d.ts.map +1 -0
  86. package/dist/i18n/en.js +10 -0
  87. package/dist/i18n/index.d.ts +5 -0
  88. package/dist/i18n/index.d.ts.map +1 -0
  89. package/dist/i18n/index.js +3 -0
  90. package/dist/i18n/messages.d.ts +577 -0
  91. package/dist/i18n/messages.d.ts.map +1 -0
  92. package/dist/i18n/messages.js +15 -0
  93. package/dist/i18n/provider.d.ts +1220 -0
  94. package/dist/i18n/provider.d.ts.map +1 -0
  95. package/dist/i18n/provider.js +44 -0
  96. package/dist/i18n/ro/base.d.ts +189 -0
  97. package/dist/i18n/ro/base.d.ts.map +1 -0
  98. package/dist/i18n/ro/base.js +188 -0
  99. package/dist/i18n/ro/commerce.d.ts +133 -0
  100. package/dist/i18n/ro/commerce.d.ts.map +1 -0
  101. package/dist/i18n/ro/commerce.js +132 -0
  102. package/dist/i18n/ro/detail.d.ts +211 -0
  103. package/dist/i18n/ro/detail.d.ts.map +1 -0
  104. package/dist/i18n/ro/detail.js +210 -0
  105. package/dist/i18n/ro/lists.d.ts +75 -0
  106. package/dist/i18n/ro/lists.d.ts.map +1 -0
  107. package/dist/i18n/ro/lists.js +74 -0
  108. package/dist/i18n/ro.d.ts +599 -0
  109. package/dist/i18n/ro.d.ts.map +1 -0
  110. package/dist/i18n/ro.js +10 -0
  111. package/dist/index.d.ts +22 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +21 -0
  114. package/dist/provider.d.ts +2 -0
  115. package/dist/provider.d.ts.map +1 -0
  116. package/dist/provider.js +1 -0
  117. package/dist/query-keys.d.ts +44 -0
  118. package/dist/query-keys.d.ts.map +1 -0
  119. package/dist/query-keys.js +16 -0
  120. package/dist/query-options.d.ts +678 -0
  121. package/dist/query-options.d.ts.map +1 -0
  122. package/dist/query-options.js +160 -0
  123. package/dist/schemas.d.ts +348 -0
  124. package/dist/schemas.d.ts.map +1 -0
  125. package/dist/schemas.js +101 -0
  126. package/dist/ui.d.ts +8 -0
  127. package/dist/ui.d.ts.map +1 -0
  128. package/dist/ui.js +7 -0
  129. package/package.json +117 -0
  130. package/src/styles.css +11 -0
@@ -0,0 +1,76 @@
1
+ export interface CreatePipelineInput {
2
+ name: string;
3
+ entityType?: string;
4
+ isDefault?: boolean;
5
+ sortOrder?: number;
6
+ [key: string]: unknown;
7
+ }
8
+ export type UpdatePipelineInput = Partial<CreatePipelineInput>;
9
+ export interface CreateStageInput {
10
+ pipelineId: string;
11
+ name: string;
12
+ sortOrder?: number;
13
+ probability?: number | null;
14
+ isClosed?: boolean;
15
+ isWon?: boolean;
16
+ isLost?: boolean;
17
+ [key: string]: unknown;
18
+ }
19
+ export type UpdateStageInput = Partial<CreateStageInput>;
20
+ export declare function usePipelineMutation(): {
21
+ createPipeline: import("@tanstack/react-query").UseMutationResult<{
22
+ id: string;
23
+ entityType: string;
24
+ name: string;
25
+ isDefault: boolean;
26
+ sortOrder: number;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }, Error, CreatePipelineInput, unknown>;
30
+ updatePipeline: import("@tanstack/react-query").UseMutationResult<{
31
+ id: string;
32
+ entityType: string;
33
+ name: string;
34
+ isDefault: boolean;
35
+ sortOrder: number;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ }, Error, {
39
+ id: string;
40
+ input: UpdatePipelineInput;
41
+ }, unknown>;
42
+ removePipeline: import("@tanstack/react-query").UseMutationResult<{
43
+ success: boolean;
44
+ }, Error, string, unknown>;
45
+ createStage: import("@tanstack/react-query").UseMutationResult<{
46
+ id: string;
47
+ pipelineId: string;
48
+ name: string;
49
+ sortOrder: number;
50
+ probability: number | null;
51
+ isClosed: boolean;
52
+ isWon: boolean;
53
+ isLost: boolean;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ }, Error, CreateStageInput, unknown>;
57
+ updateStage: import("@tanstack/react-query").UseMutationResult<{
58
+ id: string;
59
+ pipelineId: string;
60
+ name: string;
61
+ sortOrder: number;
62
+ probability: number | null;
63
+ isClosed: boolean;
64
+ isWon: boolean;
65
+ isLost: boolean;
66
+ createdAt: string;
67
+ updatedAt: string;
68
+ }, Error, {
69
+ id: string;
70
+ input: UpdateStageInput;
71
+ }, unknown>;
72
+ removeStage: import("@tanstack/react-query").UseMutationResult<{
73
+ success: boolean;
74
+ }, Error, string, unknown>;
75
+ };
76
+ //# sourceMappingURL=use-pipeline-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pipeline-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pipeline-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAE9D,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAIxD,wBAAgB,mBAAmB;;;;;;;;;;;;;;;;;;;YAoBS,MAAM;eAAS,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA8ClC,MAAM;eAAS,gBAAgB;;;;;EAsC1E"}
@@ -0,0 +1,76 @@
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 { pipelineSingleResponse, stageSingleResponse } from "../schemas.js";
8
+ const deleteResponseSchema = z.object({ success: z.boolean() });
9
+ export function usePipelineMutation() {
10
+ const { baseUrl, fetcher } = useVoyantContext();
11
+ const queryClient = useQueryClient();
12
+ const createPipeline = useMutation({
13
+ mutationFn: async (input) => {
14
+ const { data } = await fetchWithValidation("/v1/quotes/pipelines", pipelineSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
15
+ return data;
16
+ },
17
+ onSuccess: () => {
18
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.pipelines() });
19
+ },
20
+ });
21
+ const updatePipeline = useMutation({
22
+ mutationFn: async ({ id, input }) => {
23
+ const { data } = await fetchWithValidation(`/v1/quotes/pipelines/${id}`, pipelineSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
24
+ return data;
25
+ },
26
+ onSuccess: (data) => {
27
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.pipelines() });
28
+ queryClient.setQueryData(quotesQueryKeys.pipeline(data.id), data);
29
+ },
30
+ });
31
+ const removePipeline = useMutation({
32
+ mutationFn: async (id) => {
33
+ return fetchWithValidation(`/v1/quotes/pipelines/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" });
34
+ },
35
+ onSuccess: (_data, id) => {
36
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.pipelines() });
37
+ queryClient.removeQueries({ queryKey: quotesQueryKeys.pipeline(id) });
38
+ },
39
+ });
40
+ const createStage = useMutation({
41
+ mutationFn: async (input) => {
42
+ const { data } = await fetchWithValidation("/v1/quotes/stages", stageSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
43
+ return data;
44
+ },
45
+ onSuccess: () => {
46
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.stages() });
47
+ },
48
+ });
49
+ const updateStage = useMutation({
50
+ mutationFn: async ({ id, input }) => {
51
+ const { data } = await fetchWithValidation(`/v1/quotes/stages/${id}`, stageSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
52
+ return data;
53
+ },
54
+ onSuccess: (data) => {
55
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.stages() });
56
+ queryClient.setQueryData(quotesQueryKeys.stage(data.id), data);
57
+ },
58
+ });
59
+ const removeStage = useMutation({
60
+ mutationFn: async (id) => {
61
+ return fetchWithValidation(`/v1/quotes/stages/${id}`, deleteResponseSchema, { baseUrl, fetcher }, { method: "DELETE" });
62
+ },
63
+ onSuccess: (_data, id) => {
64
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.stages() });
65
+ queryClient.removeQueries({ queryKey: quotesQueryKeys.stage(id) });
66
+ },
67
+ });
68
+ return {
69
+ createPipeline,
70
+ updatePipeline,
71
+ removePipeline,
72
+ createStage,
73
+ updateStage,
74
+ removeStage,
75
+ };
76
+ }
@@ -0,0 +1,31 @@
1
+ import { type PipelinesListFilters } from "../query-keys.js";
2
+ export interface UsePipelinesOptions extends PipelinesListFilters {
3
+ enabled?: boolean;
4
+ }
5
+ export declare function usePipelines(options?: UsePipelinesOptions): import("@tanstack/react-query").UseQueryResult<{
6
+ data: {
7
+ id: string;
8
+ entityType: string;
9
+ name: string;
10
+ isDefault: boolean;
11
+ sortOrder: number;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ }[];
15
+ total: number;
16
+ limit: number;
17
+ offset: number;
18
+ }, Error>;
19
+ export interface UsePipelineOptions {
20
+ enabled?: boolean;
21
+ }
22
+ export declare function usePipeline(id: string | undefined, options?: UsePipelineOptions): import("@tanstack/react-query").UseQueryResult<{
23
+ id: string;
24
+ entityType: string;
25
+ name: string;
26
+ isDefault: boolean;
27
+ sortOrder: number;
28
+ createdAt: string;
29
+ updatedAt: string;
30
+ }, Error>;
31
+ //# sourceMappingURL=use-pipelines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-pipelines.d.ts","sourceRoot":"","sources":["../../src/hooks/use-pipelines.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,oBAAoB,EAAmB,MAAM,kBAAkB,CAAA;AAG7E,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;UAuB7D;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,GAAE,kBAAuB;;;;;;;;UAiBnF"}
@@ -0,0 +1,42 @@
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 { pipelineListResponse, pipelineSingleResponse } from "../schemas.js";
7
+ export function usePipelines(options = {}) {
8
+ const { baseUrl, fetcher } = useVoyantContext();
9
+ const { enabled = true, ...filters } = options;
10
+ return useQuery({
11
+ queryKey: quotesQueryKeys.pipelinesList(filters),
12
+ queryFn: () => {
13
+ const params = new URLSearchParams();
14
+ if (filters.entityType)
15
+ params.set("entityType", filters.entityType);
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/pipelines${qs ? `?${qs}` : ""}`, pipelineListResponse, {
22
+ baseUrl,
23
+ fetcher,
24
+ });
25
+ },
26
+ enabled,
27
+ });
28
+ }
29
+ export function usePipeline(id, options = {}) {
30
+ const { baseUrl, fetcher } = useVoyantContext();
31
+ const { enabled = true } = options;
32
+ return useQuery({
33
+ queryKey: quotesQueryKeys.pipeline(id ?? ""),
34
+ queryFn: async () => {
35
+ if (!id)
36
+ throw new Error("usePipeline requires an id");
37
+ const { data } = await fetchWithValidation(`/v1/quotes/pipelines/${id}`, pipelineSingleResponse, { baseUrl, fetcher });
38
+ return data;
39
+ },
40
+ enabled: enabled && Boolean(id),
41
+ });
42
+ }
@@ -0,0 +1,72 @@
1
+ export interface CreateQuoteInput {
2
+ title: string;
3
+ pipelineId: string;
4
+ stageId: string;
5
+ personId?: string | null;
6
+ organizationId?: string | null;
7
+ ownerId?: string | null;
8
+ status?: string;
9
+ acceptedVersionId?: string | null;
10
+ valueAmountCents?: number | null;
11
+ valueCurrency?: string | null;
12
+ expectedCloseDate?: string | null;
13
+ source?: string | null;
14
+ sourceRef?: string | null;
15
+ lostReason?: string | null;
16
+ tags?: string[];
17
+ [key: string]: unknown;
18
+ }
19
+ export type UpdateQuoteInput = Partial<CreateQuoteInput>;
20
+ export declare function useQuoteMutation(): {
21
+ create: import("@tanstack/react-query").UseMutationResult<{
22
+ id: string;
23
+ title: string;
24
+ personId: string | null;
25
+ organizationId: string | null;
26
+ pipelineId: string;
27
+ stageId: string;
28
+ ownerId: string | null;
29
+ status: string;
30
+ acceptedVersionId: string | null;
31
+ valueAmountCents: number | null;
32
+ valueCurrency: string | null;
33
+ expectedCloseDate: string | null;
34
+ source: string | null;
35
+ sourceRef: string | null;
36
+ lostReason: string | null;
37
+ tags: string[];
38
+ createdAt: string;
39
+ updatedAt: string;
40
+ stageChangedAt: string;
41
+ closedAt: string | null;
42
+ }, Error, CreateQuoteInput, unknown>;
43
+ update: import("@tanstack/react-query").UseMutationResult<{
44
+ id: string;
45
+ title: string;
46
+ personId: string | null;
47
+ organizationId: string | null;
48
+ pipelineId: string;
49
+ stageId: string;
50
+ ownerId: string | null;
51
+ status: string;
52
+ acceptedVersionId: string | null;
53
+ valueAmountCents: number | null;
54
+ valueCurrency: string | null;
55
+ expectedCloseDate: string | null;
56
+ source: string | null;
57
+ sourceRef: string | null;
58
+ lostReason: string | null;
59
+ tags: string[];
60
+ createdAt: string;
61
+ updatedAt: string;
62
+ stageChangedAt: string;
63
+ closedAt: string | null;
64
+ }, Error, {
65
+ id: string;
66
+ input: UpdateQuoteInput;
67
+ }, unknown>;
68
+ remove: import("@tanstack/react-query").UseMutationResult<{
69
+ success: boolean;
70
+ }, Error, string, unknown>;
71
+ };
72
+ //# sourceMappingURL=use-quote-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-quote-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-quote-mutation.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;AAIxD,wBAAgB,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAuBY,MAAM;eAAS,gBAAgB;;;;;EAqC1E"}
@@ -0,0 +1,50 @@
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 { quoteSingleResponse } from "../schemas.js";
8
+ const deleteResponseSchema = z.object({ success: z.boolean() });
9
+ export function useQuoteMutation() {
10
+ const { baseUrl, fetcher } = useVoyantContext();
11
+ const queryClient = useQueryClient();
12
+ const create = useMutation({
13
+ mutationFn: async (input) => {
14
+ const { data } = await fetchWithValidation("/v1/quotes/quotes", quoteSingleResponse, {
15
+ baseUrl,
16
+ fetcher,
17
+ }, { method: "POST", body: JSON.stringify(input) });
18
+ return data;
19
+ },
20
+ onSuccess: () => {
21
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quotes() });
22
+ },
23
+ });
24
+ const update = useMutation({
25
+ mutationFn: async ({ id, input }) => {
26
+ const { data } = await fetchWithValidation(`/v1/quotes/quotes/${id}`, quoteSingleResponse, {
27
+ baseUrl,
28
+ fetcher,
29
+ }, { method: "PATCH", body: JSON.stringify(input) });
30
+ return data;
31
+ },
32
+ onSuccess: (data) => {
33
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quotes() });
34
+ queryClient.setQueryData(quotesQueryKeys.quote(data.id), data);
35
+ },
36
+ });
37
+ const remove = useMutation({
38
+ mutationFn: async (id) => {
39
+ return fetchWithValidation(`/v1/quotes/quotes/${id}`, deleteResponseSchema, {
40
+ baseUrl,
41
+ fetcher,
42
+ }, { method: "DELETE" });
43
+ },
44
+ onSuccess: (_data, id) => {
45
+ void queryClient.invalidateQueries({ queryKey: quotesQueryKeys.quotes() });
46
+ queryClient.removeQueries({ queryKey: quotesQueryKeys.quote(id) });
47
+ },
48
+ });
49
+ return { create, update, remove };
50
+ }
@@ -0,0 +1,272 @@
1
+ export interface CreateQuoteVersionInput {
2
+ currency: string;
3
+ quoteId?: string;
4
+ label?: string | null;
5
+ supersedesId?: string | null;
6
+ tripSnapshotId?: string | null;
7
+ validUntil?: string | null;
8
+ subtotalAmountCents?: number;
9
+ taxAmountCents?: number;
10
+ totalAmountCents?: number;
11
+ notes?: string | null;
12
+ sentAt?: string | null;
13
+ viewedAt?: string | null;
14
+ decidedAt?: string | null;
15
+ [key: string]: unknown;
16
+ }
17
+ export type UpdateQuoteVersionInput = Partial<CreateQuoteVersionInput>;
18
+ export interface SendQuoteVersionInput {
19
+ validUntil?: string | null;
20
+ }
21
+ export interface ExpireQuoteVersionsInput {
22
+ now?: string;
23
+ }
24
+ export interface CreateQuoteVersionLineInput {
25
+ description: string;
26
+ currency: string;
27
+ quantity?: number;
28
+ unitPriceAmountCents?: number;
29
+ totalAmountCents?: number;
30
+ productId?: string | null;
31
+ supplierServiceId?: string | null;
32
+ [key: string]: unknown;
33
+ }
34
+ export type UpdateQuoteVersionLineInput = Partial<CreateQuoteVersionLineInput>;
35
+ export declare function useQuoteVersionMutation(): {
36
+ create: import("@tanstack/react-query").UseMutationResult<{
37
+ id: string;
38
+ quoteId: string;
39
+ label: string | null;
40
+ status: string;
41
+ supersedesId: string | null;
42
+ tripSnapshotId: string | null;
43
+ validUntil: string | null;
44
+ currency: string;
45
+ subtotalAmountCents: number;
46
+ taxAmountCents: number;
47
+ totalAmountCents: number;
48
+ notes: string | null;
49
+ sentAt: string | null;
50
+ viewedAt: string | null;
51
+ decidedAt: string | null;
52
+ createdAt: string;
53
+ updatedAt: string;
54
+ archivedAt: string | null;
55
+ }, Error, {
56
+ quoteId: string;
57
+ input: CreateQuoteVersionInput;
58
+ }, unknown>;
59
+ update: import("@tanstack/react-query").UseMutationResult<{
60
+ id: string;
61
+ quoteId: string;
62
+ label: string | null;
63
+ status: string;
64
+ supersedesId: string | null;
65
+ tripSnapshotId: string | null;
66
+ validUntil: string | null;
67
+ currency: string;
68
+ subtotalAmountCents: number;
69
+ taxAmountCents: number;
70
+ totalAmountCents: number;
71
+ notes: string | null;
72
+ sentAt: string | null;
73
+ viewedAt: string | null;
74
+ decidedAt: string | null;
75
+ createdAt: string;
76
+ updatedAt: string;
77
+ archivedAt: string | null;
78
+ }, Error, {
79
+ id: string;
80
+ input: UpdateQuoteVersionInput;
81
+ }, unknown>;
82
+ remove: import("@tanstack/react-query").UseMutationResult<{
83
+ success: boolean;
84
+ }, Error, string, unknown>;
85
+ send: import("@tanstack/react-query").UseMutationResult<{
86
+ id: string;
87
+ quoteId: string;
88
+ label: string | null;
89
+ status: string;
90
+ supersedesId: string | null;
91
+ tripSnapshotId: string | null;
92
+ validUntil: string | null;
93
+ currency: string;
94
+ subtotalAmountCents: number;
95
+ taxAmountCents: number;
96
+ totalAmountCents: number;
97
+ notes: string | null;
98
+ sentAt: string | null;
99
+ viewedAt: string | null;
100
+ decidedAt: string | null;
101
+ createdAt: string;
102
+ updatedAt: string;
103
+ archivedAt: string | null;
104
+ }, Error, {
105
+ id: string;
106
+ input?: SendQuoteVersionInput;
107
+ }, unknown>;
108
+ view: import("@tanstack/react-query").UseMutationResult<{
109
+ id: string;
110
+ quoteId: string;
111
+ label: string | null;
112
+ status: string;
113
+ supersedesId: string | null;
114
+ tripSnapshotId: string | null;
115
+ validUntil: string | null;
116
+ currency: string;
117
+ subtotalAmountCents: number;
118
+ taxAmountCents: number;
119
+ totalAmountCents: number;
120
+ notes: string | null;
121
+ sentAt: string | null;
122
+ viewedAt: string | null;
123
+ decidedAt: string | null;
124
+ createdAt: string;
125
+ updatedAt: string;
126
+ archivedAt: string | null;
127
+ }, Error, string, unknown>;
128
+ decline: import("@tanstack/react-query").UseMutationResult<{
129
+ id: string;
130
+ quoteId: string;
131
+ label: string | null;
132
+ status: string;
133
+ supersedesId: string | null;
134
+ tripSnapshotId: string | null;
135
+ validUntil: string | null;
136
+ currency: string;
137
+ subtotalAmountCents: number;
138
+ taxAmountCents: number;
139
+ totalAmountCents: number;
140
+ notes: string | null;
141
+ sentAt: string | null;
142
+ viewedAt: string | null;
143
+ decidedAt: string | null;
144
+ createdAt: string;
145
+ updatedAt: string;
146
+ archivedAt: string | null;
147
+ }, Error, string, unknown>;
148
+ accept: import("@tanstack/react-query").UseMutationResult<{
149
+ quote: {
150
+ id: string;
151
+ title: string;
152
+ personId: string | null;
153
+ organizationId: string | null;
154
+ pipelineId: string;
155
+ stageId: string;
156
+ ownerId: string | null;
157
+ status: string;
158
+ acceptedVersionId: string | null;
159
+ valueAmountCents: number | null;
160
+ valueCurrency: string | null;
161
+ expectedCloseDate: string | null;
162
+ source: string | null;
163
+ sourceRef: string | null;
164
+ lostReason: string | null;
165
+ tags: string[];
166
+ createdAt: string;
167
+ updatedAt: string;
168
+ stageChangedAt: string;
169
+ closedAt: string | null;
170
+ };
171
+ quoteVersion: {
172
+ id: string;
173
+ quoteId: string;
174
+ label: string | null;
175
+ status: string;
176
+ supersedesId: string | null;
177
+ tripSnapshotId: string | null;
178
+ validUntil: string | null;
179
+ currency: string;
180
+ subtotalAmountCents: number;
181
+ taxAmountCents: number;
182
+ totalAmountCents: number;
183
+ notes: string | null;
184
+ sentAt: string | null;
185
+ viewedAt: string | null;
186
+ decidedAt: string | null;
187
+ createdAt: string;
188
+ updatedAt: string;
189
+ archivedAt: string | null;
190
+ };
191
+ closedQuoteVersions: {
192
+ id: string;
193
+ quoteId: string;
194
+ label: string | null;
195
+ status: string;
196
+ supersedesId: string | null;
197
+ tripSnapshotId: string | null;
198
+ validUntil: string | null;
199
+ currency: string;
200
+ subtotalAmountCents: number;
201
+ taxAmountCents: number;
202
+ totalAmountCents: number;
203
+ notes: string | null;
204
+ sentAt: string | null;
205
+ viewedAt: string | null;
206
+ decidedAt: string | null;
207
+ createdAt: string;
208
+ updatedAt: string;
209
+ archivedAt: string | null;
210
+ }[];
211
+ }, Error, string, unknown>;
212
+ expire: import("@tanstack/react-query").UseMutationResult<{
213
+ id: string;
214
+ quoteId: string;
215
+ label: string | null;
216
+ status: string;
217
+ supersedesId: string | null;
218
+ tripSnapshotId: string | null;
219
+ validUntil: string | null;
220
+ currency: string;
221
+ subtotalAmountCents: number;
222
+ taxAmountCents: number;
223
+ totalAmountCents: number;
224
+ notes: string | null;
225
+ sentAt: string | null;
226
+ viewedAt: string | null;
227
+ decidedAt: string | null;
228
+ createdAt: string;
229
+ updatedAt: string;
230
+ archivedAt: string | null;
231
+ }[], Error, ExpireQuoteVersionsInput | undefined, unknown>;
232
+ createLine: import("@tanstack/react-query").UseMutationResult<{
233
+ id: string;
234
+ quoteVersionId: string;
235
+ productId: string | null;
236
+ supplierServiceId: string | null;
237
+ description: string;
238
+ quantity: number;
239
+ unitPriceAmountCents: number;
240
+ totalAmountCents: number;
241
+ currency: string;
242
+ createdAt: string;
243
+ updatedAt: string;
244
+ }, Error, {
245
+ quoteVersionId: string;
246
+ input: CreateQuoteVersionLineInput;
247
+ }, unknown>;
248
+ updateLine: import("@tanstack/react-query").UseMutationResult<{
249
+ id: string;
250
+ quoteVersionId: string;
251
+ productId: string | null;
252
+ supplierServiceId: string | null;
253
+ description: string;
254
+ quantity: number;
255
+ unitPriceAmountCents: number;
256
+ totalAmountCents: number;
257
+ currency: string;
258
+ createdAt: string;
259
+ updatedAt: string;
260
+ }, Error, {
261
+ quoteVersionId: string;
262
+ lineId: string;
263
+ input: UpdateQuoteVersionLineInput;
264
+ }, unknown>;
265
+ removeLine: import("@tanstack/react-query").UseMutationResult<{
266
+ success: boolean;
267
+ }, Error, {
268
+ quoteVersionId: string;
269
+ lineId: string;
270
+ }, unknown>;
271
+ };
272
+ //# sourceMappingURL=use-quote-version-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-quote-version-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-quote-version-mutation.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AAEtE,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED,MAAM,WAAW,wBAAwB;IACvC,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAA;AAK9E,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;iBAKe,MAAM;eAAS,uBAAuB;;;;;;;;;;;;;;;;;;;;;;YAmBhD,MAAM;eAAS,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;YAgCtC,MAAM;gBAAU,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqG3D,MAAM;eACf,2BAA2B;;;;;;;;;;;;;;;wBA0BlB,MAAM;gBACd,MAAM;eACP,2BAA2B;;;;;wBAyBlB,MAAM;gBACd,MAAM;;EAgCnB"}