@voyantjs/distribution-react 0.105.2 → 0.107.0

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 (66) hide show
  1. package/README.md +56 -10
  2. package/dist/components/booking-link-detail-page.d.ts +10 -0
  3. package/dist/components/booking-link-detail-page.d.ts.map +1 -0
  4. package/dist/components/booking-link-detail-page.js +51 -0
  5. package/dist/components/channel-detail-page.d.ts +12 -0
  6. package/dist/components/channel-detail-page.d.ts.map +1 -0
  7. package/dist/components/channel-detail-page.js +41 -0
  8. package/dist/components/channel-sync-page.d.ts +8 -0
  9. package/dist/components/channel-sync-page.d.ts.map +1 -0
  10. package/dist/components/channel-sync-page.js +257 -0
  11. package/dist/components/channels-page.d.ts +6 -0
  12. package/dist/components/channels-page.d.ts.map +1 -0
  13. package/dist/components/channels-page.js +132 -0
  14. package/dist/components/commission-rule-detail-page.d.ts +10 -0
  15. package/dist/components/commission-rule-detail-page.d.ts.map +1 -0
  16. package/dist/components/commission-rule-detail-page.js +57 -0
  17. package/dist/components/contract-detail-page.d.ts +10 -0
  18. package/dist/components/contract-detail-page.d.ts.map +1 -0
  19. package/dist/components/contract-detail-page.js +64 -0
  20. package/dist/components/distribution-overview.d.ts +19 -0
  21. package/dist/components/distribution-overview.d.ts.map +1 -0
  22. package/dist/components/distribution-overview.js +13 -0
  23. package/dist/components/distribution-page.d.ts +26 -0
  24. package/dist/components/distribution-page.d.ts.map +1 -0
  25. package/dist/components/distribution-page.js +190 -0
  26. package/dist/components/distribution-section-header.d.ts +7 -0
  27. package/dist/components/distribution-section-header.d.ts.map +1 -0
  28. package/dist/components/distribution-section-header.js +6 -0
  29. package/dist/components/distribution-shared.d.ts +32 -0
  30. package/dist/components/distribution-shared.d.ts.map +1 -0
  31. package/dist/components/distribution-shared.js +246 -0
  32. package/dist/components/distribution-tabs-primary.d.ts +57 -0
  33. package/dist/components/distribution-tabs-primary.d.ts.map +1 -0
  34. package/dist/components/distribution-tabs-primary.js +89 -0
  35. package/dist/components/distribution-tabs-secondary.d.ts +58 -0
  36. package/dist/components/distribution-tabs-secondary.d.ts.map +1 -0
  37. package/dist/components/distribution-tabs-secondary.js +89 -0
  38. package/dist/components/mapping-detail-page.d.ts +10 -0
  39. package/dist/components/mapping-detail-page.d.ts.map +1 -0
  40. package/dist/components/mapping-detail-page.js +51 -0
  41. package/dist/components/webhook-event-detail-page.d.ts +9 -0
  42. package/dist/components/webhook-event-detail-page.d.ts.map +1 -0
  43. package/dist/components/webhook-event-detail-page.js +46 -0
  44. package/dist/i18n/en.d.ts +592 -0
  45. package/dist/i18n/en.d.ts.map +1 -0
  46. package/dist/i18n/en.js +561 -0
  47. package/dist/i18n/index.d.ts +5 -0
  48. package/dist/i18n/index.d.ts.map +1 -0
  49. package/dist/i18n/index.js +3 -0
  50. package/dist/i18n/messages.d.ts +409 -0
  51. package/dist/i18n/messages.d.ts.map +1 -0
  52. package/dist/i18n/messages.js +1 -0
  53. package/dist/i18n/provider.d.ts +1207 -0
  54. package/dist/i18n/provider.d.ts.map +1 -0
  55. package/dist/i18n/provider.js +44 -0
  56. package/dist/i18n/ro.d.ts +592 -0
  57. package/dist/i18n/ro.d.ts.map +1 -0
  58. package/dist/i18n/ro.js +561 -0
  59. package/dist/i18n/utils.d.ts +4 -0
  60. package/dist/i18n/utils.d.ts.map +1 -0
  61. package/dist/i18n/utils.js +8 -0
  62. package/dist/ui.d.ts +16 -0
  63. package/dist/ui.d.ts.map +1 -0
  64. package/dist/ui.js +14 -0
  65. package/package.json +53 -9
  66. package/src/styles.css +11 -0
