@voyant-travel/identity-react 0.119.1
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 +14 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +58 -0
- package/dist/components/address-dialog.d.ts +11 -0
- package/dist/components/address-dialog.d.ts.map +1 -0
- package/dist/components/address-dialog.js +130 -0
- package/dist/components/contact-point-dialog.d.ts +11 -0
- package/dist/components/contact-point-dialog.d.ts.map +1 -0
- package/dist/components/contact-point-dialog.js +78 -0
- package/dist/components/entity-ref-picker.d.ts +21 -0
- package/dist/components/entity-ref-picker.d.ts.map +1 -0
- package/dist/components/entity-ref-picker.js +38 -0
- package/dist/components/identity-page.d.ts +20 -0
- package/dist/components/identity-page.d.ts.map +1 -0
- package/dist/components/identity-page.js +230 -0
- package/dist/components/named-contact-dialog.d.ts +11 -0
- package/dist/components/named-contact-dialog.d.ts.map +1 -0
- package/dist/components/named-contact-dialog.js +101 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/use-address-mutation.d.ts +72 -0
- package/dist/hooks/use-address-mutation.d.ts.map +1 -0
- package/dist/hooks/use-address-mutation.js +40 -0
- package/dist/hooks/use-addresses.d.ts +31 -0
- package/dist/hooks/use-addresses.d.ts.map +1 -0
- package/dist/hooks/use-addresses.js +12 -0
- package/dist/hooks/use-contact-point-mutation.d.ts +51 -0
- package/dist/hooks/use-contact-point-mutation.d.ts.map +1 -0
- package/dist/hooks/use-contact-point-mutation.js +40 -0
- package/dist/hooks/use-contact-points.d.ts +24 -0
- package/dist/hooks/use-contact-points.d.ts.map +1 -0
- package/dist/hooks/use-contact-points.js +12 -0
- package/dist/hooks/use-named-contact-mutation.d.ts +54 -0
- package/dist/hooks/use-named-contact-mutation.d.ts.map +1 -0
- package/dist/hooks/use-named-contact-mutation.js +40 -0
- package/dist/hooks/use-named-contacts.d.ts +25 -0
- package/dist/hooks/use-named-contacts.d.ts.map +1 -0
- package/dist/hooks/use-named-contacts.js +12 -0
- package/dist/i18n/en.d.ts +193 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +192 -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 +161 -0
- package/dist/i18n/messages.d.ts.map +1 -0
- package/dist/i18n/messages.js +1 -0
- package/dist/i18n/provider.d.ts +408 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +44 -0
- package/dist/i18n/ro.d.ts +193 -0
- package/dist/i18n/ro.d.ts.map +1 -0
- package/dist/i18n/ro.js +192 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -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 +40 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +12 -0
- package/dist/query-options.d.ts +489 -0
- package/dist/query-options.d.ts.map +1 -0
- package/dist/query-options.js +63 -0
- package/dist/schemas.d.ts +278 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +52 -0
- package/dist/ui.d.ts +7 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +6 -0
- package/package.json +146 -0
- package/src/styles.css +11 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type IdentityTab = "contact-points" | "addresses" | "named-contacts";
|
|
2
|
+
export interface IdentityPageProps {
|
|
3
|
+
entityType?: string;
|
|
4
|
+
entityId?: string;
|
|
5
|
+
tab?: IdentityTab;
|
|
6
|
+
onScopeChange?: (scope: {
|
|
7
|
+
entityType: string;
|
|
8
|
+
entityId: string;
|
|
9
|
+
}) => void;
|
|
10
|
+
onTabChange?: (tab: IdentityTab) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function IdentityPage({ entityType, entityId, tab, onScopeChange, onTabChange, }?: IdentityPageProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export interface IdentityEntityTabProps {
|
|
14
|
+
entityType: string;
|
|
15
|
+
entityId: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function ContactPointsTab({ entityType, entityId }: IdentityEntityTabProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare function AddressesTab({ entityType, entityId }: IdentityEntityTabProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function NamedContactsTab({ entityType, entityId }: IdentityEntityTabProps): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
//# sourceMappingURL=identity-page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity-page.d.ts","sourceRoot":"","sources":["../../src/components/identity-page.tsx"],"names":[],"mappings":"AA2BA,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,WAAW,GAAG,gBAAgB,CAAA;AAE3E,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,GAAG,CAAC,EAAE,WAAW,CAAA;IACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACzE,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAA;CACzC;AAED,wBAAgB,YAAY,CAAC,EAC3B,UAAU,EACV,QAAQ,EACR,GAAG,EACH,aAAa,EACb,WAAW,GACZ,GAAE,iBAAsB,2CA2ExB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,sBAAsB,2CAmHhF;AAED,wBAAgB,YAAY,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,sBAAsB,2CA4H5E;AAED,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,sBAAsB,2CAiIhF"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Badge, Button } from "@voyant-travel/ui/components";
|
|
4
|
+
import { DataTable } from "@voyant-travel/ui/components/data-table";
|
|
5
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@voyant-travel/ui/components/tabs";
|
|
6
|
+
import { IdCard, Pencil, Plus, Star, Trash2 } from "lucide-react";
|
|
7
|
+
import { useMemo, useState } from "react";
|
|
8
|
+
import { useIdentityUiMessagesOrDefault } from "../i18n/index.js";
|
|
9
|
+
import { useAddresses, useAddressMutation, useContactPointMutation, useContactPoints, useNamedContactMutation, useNamedContacts, } from "../index.js";
|
|
10
|
+
import { AddressDialog } from "./address-dialog.js";
|
|
11
|
+
import { ContactPointDialog } from "./contact-point-dialog.js";
|
|
12
|
+
import { EntityRefPicker } from "./entity-ref-picker.js";
|
|
13
|
+
import { NamedContactDialog } from "./named-contact-dialog.js";
|
|
14
|
+
const PAGE_SIZE = 25;
|
|
15
|
+
export function IdentityPage({ entityType, entityId, tab, onScopeChange, onTabChange, } = {}) {
|
|
16
|
+
const messages = useIdentityUiMessagesOrDefault();
|
|
17
|
+
const pageMessages = messages.identityPage;
|
|
18
|
+
const [innerEntityType, setInnerEntityType] = useState(entityType ?? "");
|
|
19
|
+
const [innerEntityId, setInnerEntityId] = useState(entityId ?? "");
|
|
20
|
+
const [innerTab, setInnerTab] = useState(tab ?? "contact-points");
|
|
21
|
+
const activeEntityType = entityType ?? innerEntityType;
|
|
22
|
+
const activeEntityId = entityId ?? innerEntityId;
|
|
23
|
+
const activeTab = tab ?? innerTab;
|
|
24
|
+
const scopeReady = activeEntityType.trim().length > 0 && activeEntityId.trim().length > 0;
|
|
25
|
+
const updateScope = (next) => {
|
|
26
|
+
const nextEntityType = next.entityType ?? activeEntityType;
|
|
27
|
+
const nextEntityId = next.entityId ?? activeEntityId;
|
|
28
|
+
if (entityType === undefined)
|
|
29
|
+
setInnerEntityType(nextEntityType);
|
|
30
|
+
if (entityId === undefined)
|
|
31
|
+
setInnerEntityId(nextEntityId);
|
|
32
|
+
onScopeChange?.({ entityType: nextEntityType, entityId: nextEntityId });
|
|
33
|
+
};
|
|
34
|
+
const updateTab = (next) => {
|
|
35
|
+
if (tab === undefined)
|
|
36
|
+
setInnerTab(next);
|
|
37
|
+
onTabChange?.(next);
|
|
38
|
+
};
|
|
39
|
+
return (_jsxs("div", { className: "flex flex-col gap-6 p-6", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(IdCard, { className: "size-5 text-muted-foreground", "aria-hidden": "true" }), _jsx("h1", { className: "text-2xl font-bold tracking-tight", children: pageMessages.title })] }), _jsx("p", { className: "max-w-2xl text-sm text-muted-foreground", children: pageMessages.description }), _jsx(EntityRefPicker, { entityType: activeEntityType, entityId: activeEntityId, onChange: updateScope, messages: {
|
|
40
|
+
entityTypeLabel: pageMessages.fields.entityType,
|
|
41
|
+
entityLabel: pageMessages.fields.entity,
|
|
42
|
+
customEntityTypeLabel: pageMessages.fields.customEntityType,
|
|
43
|
+
typePlaceholder: pageMessages.placeholders.entityType,
|
|
44
|
+
entityPlaceholder: pageMessages.placeholders.entity,
|
|
45
|
+
entityTypeLabels: pageMessages.entityTypeLabels,
|
|
46
|
+
} }), !scopeReady ? (_jsx("div", { className: "rounded-md border border-dashed p-12 text-center", children: _jsx("p", { className: "text-sm text-muted-foreground", children: pageMessages.emptyScope }) })) : (_jsxs(Tabs, { value: activeTab, onValueChange: (value) => updateTab(value), className: "w-full", children: [_jsxs(TabsList, { children: [_jsx(TabsTrigger, { value: "contact-points", children: pageMessages.tabs.contactPoints }), _jsx(TabsTrigger, { value: "addresses", children: pageMessages.tabs.addresses }), _jsx(TabsTrigger, { value: "named-contacts", children: pageMessages.tabs.namedContacts })] }), _jsx(TabsContent, { value: "contact-points", className: "mt-4", children: _jsx(ContactPointsTab, { entityType: activeEntityType, entityId: activeEntityId }) }), _jsx(TabsContent, { value: "addresses", className: "mt-4", children: _jsx(AddressesTab, { entityType: activeEntityType, entityId: activeEntityId }) }), _jsx(TabsContent, { value: "named-contacts", className: "mt-4", children: _jsx(NamedContactsTab, { entityType: activeEntityType, entityId: activeEntityId }) })] }))] }));
|
|
47
|
+
}
|
|
48
|
+
export function ContactPointsTab({ entityType, entityId }) {
|
|
49
|
+
const messages = useIdentityUiMessagesOrDefault();
|
|
50
|
+
const tabMessages = messages.contactPointsTab;
|
|
51
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
52
|
+
const [editing, setEditing] = useState();
|
|
53
|
+
const { data, isPending, refetch } = useContactPoints({
|
|
54
|
+
entityType,
|
|
55
|
+
entityId,
|
|
56
|
+
limit: PAGE_SIZE,
|
|
57
|
+
offset: 0,
|
|
58
|
+
enabled: Boolean(entityType) && Boolean(entityId),
|
|
59
|
+
});
|
|
60
|
+
const { remove } = useContactPointMutation();
|
|
61
|
+
const columns = useMemo(() => [
|
|
62
|
+
{
|
|
63
|
+
accessorKey: "kind",
|
|
64
|
+
header: tabMessages.columns.kind,
|
|
65
|
+
cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: messages.common.contactPointKindLabels[row.original.kind] })),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
accessorKey: "value",
|
|
69
|
+
header: tabMessages.columns.value,
|
|
70
|
+
cell: ({ row }) => _jsx("span", { className: "font-medium", children: row.original.value }),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
accessorKey: "label",
|
|
74
|
+
header: tabMessages.columns.label,
|
|
75
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground", children: row.original.label ?? "-" })),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
accessorKey: "isPrimary",
|
|
79
|
+
header: tabMessages.columns.primary,
|
|
80
|
+
cell: ({ row }) => row.original.isPrimary ? (_jsx(Star, { className: "size-3.5 fill-current text-amber-500", "aria-hidden": "true" })) : null,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "actions",
|
|
84
|
+
header: () => _jsx("div", { className: "w-20" }),
|
|
85
|
+
cell: ({ row }) => (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => {
|
|
86
|
+
setEditing(row.original);
|
|
87
|
+
setDialogOpen(true);
|
|
88
|
+
}, className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "size-3.5", "aria-hidden": "true" }) }), _jsx("button", { type: "button", onClick: () => {
|
|
89
|
+
if (confirm(tabMessages.actions.deleteConfirm)) {
|
|
90
|
+
remove.mutate(row.original.id, { onSuccess: () => void refetch() });
|
|
91
|
+
}
|
|
92
|
+
}, className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "size-3.5", "aria-hidden": "true" }) })] })),
|
|
93
|
+
},
|
|
94
|
+
], [refetch, remove, messages.common.contactPointKindLabels, tabMessages]);
|
|
95
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: tabMessages.description }), _jsxs(Button, { size: "sm", onClick: () => {
|
|
96
|
+
setEditing(undefined);
|
|
97
|
+
setDialogOpen(true);
|
|
98
|
+
}, children: [_jsx(Plus, { className: "mr-2 size-4", "aria-hidden": "true" }), tabMessages.add] })] }), _jsx(DataTable, { columns: columns, data: data?.data ?? [], emptyMessage: isPending ? tabMessages.empty.loading : tabMessages.empty.none, pageSize: PAGE_SIZE }), _jsx(ContactPointDialog, { open: dialogOpen, onOpenChange: setDialogOpen, entityType: entityType, entityId: entityId, contactPoint: editing, onSuccess: () => {
|
|
99
|
+
setDialogOpen(false);
|
|
100
|
+
setEditing(undefined);
|
|
101
|
+
void refetch();
|
|
102
|
+
} })] }));
|
|
103
|
+
}
|
|
104
|
+
export function AddressesTab({ entityType, entityId }) {
|
|
105
|
+
const messages = useIdentityUiMessagesOrDefault();
|
|
106
|
+
const tabMessages = messages.addressesTab;
|
|
107
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
108
|
+
const [editing, setEditing] = useState();
|
|
109
|
+
const { data, isPending, refetch } = useAddresses({
|
|
110
|
+
entityType,
|
|
111
|
+
entityId,
|
|
112
|
+
limit: PAGE_SIZE,
|
|
113
|
+
offset: 0,
|
|
114
|
+
enabled: Boolean(entityType) && Boolean(entityId),
|
|
115
|
+
});
|
|
116
|
+
const { remove } = useAddressMutation();
|
|
117
|
+
const columns = useMemo(() => [
|
|
118
|
+
{
|
|
119
|
+
accessorKey: "label",
|
|
120
|
+
header: tabMessages.columns.label,
|
|
121
|
+
cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: messages.common.addressLabelLabels[row.original.label] })),
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
accessorKey: "line1",
|
|
125
|
+
header: tabMessages.columns.street,
|
|
126
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground", children: row.original.line1 ?? "-" })),
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
accessorKey: "city",
|
|
130
|
+
header: tabMessages.columns.city,
|
|
131
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground", children: row.original.city ?? "-" })),
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
accessorKey: "country",
|
|
135
|
+
header: tabMessages.columns.country,
|
|
136
|
+
cell: ({ row }) => (_jsx("span", { className: "font-mono text-xs text-muted-foreground", children: row.original.country ?? "-" })),
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
accessorKey: "isPrimary",
|
|
140
|
+
header: tabMessages.columns.primary,
|
|
141
|
+
cell: ({ row }) => row.original.isPrimary ? (_jsx(Star, { className: "size-3.5 fill-current text-amber-500", "aria-hidden": "true" })) : null,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "actions",
|
|
145
|
+
header: () => _jsx("div", { className: "w-20" }),
|
|
146
|
+
cell: ({ row }) => (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => {
|
|
147
|
+
setEditing(row.original);
|
|
148
|
+
setDialogOpen(true);
|
|
149
|
+
}, className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "size-3.5", "aria-hidden": "true" }) }), _jsx("button", { type: "button", onClick: () => {
|
|
150
|
+
if (confirm(tabMessages.actions.deleteConfirm)) {
|
|
151
|
+
remove.mutate(row.original.id, { onSuccess: () => void refetch() });
|
|
152
|
+
}
|
|
153
|
+
}, className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "size-3.5", "aria-hidden": "true" }) })] })),
|
|
154
|
+
},
|
|
155
|
+
], [refetch, remove, messages.common.addressLabelLabels, tabMessages]);
|
|
156
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: tabMessages.description }), _jsxs(Button, { size: "sm", onClick: () => {
|
|
157
|
+
setEditing(undefined);
|
|
158
|
+
setDialogOpen(true);
|
|
159
|
+
}, children: [_jsx(Plus, { className: "mr-2 size-4", "aria-hidden": "true" }), tabMessages.add] })] }), _jsx(DataTable, { columns: columns, data: data?.data ?? [], emptyMessage: isPending ? tabMessages.empty.loading : tabMessages.empty.none, pageSize: PAGE_SIZE }), _jsx(AddressDialog, { open: dialogOpen, onOpenChange: setDialogOpen, entityType: entityType, entityId: entityId, address: editing, onSuccess: () => {
|
|
160
|
+
setDialogOpen(false);
|
|
161
|
+
setEditing(undefined);
|
|
162
|
+
void refetch();
|
|
163
|
+
} })] }));
|
|
164
|
+
}
|
|
165
|
+
export function NamedContactsTab({ entityType, entityId }) {
|
|
166
|
+
const messages = useIdentityUiMessagesOrDefault();
|
|
167
|
+
const tabMessages = messages.namedContactsTab;
|
|
168
|
+
const [dialogOpen, setDialogOpen] = useState(false);
|
|
169
|
+
const [editing, setEditing] = useState();
|
|
170
|
+
const { data, isPending, refetch } = useNamedContacts({
|
|
171
|
+
entityType,
|
|
172
|
+
entityId,
|
|
173
|
+
limit: PAGE_SIZE,
|
|
174
|
+
offset: 0,
|
|
175
|
+
enabled: Boolean(entityType) && Boolean(entityId),
|
|
176
|
+
});
|
|
177
|
+
const { remove } = useNamedContactMutation();
|
|
178
|
+
const columns = useMemo(() => [
|
|
179
|
+
{
|
|
180
|
+
accessorKey: "role",
|
|
181
|
+
header: tabMessages.columns.role,
|
|
182
|
+
cell: ({ row }) => (_jsx(Badge, { variant: "outline", children: messages.common.namedContactRoleLabels[row.original.role] })),
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
accessorKey: "name",
|
|
186
|
+
header: tabMessages.columns.name,
|
|
187
|
+
cell: ({ row }) => _jsx("span", { className: "font-medium", children: row.original.name }),
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
accessorKey: "title",
|
|
191
|
+
header: tabMessages.columns.title,
|
|
192
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground", children: row.original.title ?? "-" })),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
accessorKey: "email",
|
|
196
|
+
header: tabMessages.columns.email,
|
|
197
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground", children: row.original.email ?? "-" })),
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
accessorKey: "phone",
|
|
201
|
+
header: tabMessages.columns.phone,
|
|
202
|
+
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground", children: row.original.phone ?? "-" })),
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
accessorKey: "isPrimary",
|
|
206
|
+
header: tabMessages.columns.primary,
|
|
207
|
+
cell: ({ row }) => row.original.isPrimary ? (_jsx(Star, { className: "size-3.5 fill-current text-amber-500", "aria-hidden": "true" })) : null,
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
id: "actions",
|
|
211
|
+
header: () => _jsx("div", { className: "w-20" }),
|
|
212
|
+
cell: ({ row }) => (_jsxs("div", { className: "flex items-center gap-1", children: [_jsx("button", { type: "button", onClick: () => {
|
|
213
|
+
setEditing(row.original);
|
|
214
|
+
setDialogOpen(true);
|
|
215
|
+
}, className: "text-muted-foreground hover:text-foreground", children: _jsx(Pencil, { className: "size-3.5", "aria-hidden": "true" }) }), _jsx("button", { type: "button", onClick: () => {
|
|
216
|
+
if (confirm(tabMessages.actions.deleteConfirm)) {
|
|
217
|
+
remove.mutate(row.original.id, { onSuccess: () => void refetch() });
|
|
218
|
+
}
|
|
219
|
+
}, className: "text-muted-foreground hover:text-destructive", children: _jsx(Trash2, { className: "size-3.5", "aria-hidden": "true" }) })] })),
|
|
220
|
+
},
|
|
221
|
+
], [refetch, remove, messages.common.namedContactRoleLabels, tabMessages]);
|
|
222
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: tabMessages.description }), _jsxs(Button, { size: "sm", onClick: () => {
|
|
223
|
+
setEditing(undefined);
|
|
224
|
+
setDialogOpen(true);
|
|
225
|
+
}, children: [_jsx(Plus, { className: "mr-2 size-4", "aria-hidden": "true" }), tabMessages.add] })] }), _jsx(DataTable, { columns: columns, data: data?.data ?? [], emptyMessage: isPending ? tabMessages.empty.loading : tabMessages.empty.none, pageSize: PAGE_SIZE }), _jsx(NamedContactDialog, { open: dialogOpen, onOpenChange: setDialogOpen, entityType: entityType, entityId: entityId, namedContact: editing, onSuccess: () => {
|
|
226
|
+
setDialogOpen(false);
|
|
227
|
+
setEditing(undefined);
|
|
228
|
+
void refetch();
|
|
229
|
+
} })] }));
|
|
230
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type NamedContactRecord } from "../index.js";
|
|
2
|
+
export interface NamedContactDialogProps {
|
|
3
|
+
open: boolean;
|
|
4
|
+
onOpenChange: (open: boolean) => void;
|
|
5
|
+
entityType: string;
|
|
6
|
+
entityId: string;
|
|
7
|
+
namedContact?: NamedContactRecord;
|
|
8
|
+
onSuccess?: (namedContact: NamedContactRecord) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function NamedContactDialog({ open, onOpenChange, entityType, entityId, namedContact, onSuccess, }: NamedContactDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=named-contact-dialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"named-contact-dialog.d.ts","sourceRoot":"","sources":["../../src/components/named-contact-dialog.tsx"],"names":[],"mappings":"AA0BA,OAAO,EAEL,KAAK,kBAAkB,EAGxB,MAAM,aAAa,CAAA;AAiCpB,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,OAAO,CAAA;IACb,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;IACrC,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,SAAS,CAAC,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAA;CACvD;AAED,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,SAAS,GACV,EAAE,uBAAuB,2CAmKzB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button, Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea, } from "@voyant-travel/ui/components";
|
|
4
|
+
import { zodResolver } from "@voyant-travel/ui/lib/zod-resolver";
|
|
5
|
+
import { Loader2 } from "lucide-react";
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
import { useForm } from "react-hook-form";
|
|
8
|
+
import { z } from "zod/v4";
|
|
9
|
+
import { useIdentityUiMessagesOrDefault } from "../i18n/index.js";
|
|
10
|
+
import { useNamedContactMutation, } from "../index.js";
|
|
11
|
+
const NAMED_CONTACT_ROLES = [
|
|
12
|
+
"general",
|
|
13
|
+
"primary",
|
|
14
|
+
"reservations",
|
|
15
|
+
"operations",
|
|
16
|
+
"front_desk",
|
|
17
|
+
"sales",
|
|
18
|
+
"emergency",
|
|
19
|
+
"accounting",
|
|
20
|
+
"legal",
|
|
21
|
+
"other",
|
|
22
|
+
];
|
|
23
|
+
function createFormSchema(messages) {
|
|
24
|
+
return z.object({
|
|
25
|
+
role: z.enum(NAMED_CONTACT_ROLES),
|
|
26
|
+
name: z.string().min(1, messages.namedContactDialog.validation.nameRequired).max(255),
|
|
27
|
+
title: z.string().optional().nullable(),
|
|
28
|
+
email: z.string().optional().nullable(),
|
|
29
|
+
phone: z.string().optional().nullable(),
|
|
30
|
+
isPrimary: z.boolean(),
|
|
31
|
+
notes: z.string().optional().nullable(),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function NamedContactDialog({ open, onOpenChange, entityType, entityId, namedContact, onSuccess, }) {
|
|
35
|
+
const isEditing = Boolean(namedContact);
|
|
36
|
+
const { create, update } = useNamedContactMutation();
|
|
37
|
+
const messages = useIdentityUiMessagesOrDefault();
|
|
38
|
+
const formSchema = createFormSchema(messages);
|
|
39
|
+
const form = useForm({
|
|
40
|
+
resolver: zodResolver(formSchema),
|
|
41
|
+
defaultValues: {
|
|
42
|
+
role: "general",
|
|
43
|
+
name: "",
|
|
44
|
+
title: "",
|
|
45
|
+
email: "",
|
|
46
|
+
phone: "",
|
|
47
|
+
isPrimary: false,
|
|
48
|
+
notes: "",
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (open && namedContact) {
|
|
53
|
+
form.reset({
|
|
54
|
+
role: namedContact.role,
|
|
55
|
+
name: namedContact.name,
|
|
56
|
+
title: namedContact.title ?? "",
|
|
57
|
+
email: namedContact.email ?? "",
|
|
58
|
+
phone: namedContact.phone ?? "",
|
|
59
|
+
isPrimary: namedContact.isPrimary,
|
|
60
|
+
notes: namedContact.notes ?? "",
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (open) {
|
|
65
|
+
form.reset({
|
|
66
|
+
role: "general",
|
|
67
|
+
name: "",
|
|
68
|
+
title: "",
|
|
69
|
+
email: "",
|
|
70
|
+
phone: "",
|
|
71
|
+
isPrimary: false,
|
|
72
|
+
notes: "",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}, [form, namedContact, open]);
|
|
76
|
+
const onSubmit = async (values) => {
|
|
77
|
+
const payload = {
|
|
78
|
+
entityType,
|
|
79
|
+
entityId,
|
|
80
|
+
role: values.role,
|
|
81
|
+
name: values.name,
|
|
82
|
+
title: values.title || null,
|
|
83
|
+
email: values.email || null,
|
|
84
|
+
phone: values.phone || null,
|
|
85
|
+
isPrimary: values.isPrimary,
|
|
86
|
+
notes: values.notes || null,
|
|
87
|
+
};
|
|
88
|
+
const saved = isEditing
|
|
89
|
+
? await update.mutateAsync({ id: namedContact.id, input: payload })
|
|
90
|
+
: await create.mutateAsync(payload);
|
|
91
|
+
onOpenChange(false);
|
|
92
|
+
onSuccess?.(saved);
|
|
93
|
+
};
|
|
94
|
+
const isSubmitting = form.formState.isSubmitting || create.isPending || update.isPending;
|
|
95
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { children: [_jsx(DialogHeader, { children: _jsx(DialogTitle, { children: isEditing
|
|
96
|
+
? messages.namedContactDialog.titles.edit
|
|
97
|
+
: messages.namedContactDialog.titles.create }) }), _jsxs("form", { onSubmit: form.handleSubmit(onSubmit), children: [_jsxs(DialogBody, { className: "grid gap-4", children: [_jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.namedContactDialog.fields.role }), _jsxs(Select, { items: NAMED_CONTACT_ROLES.map((x) => ({
|
|
98
|
+
label: messages.common.namedContactRoleLabels[x],
|
|
99
|
+
value: x,
|
|
100
|
+
})), value: form.watch("role"), onValueChange: (value) => form.setValue("role", value), children: [_jsx(SelectTrigger, { className: "w-full", children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: NAMED_CONTACT_ROLES.map((role) => (_jsx(SelectItem, { value: role, children: messages.common.namedContactRoleLabels[role] }, role))) })] })] }), _jsxs("div", { className: "flex items-center gap-2 self-end pb-1", children: [_jsx(Switch, { checked: form.watch("isPrimary"), onCheckedChange: (value) => form.setValue("isPrimary", value) }), _jsx(Label, { children: messages.common.primary })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.namedContactDialog.fields.name }), _jsx(Input, { ...form.register("name"), placeholder: messages.namedContactDialog.placeholders.name }), form.formState.errors.name ? (_jsx("p", { className: "text-xs text-destructive", children: form.formState.errors.name.message })) : null] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.namedContactDialog.fields.title }), _jsx(Input, { ...form.register("title"), placeholder: messages.namedContactDialog.placeholders.title })] })] }), _jsxs("div", { className: "grid grid-cols-2 gap-4", children: [_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.namedContactDialog.fields.email }), _jsx(Input, { ...form.register("email"), placeholder: messages.namedContactDialog.placeholders.email })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.namedContactDialog.fields.phone }), _jsx(Input, { ...form.register("phone") })] })] }), _jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Label, { children: messages.namedContactDialog.fields.notes }), _jsx(Textarea, { ...form.register("notes") })] })] }), _jsxs(DialogFooter, { children: [_jsx(Button, { type: "button", variant: "ghost", onClick: () => onOpenChange(false), children: messages.common.cancel }), _jsxs(Button, { type: "submit", disabled: isSubmitting, children: [isSubmitting ? _jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : null, isEditing ? messages.common.saveChanges : messages.namedContactDialog.actions.create] })] })] })] }) }));
|
|
101
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./use-address-mutation.js";
|
|
2
|
+
export * from "./use-addresses.js";
|
|
3
|
+
export * from "./use-contact-point-mutation.js";
|
|
4
|
+
export * from "./use-contact-points.js";
|
|
5
|
+
export * from "./use-named-contact-mutation.js";
|
|
6
|
+
export * from "./use-named-contacts.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA;AACvC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { insertAddressSchema, updateAddressSchema } from "@voyant-travel/identity";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateAddressInput = z.input<typeof insertAddressSchema>;
|
|
4
|
+
export type UpdateAddressInput = z.input<typeof updateAddressSchema>;
|
|
5
|
+
export declare function useAddressMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
entityType: string;
|
|
8
|
+
entityId: string;
|
|
9
|
+
label: "service" | "other" | "primary" | "legal" | "billing" | "shipping" | "mailing" | "meeting";
|
|
10
|
+
isPrimary: boolean;
|
|
11
|
+
id: string;
|
|
12
|
+
fullText: string | null;
|
|
13
|
+
line1: string | null;
|
|
14
|
+
line2: string | null;
|
|
15
|
+
city: string | null;
|
|
16
|
+
region: string | null;
|
|
17
|
+
postalCode: string | null;
|
|
18
|
+
country: string | null;
|
|
19
|
+
latitude: number | null;
|
|
20
|
+
longitude: number | null;
|
|
21
|
+
timezone: string | null;
|
|
22
|
+
notes: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
26
|
+
}, Error, {
|
|
27
|
+
entityType: string;
|
|
28
|
+
entityId: string;
|
|
29
|
+
label?: "service" | "other" | "primary" | "legal" | "billing" | "shipping" | "mailing" | "meeting" | undefined;
|
|
30
|
+
fullText?: string | null | undefined;
|
|
31
|
+
line1?: string | null | undefined;
|
|
32
|
+
line2?: string | null | undefined;
|
|
33
|
+
city?: string | null | undefined;
|
|
34
|
+
region?: string | null | undefined;
|
|
35
|
+
postalCode?: string | null | undefined;
|
|
36
|
+
country?: string | null | undefined;
|
|
37
|
+
latitude?: number | null | undefined;
|
|
38
|
+
longitude?: number | null | undefined;
|
|
39
|
+
timezone?: string | null | undefined;
|
|
40
|
+
isPrimary?: boolean | undefined;
|
|
41
|
+
notes?: string | null | undefined;
|
|
42
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
43
|
+
}, unknown>;
|
|
44
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
45
|
+
entityType: string;
|
|
46
|
+
entityId: string;
|
|
47
|
+
label: "service" | "other" | "primary" | "legal" | "billing" | "shipping" | "mailing" | "meeting";
|
|
48
|
+
isPrimary: boolean;
|
|
49
|
+
id: string;
|
|
50
|
+
fullText: string | null;
|
|
51
|
+
line1: string | null;
|
|
52
|
+
line2: string | null;
|
|
53
|
+
city: string | null;
|
|
54
|
+
region: string | null;
|
|
55
|
+
postalCode: string | null;
|
|
56
|
+
country: string | null;
|
|
57
|
+
latitude: number | null;
|
|
58
|
+
longitude: number | null;
|
|
59
|
+
timezone: string | null;
|
|
60
|
+
notes: string | null;
|
|
61
|
+
createdAt: string;
|
|
62
|
+
updatedAt: string;
|
|
63
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
64
|
+
}, Error, {
|
|
65
|
+
id: string;
|
|
66
|
+
input: UpdateAddressInput;
|
|
67
|
+
}, unknown>;
|
|
68
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
}, Error, string, unknown>;
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=use-address-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-address-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-address-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AACvF,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AACpE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAEpE,wBAAgB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBU,MAAM;eAAS,kBAAkB;;;;;EAgC5E"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { fetchWithValidation } from "../client.js";
|
|
4
|
+
import { useVoyantIdentityContext } from "../provider.js";
|
|
5
|
+
import { identityQueryKeys } from "../query-keys.js";
|
|
6
|
+
import { addressSingleResponse, successEnvelope } from "../schemas.js";
|
|
7
|
+
export function useAddressMutation() {
|
|
8
|
+
const { baseUrl, fetcher } = useVoyantIdentityContext();
|
|
9
|
+
const queryClient = useQueryClient();
|
|
10
|
+
const create = useMutation({
|
|
11
|
+
mutationFn: async (input) => {
|
|
12
|
+
const { data } = await fetchWithValidation("/v1/identity/addresses", addressSingleResponse, { baseUrl, fetcher }, { method: "POST", body: JSON.stringify(input) });
|
|
13
|
+
return data;
|
|
14
|
+
},
|
|
15
|
+
onSuccess: (data) => {
|
|
16
|
+
void queryClient.invalidateQueries({ queryKey: identityQueryKeys.addresses() });
|
|
17
|
+
queryClient.setQueryData(identityQueryKeys.address(data.id), data);
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const update = useMutation({
|
|
21
|
+
mutationFn: async ({ id, input }) => {
|
|
22
|
+
const { data } = await fetchWithValidation(`/v1/identity/addresses/${id}`, addressSingleResponse, { baseUrl, fetcher }, { method: "PATCH", body: JSON.stringify(input) });
|
|
23
|
+
return data;
|
|
24
|
+
},
|
|
25
|
+
onSuccess: (data) => {
|
|
26
|
+
void queryClient.invalidateQueries({ queryKey: identityQueryKeys.addresses() });
|
|
27
|
+
queryClient.setQueryData(identityQueryKeys.address(data.id), data);
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const remove = useMutation({
|
|
31
|
+
mutationFn: async (id) => fetchWithValidation(`/v1/identity/addresses/${id}`, successEnvelope, { baseUrl, fetcher }, {
|
|
32
|
+
method: "DELETE",
|
|
33
|
+
}),
|
|
34
|
+
onSuccess: (_data, id) => {
|
|
35
|
+
void queryClient.invalidateQueries({ queryKey: identityQueryKeys.addresses() });
|
|
36
|
+
queryClient.removeQueries({ queryKey: identityQueryKeys.address(id) });
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return { create, update, remove };
|
|
40
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AddressesListFilters } from "../query-keys.js";
|
|
2
|
+
export interface UseAddressesOptions extends AddressesListFilters {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function useAddresses(options?: UseAddressesOptions): import("@tanstack/react-query").UseQueryResult<{
|
|
6
|
+
data: {
|
|
7
|
+
entityType: string;
|
|
8
|
+
entityId: string;
|
|
9
|
+
label: "service" | "other" | "primary" | "legal" | "billing" | "shipping" | "mailing" | "meeting";
|
|
10
|
+
isPrimary: boolean;
|
|
11
|
+
id: string;
|
|
12
|
+
fullText: string | null;
|
|
13
|
+
line1: string | null;
|
|
14
|
+
line2: string | null;
|
|
15
|
+
city: string | null;
|
|
16
|
+
region: string | null;
|
|
17
|
+
postalCode: string | null;
|
|
18
|
+
country: string | null;
|
|
19
|
+
latitude: number | null;
|
|
20
|
+
longitude: number | null;
|
|
21
|
+
timezone: string | null;
|
|
22
|
+
notes: string | null;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
updatedAt: string;
|
|
25
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
26
|
+
}[];
|
|
27
|
+
total: number;
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
}, Error>;
|
|
31
|
+
//# sourceMappingURL=use-addresses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-addresses.d.ts","sourceRoot":"","sources":["../../src/hooks/use-addresses.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,MAAM,WAAW,mBAAoB,SAAQ,oBAAoB;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;UAQ7D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { useVoyantIdentityContext } from "../provider.js";
|
|
4
|
+
import { getAddressesQueryOptions } from "../query-options.js";
|
|
5
|
+
export function useAddresses(options = {}) {
|
|
6
|
+
const { baseUrl, fetcher } = useVoyantIdentityContext();
|
|
7
|
+
const { enabled = true, ...filters } = options;
|
|
8
|
+
return useQuery({
|
|
9
|
+
...getAddressesQueryOptions({ baseUrl, fetcher }, filters),
|
|
10
|
+
enabled,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { insertContactPointSchema, updateContactPointSchema } from "@voyant-travel/identity";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
export type CreateContactPointInput = z.input<typeof insertContactPointSchema>;
|
|
4
|
+
export type UpdateContactPointInput = z.input<typeof updateContactPointSchema>;
|
|
5
|
+
export declare function useContactPointMutation(): {
|
|
6
|
+
create: import("@tanstack/react-query").UseMutationResult<{
|
|
7
|
+
entityType: string;
|
|
8
|
+
entityId: string;
|
|
9
|
+
kind: "other" | "email" | "phone" | "mobile" | "website" | "whatsapp" | "sms" | "fax" | "social";
|
|
10
|
+
value: string;
|
|
11
|
+
isPrimary: boolean;
|
|
12
|
+
id: string;
|
|
13
|
+
label: string | null;
|
|
14
|
+
normalizedValue: string | null;
|
|
15
|
+
notes: string | null;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
updatedAt: string;
|
|
18
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
19
|
+
}, Error, {
|
|
20
|
+
entityType: string;
|
|
21
|
+
entityId: string;
|
|
22
|
+
kind: "other" | "email" | "phone" | "mobile" | "website" | "whatsapp" | "sms" | "fax" | "social";
|
|
23
|
+
value: string;
|
|
24
|
+
label?: string | null | undefined;
|
|
25
|
+
normalizedValue?: string | null | undefined;
|
|
26
|
+
isPrimary?: boolean | undefined;
|
|
27
|
+
notes?: string | null | undefined;
|
|
28
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
29
|
+
}, unknown>;
|
|
30
|
+
update: import("@tanstack/react-query").UseMutationResult<{
|
|
31
|
+
entityType: string;
|
|
32
|
+
entityId: string;
|
|
33
|
+
kind: "other" | "email" | "phone" | "mobile" | "website" | "whatsapp" | "sms" | "fax" | "social";
|
|
34
|
+
value: string;
|
|
35
|
+
isPrimary: boolean;
|
|
36
|
+
id: string;
|
|
37
|
+
label: string | null;
|
|
38
|
+
normalizedValue: string | null;
|
|
39
|
+
notes: string | null;
|
|
40
|
+
createdAt: string;
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
43
|
+
}, Error, {
|
|
44
|
+
id: string;
|
|
45
|
+
input: UpdateContactPointInput;
|
|
46
|
+
}, unknown>;
|
|
47
|
+
remove: import("@tanstack/react-query").UseMutationResult<{
|
|
48
|
+
success: boolean;
|
|
49
|
+
}, Error, string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=use-contact-point-mutation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-contact-point-mutation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-contact-point-mutation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAO5B,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAC9E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAE9E,wBAAgB,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqBK,MAAM;eAAS,uBAAuB;;;;;EAgCjF"}
|