@@ -0,0 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3
+ import { Badge, Button, Card, CardContent, CardHeader, CardTitle, ConfirmActionButton, } from "@voyantjs/ui/components";
4
+ import { cn } from "@voyantjs/ui/lib/utils";
5
+ import { ArrowLeft, Link2, Loader2, Package } from "lucide-react";
6
+ import { useDistributionUiI18nOrDefault } from "../i18n/index.js";
7
+ import { distributionQueryKeys, fetchWithValidation, getChannelQueryOptions, getMappingQueryOptions, getProductQueryOptions, successEnvelope, useVoyantDistributionContext, } from "../index.js";
8
+ import { formatDistributionDateTime } from "./distribution-shared.js";
9
+ const noop = () => { };
10
+ export function MappingDetailPage({ id, className, onBack = noop, onDeleted = noop, onChannelOpen = noop, onProductOpen = noop, }) {
11
+ const i18n = useDistributionUiI18nOrDefault();
12
+ const { messages } = i18n;
13
+ const detail = messages.details.mapping;
14
+ const client = useVoyantDistributionContext();
15
+ const queryClient = useQueryClient();
16
+ const mappingQuery = useQuery({
17
+ ...getMappingQueryOptions(client, id),
18
+ select: (result) => result.data,
19
+ });
20
+ const mapping = mappingQuery.data;
21
+ const channelQuery = useQuery({
22
+ ...getChannelQueryOptions(client, mapping?.channelId),
23
+ select: (result) => result.data,
24
+ enabled: Boolean(mapping?.channelId),
25
+ });
26
+ const productQuery = useQuery({
27
+ ...getProductQueryOptions(client, mapping?.productId),
28
+ select: (result) => result.data,
29
+ enabled: Boolean(mapping?.productId),
30
+ });
31
+ const remove = useMutation({
32
+ mutationFn: () => fetchWithValidation(`/v1/distribution/product-mappings/${id}`, successEnvelope, client, {
33
+ method: "DELETE", // i18n-literal-ok HTTP method
34
+ }),
35
+ onSuccess: () => {
36
+ void queryClient.invalidateQueries({ queryKey: distributionQueryKeys.mappings() });
37
+ queryClient.removeQueries({ queryKey: distributionQueryKeys.mapping(id) });
38
+ onDeleted();
39
+ onBack();
40
+ },
41
+ });
42
+ if (mappingQuery.isPending) {
43
+ return (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }));
44
+ }
45
+ if (!mapping) {
46
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-12", children: [_jsx("p", { className: "text-muted-foreground", children: detail.notFound }), _jsx(Button, { variant: "outline", onClick: onBack, children: messages.common.backToDistribution })] }));
47
+ }
48
+ return (_jsxs("div", { "data-slot": "mapping-detail-page", className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Button, { variant: "ghost", size: "icon", onClick: onBack, children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "flex-1", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: detail.title }), _jsxs("div", { className: "mt-1 flex items-center gap-2", children: [_jsx(Badge, { variant: mapping.active ? "default" : "secondary", children: mapping.active ? messages.common.active : messages.common.inactive }), _jsx(Badge, { variant: "outline", children: mapping.externalProductId })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => onChannelOpen(mapping.channelId), children: [_jsx(Link2, { className: "mr-2 h-4 w-4" }), detail.openChannel] }), _jsxs(Button, { variant: "outline", onClick: () => onProductOpen(mapping.productId), children: [_jsx(Package, { className: "mr-2 h-4 w-4" }), detail.openProduct] }), _jsx(ConfirmActionButton, { buttonLabel: detail.deleteButton, confirmLabel: detail.deleteButton, title: detail.deleteConfirm, description: detail.deleteDescription, variant: "destructive", confirmVariant: "destructive", disabled: remove.isPending, onConfirm: async () => {
49
+ await remove.mutateAsync();
50
+ } })] })] }), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: detail.sections.details }) }), _jsxs(CardContent, { className: "grid gap-3 text-sm md:grid-cols-2", children: [_jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.channelLabel, ":"] }), " ", _jsx("span", { children: channelQuery.data?.name ?? mapping.channelId })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.productLabel, ":"] }), " ", _jsx("span", { children: productQuery.data?.name ?? mapping.productId })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [detail.labels.externalProduct, ":"] }), " ", _jsx("span", { children: mapping.externalProductId })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [detail.labels.externalRate, ":"] }), " ", _jsx("span", { children: mapping.externalRateId ?? messages.common.none })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [detail.labels.externalCategory, ":"] }), " ", _jsx("span", { children: mapping.externalCategoryId ?? messages.common.none })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.createdLabel, ":"] }), " ", _jsx("span", { children: formatDistributionDateTime(mapping.createdAt, i18n) })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.updatedLabel, ":"] }), " ", _jsx("span", { children: formatDistributionDateTime(mapping.updatedAt, i18n) })] })] })] })] }));
51
+ }
@@ -0,0 +1,9 @@
1
+ export interface WebhookEventDetailPageProps {
2
+ id: string;
3
+ className?: string;
4
+ onBack?: () => void;
5
+ onDeleted?: () => void;
6
+ onChannelOpen?: (channelId: string) => void;
7
+ }
8
+ export declare function WebhookEventDetailPage({ id, className, onBack, onDeleted, onChannelOpen, }: WebhookEventDetailPageProps): import("react/jsx-runtime").JSX.Element;
9
+ //# sourceMappingURL=webhook-event-detail-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhook-event-detail-page.d.ts","sourceRoot":"","sources":["../../src/components/webhook-event-detail-page.tsx"],"names":[],"mappings":"AAuBA,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5C;AAID,wBAAgB,sBAAsB,CAAC,EACrC,EAAE,EACF,SAAS,EACT,MAAa,EACb,SAAgB,EAChB,aAAoB,GACrB,EAAE,2BAA2B,2CA0I7B"}
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
3
+ import { Badge, Button, Card, CardContent, CardHeader, CardTitle, ConfirmActionButton, } from "@voyantjs/ui/components";
4
+ import { cn } from "@voyantjs/ui/lib/utils";
5
+ import { ArrowLeft, Link2, Loader2, Webhook } from "lucide-react";
6
+ import { useDistributionUiI18nOrDefault } from "../i18n/index.js";
7
+ import { distributionQueryKeys, fetchWithValidation, getChannelQueryOptions, getWebhookEventQueryOptions, successEnvelope, useVoyantDistributionContext, } from "../index.js";
8
+ import { formatDistributionDateTime } from "./distribution-shared.js";
9
+ const noop = () => { };
10
+ export function WebhookEventDetailPage({ id, className, onBack = noop, onDeleted = noop, onChannelOpen = noop, }) {
11
+ const i18n = useDistributionUiI18nOrDefault();
12
+ const { messages } = i18n;
13
+ const detail = messages.details.webhookEvent;
14
+ const client = useVoyantDistributionContext();
15
+ const queryClient = useQueryClient();
16
+ const eventQuery = useQuery({
17
+ ...getWebhookEventQueryOptions(client, id),
18
+ select: (result) => result.data,
19
+ });
20
+ const event = eventQuery.data;
21
+ const channelQuery = useQuery({
22
+ ...getChannelQueryOptions(client, event?.channelId),
23
+ select: (result) => result.data,
24
+ enabled: Boolean(event?.channelId),
25
+ });
26
+ const remove = useMutation({
27
+ mutationFn: () => fetchWithValidation(`/v1/distribution/webhook-events/${id}`, successEnvelope, client, {
28
+ method: "DELETE", // i18n-literal-ok HTTP method
29
+ }),
30
+ onSuccess: () => {
31
+ void queryClient.invalidateQueries({ queryKey: distributionQueryKeys.webhookEvents() });
32
+ queryClient.removeQueries({ queryKey: distributionQueryKeys.webhookEvent(id) });
33
+ onDeleted();
34
+ onBack();
35
+ },
36
+ });
37
+ if (eventQuery.isPending) {
38
+ return (_jsx("div", { className: "flex items-center justify-center py-12", children: _jsx(Loader2, { className: "h-6 w-6 animate-spin text-muted-foreground" }) }));
39
+ }
40
+ if (!event) {
41
+ return (_jsxs("div", { className: "flex flex-col items-center justify-center gap-4 py-12", children: [_jsx("p", { className: "text-muted-foreground", children: detail.notFound }), _jsx(Button, { variant: "outline", onClick: onBack, children: messages.common.backToDistribution })] }));
42
+ }
43
+ return (_jsxs("div", { "data-slot": "webhook-event-detail-page", className: cn("flex flex-col gap-6 p-6", className), children: [_jsxs("div", { className: "flex items-center gap-4", children: [_jsx(Button, { variant: "ghost", size: "icon", onClick: onBack, children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "flex-1", children: [_jsx("h1", { className: "text-2xl font-bold tracking-tight", children: detail.title }), _jsxs("div", { className: "mt-1 flex items-center gap-2", children: [_jsx(Badge, { variant: "outline", children: messages.common.webhookStatusLabels[event.status] }), _jsx(Badge, { variant: "secondary", children: event.eventType })] })] }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsxs(Button, { variant: "outline", onClick: () => onChannelOpen(event.channelId), children: [_jsx(Link2, { className: "mr-2 h-4 w-4" }), detail.openChannel] }), _jsx(ConfirmActionButton, { buttonLabel: detail.deleteButton, confirmLabel: detail.deleteButton, title: detail.deleteConfirm, description: detail.deleteDescription, variant: "destructive", confirmVariant: "destructive", disabled: remove.isPending, onConfirm: async () => {
44
+ await remove.mutateAsync();
45
+ } })] })] }), _jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [_jsxs(Card, { children: [_jsxs(CardHeader, { className: "flex flex-row items-center gap-2", children: [_jsx(Webhook, { className: "h-4 w-4" }), _jsx(CardTitle, { children: detail.sections.details })] }), _jsxs(CardContent, { className: "grid gap-3 text-sm", children: [_jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.channelLabel, ":"] }), " ", _jsx("span", { children: channelQuery.data?.name ?? event.channelId })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [detail.labels.externalEvent, ":"] }), " ", _jsx("span", { children: event.externalEventId ?? messages.common.none })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [detail.labels.received, ":"] }), " ", _jsx("span", { children: formatDistributionDateTime(event.receivedAt, i18n) })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [detail.labels.processed, ":"] }), " ", _jsx("span", { children: formatDistributionDateTime(event.processedAt, i18n) })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.createdLabel, ":"] }), " ", _jsx("span", { children: formatDistributionDateTime(event.createdAt, i18n) })] }), _jsxs("div", { children: [_jsxs("span", { className: "text-muted-foreground", children: [messages.common.updatedLabel, ":"] }), " ", _jsx("span", { children: formatDistributionDateTime(event.updatedAt, i18n) })] }), event.errorMessage ? (_jsxs("div", { children: [_jsx("div", { className: "mb-1 text-muted-foreground", children: detail.labels.error }), _jsx("div", { className: "whitespace-pre-wrap rounded-md border p-3", children: event.errorMessage })] })) : null] })] }), _jsxs(Card, { children: [_jsx(CardHeader, { children: _jsx(CardTitle, { children: detail.sections.payload }) }), _jsx(CardContent, { className: "text-sm", children: _jsx("pre", { className: "overflow-x-auto rounded-md bg-muted p-3 text-xs", children: JSON.stringify(event.payload, null, 2) }) })] })] })] }));
46
+ }