@dragonmastery/dragoncore-vue 0.0.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.
Files changed (138) hide show
  1. package/LICENSE +75 -0
  2. package/dist/AppLink-CHMMrSFI.js +54 -0
  3. package/dist/AppLink-CHMMrSFI.js.map +1 -0
  4. package/dist/Appearance-BfPdKMXw.js +70 -0
  5. package/dist/Appearance-BfPdKMXw.js.map +1 -0
  6. package/dist/Appearance-C3WguxT-.js +3 -0
  7. package/dist/ChangePasswordPage-Btu5lf-r.js +86 -0
  8. package/dist/ChangePasswordPage-Btu5lf-r.js.map +1 -0
  9. package/dist/ChangePasswordPage-mBBuQMkT.js +6 -0
  10. package/dist/CreateTeamForm-n2ut93vM.js +43 -0
  11. package/dist/CreateTeamMemberForm-CcH3AxNL.js +43 -0
  12. package/dist/CreateUserPage-CDrGuW9B.js +6 -0
  13. package/dist/CreateUserPage-Cmx8xjjv.js +76 -0
  14. package/dist/CreateUserPage-Cmx8xjjv.js.map +1 -0
  15. package/dist/CreditBalanceDashboard-DLz0ioP3.js +43 -0
  16. package/dist/CreditManagement-D3q5S-qc.js +43 -0
  17. package/dist/CustomerCreateSupportTicketForm-Ci7QYkG-.js +43 -0
  18. package/dist/CustomerEditSupportTicketForm-Dd5ZB74k.js +159 -0
  19. package/dist/CustomerEditSupportTicketForm-Dd5ZB74k.js.map +1 -0
  20. package/dist/CustomerEditSupportTicketForm-lLchVjnw.js +9 -0
  21. package/dist/CustomerSupportTicketAttachmentsTab-gBrVO97t.js +43 -0
  22. package/dist/CustomerSupportTicketCustomerNotesTab-D0jhzbOY.js +8 -0
  23. package/dist/CustomerSupportTicketCustomerNotesTab-D1aa9It7.js +23 -0
  24. package/dist/CustomerSupportTicketCustomerNotesTab-D1aa9It7.js.map +1 -0
  25. package/dist/CustomerSupportTicketHistoryTab-BNTf8EZq.js +6 -0
  26. package/dist/CustomerSupportTicketHistoryTab-CFYN_Sa4.js +17 -0
  27. package/dist/CustomerSupportTicketHistoryTab-CFYN_Sa4.js.map +1 -0
  28. package/dist/CustomerSupportTicketList-BkOzFxMP.js +6 -0
  29. package/dist/CustomerSupportTicketList-C2nUPawb.js +166 -0
  30. package/dist/CustomerSupportTicketList-C2nUPawb.js.map +1 -0
  31. package/dist/CustomerSupportTicketParent-2mONd9kL.js +66 -0
  32. package/dist/CustomerSupportTicketParent-2mONd9kL.js.map +1 -0
  33. package/dist/CustomerSupportTicketParent-N8ko1yFE.js +7 -0
  34. package/dist/CustomerSupportTicketSuccess-w_-9NXT4.js +43 -0
  35. package/dist/CustomerViewSupportTicket-CVwNH0lS.js +11 -0
  36. package/dist/CustomerViewSupportTicket-tZkxragu.js +363 -0
  37. package/dist/CustomerViewSupportTicket-tZkxragu.js.map +1 -0
  38. package/dist/EditTeamForm-BioqiTWE.js +43 -0
  39. package/dist/EditTeamMemberForm-DCq0Gsn_.js +7 -0
  40. package/dist/EditTeamMemberForm-ru4WgLz-.js +169 -0
  41. package/dist/EditTeamMemberForm-ru4WgLz-.js.map +1 -0
  42. package/dist/EditUserPage-BxJ5QvIM.js +112 -0
  43. package/dist/EditUserPage-BxJ5QvIM.js.map +1 -0
  44. package/dist/EditUserPage-XOBuxUxd.js +7 -0
  45. package/dist/FieldsetSection-CsHN38_o.js +27 -0
  46. package/dist/FieldsetSection-CsHN38_o.js.map +1 -0
  47. package/dist/ForgotPassword-CpqvcSFg.js +7 -0
  48. package/dist/ForgotPassword-CqhenzUG.js +73 -0
  49. package/dist/ForgotPassword-CqhenzUG.js.map +1 -0
  50. package/dist/InlineAttachments-I39rOvip.js +1351 -0
  51. package/dist/InlineAttachments-I39rOvip.js.map +1 -0
  52. package/dist/LoginForm-AM0qkfbU.js +7 -0
  53. package/dist/LoginForm-_PZ51Uwe.js +116 -0
  54. package/dist/LoginForm-_PZ51Uwe.js.map +1 -0
  55. package/dist/Logout-BMjiqHnS.js +38 -0
  56. package/dist/Logout-BMjiqHnS.js.map +1 -0
  57. package/dist/Logout-BfiBjlaH.js +6 -0
  58. package/dist/NoteList-C0hRPNMO.js +497 -0
  59. package/dist/NoteList-C0hRPNMO.js.map +1 -0
  60. package/dist/NotificationEmailsPage-BjRqtW95.js +141 -0
  61. package/dist/NotificationEmailsPage-BjRqtW95.js.map +1 -0
  62. package/dist/NotificationEmailsPage-bx-9rg3x.js +7 -0
  63. package/dist/ResetPassword-BQLkR9TZ.js +43 -0
  64. package/dist/Signup-CnCcQlB8.js +7 -0
  65. package/dist/Signup-c2-_yMOM.js +106 -0
  66. package/dist/Signup-c2-_yMOM.js.map +1 -0
  67. package/dist/StaffCreateSupportTicketForm-ChVFDJdA.js +43 -0
  68. package/dist/StaffEditSupportTicketForm-DY1Zkf5k.js +9 -0
  69. package/dist/StaffEditSupportTicketForm-DuUKuIGg.js +263 -0
  70. package/dist/StaffEditSupportTicketForm-DuUKuIGg.js.map +1 -0
  71. package/dist/StaffSupportTicketAttachmentsTab-DpDXsHXP.js +43 -0
  72. package/dist/StaffSupportTicketCustomerNotesTab-CusqQV2-.js +23 -0
  73. package/dist/StaffSupportTicketCustomerNotesTab-CusqQV2-.js.map +1 -0
  74. package/dist/StaffSupportTicketCustomerNotesTab-rbJHJ0_V.js +8 -0
  75. package/dist/StaffSupportTicketHistoryTab-D24myEm3.js +17 -0
  76. package/dist/StaffSupportTicketHistoryTab-D24myEm3.js.map +1 -0
  77. package/dist/StaffSupportTicketHistoryTab-nmVma5vp.js +6 -0
  78. package/dist/StaffSupportTicketInternalNotesTab-D8HM--dp.js +23 -0
  79. package/dist/StaffSupportTicketInternalNotesTab-D8HM--dp.js.map +1 -0
  80. package/dist/StaffSupportTicketInternalNotesTab-DihYd5XI.js +8 -0
  81. package/dist/StaffSupportTicketList-DelptSmK.js +43 -0
  82. package/dist/StaffSupportTicketParent-BCrj3ckV.js +7 -0
  83. package/dist/StaffSupportTicketParent-Cx1buQZw.js +66 -0
  84. package/dist/StaffSupportTicketParent-Cx1buQZw.js.map +1 -0
  85. package/dist/StaffSupportTicketSuccess-BYxtY5wZ.js +43 -0
  86. package/dist/StaffSupportTicketWorkflowTab-BrDDBeK9.js +9 -0
  87. package/dist/StaffSupportTicketWorkflowTab-DmVTPzxS.js +1234 -0
  88. package/dist/StaffSupportTicketWorkflowTab-DmVTPzxS.js.map +1 -0
  89. package/dist/SupportTicketHistoryTab-CLMopA7a.js +220 -0
  90. package/dist/SupportTicketHistoryTab-CLMopA7a.js.map +1 -0
  91. package/dist/SupportTicketStatusBadge-YdZzjvkh.js +163 -0
  92. package/dist/SupportTicketStatusBadge-YdZzjvkh.js.map +1 -0
  93. package/dist/TeamAttachmentsTab-BxUpTWYh.js +43 -0
  94. package/dist/TeamHistoryTab-CUCT9MRG.js +5 -0
  95. package/dist/TeamHistoryTab-gB3H2KZv.js +219 -0
  96. package/dist/TeamHistoryTab-gB3H2KZv.js.map +1 -0
  97. package/dist/TeamList-By6pzWm5.js +43 -0
  98. package/dist/TeamMemberList-CYV9fWEb.js +43 -0
  99. package/dist/TeamMemberParent-CVvGqpxD.js +43 -0
  100. package/dist/TeamMembersTab-4gmnP9sD.js +21 -0
  101. package/dist/TeamMembersTab-4gmnP9sD.js.map +1 -0
  102. package/dist/TeamMembersTab-CpE9BaCi.js +3 -0
  103. package/dist/TeamNotesTab-pfXTDhg6.js +23 -0
  104. package/dist/TeamNotesTab-pfXTDhg6.js.map +1 -0
  105. package/dist/TeamNotesTab-u4cDC67X.js +8 -0
  106. package/dist/TeamParent-BxT1KubK.js +43 -0
  107. package/dist/UserListPage-DsQdH2Sm.js +4 -0
  108. package/dist/UserListPage-WU56KiWj.js +153 -0
  109. package/dist/UserListPage-WU56KiWj.js.map +1 -0
  110. package/dist/UserProfilePage-B73JhjUu.js +7 -0
  111. package/dist/UserProfilePage-BtLUY1kt.js +125 -0
  112. package/dist/UserProfilePage-BtLUY1kt.js.map +1 -0
  113. package/dist/ViewTeam-DzX-obEl.js +43 -0
  114. package/dist/ViewTeamMember-PF6S_4Pb.js +43 -0
  115. package/dist/ZiniaContainer-C7c7Vwkh.js +18 -0
  116. package/dist/ZiniaContainer-C7c7Vwkh.js.map +1 -0
  117. package/dist/convertToLocalDateTime-D4IoNvRj.js +111 -0
  118. package/dist/convertToLocalDateTime-D4IoNvRj.js.map +1 -0
  119. package/dist/creditValueFormatter-DftEzu8d.js +128 -0
  120. package/dist/creditValueFormatter-DftEzu8d.js.map +1 -0
  121. package/dist/displayIdFormatter-Dz900Awr.js +13 -0
  122. package/dist/displayIdFormatter-Dz900Awr.js.map +1 -0
  123. package/dist/index.d.ts +6068 -0
  124. package/dist/index.js +45 -0
  125. package/dist/src-o5fMIo5_.js +6649 -0
  126. package/dist/src-o5fMIo5_.js.map +1 -0
  127. package/dist/useBreadcrumbs-DmgSucoe.js +41 -0
  128. package/dist/useBreadcrumbs-DmgSucoe.js.map +1 -0
  129. package/dist/useMutation-CFwe7H9j.js +50 -0
  130. package/dist/useMutation-CFwe7H9j.js.map +1 -0
  131. package/dist/useQuery-p7oJO7OD.js +107 -0
  132. package/dist/useQuery-p7oJO7OD.js.map +1 -0
  133. package/dist/useQueryCache-ByayvZgZ.js +254 -0
  134. package/dist/useQueryCache-ByayvZgZ.js.map +1 -0
  135. package/dist/useRpcAuth-BLlRSHy8.js +722 -0
  136. package/dist/useRpcAuth-BLlRSHy8.js.map +1 -0
  137. package/package.json +62 -0
  138. package/src/daisyui.css +63 -0
@@ -0,0 +1,497 @@
1
+ import { r as executeWithAuth, s as getRefreshTokenHandler } from "./useRpcAuth-BLlRSHy8.js";
2
+ import { t as useMutation } from "./useMutation-CFwe7H9j.js";
3
+ import { t as useQuery } from "./useQuery-p7oJO7OD.js";
4
+ import { t as formatSystemTimestamp } from "./convertToLocalDateTime-D4IoNvRj.js";
5
+ import { computed, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, ref, toDisplayString, unref, watch, withCtx } from "vue";
6
+ import { NoteCreateSchema, NoteReadSchema, NoteUpdateSchema, OPERATORS } from "@dragonmastery/dragoncore-shared";
7
+ import { ActionIcons, useCursorDataTable, useForm, withMetadata } from "@dragonmastery/zinia-forms-core";
8
+ import { toast } from "vue3-toastify";
9
+
10
+ //#region src/composables/useUserLookup.ts
11
+ /**
12
+ * Generic composable for looking up user information by user ID
13
+ * Fetches team members from the user's teams and caches them
14
+ * Provides a map of user_id -> display_name for easy lookups
15
+ *
16
+ * @param queryFn - Function that queries team members from the API
17
+ * @param options - Optional query options (cacheKey defaults to 'user-team-members')
18
+ */
19
+ function useUserLookup(queryFn, options) {
20
+ const { data: userTeamMembers, loading: isUserTeamMembersLoading } = useQuery(queryFn, {
21
+ cacheKey: options?.cacheKey ?? "user-team-members",
22
+ staleTime: options?.staleTime ?? 1440 * 60 * 1e3,
23
+ ...options
24
+ });
25
+ const userMap = computed(() => {
26
+ const map = /* @__PURE__ */ new Map();
27
+ userTeamMembers.value?.items?.forEach((member) => {
28
+ if (member.user_id) {
29
+ const displayName = member.display_name || member.email_address;
30
+ if (displayName) map.set(member.user_id, displayName);
31
+ }
32
+ });
33
+ return map;
34
+ });
35
+ /**
36
+ * Get the display name for a user ID
37
+ * @param userId - The user ID to look up
38
+ * @returns The display name if found, or null if not found
39
+ */
40
+ const getUserName = (userId) => {
41
+ if (!userId) return null;
42
+ return userMap.value.get(userId) || null;
43
+ };
44
+ /**
45
+ * Get the display name for a user ID, with a fallback
46
+ * @param userId - The user ID to look up
47
+ * @param fallback - The fallback text to use if not found (default: the userId itself)
48
+ * @returns The display name if found, or the fallback (or userId) if not found
49
+ */
50
+ const getUserNameWithFallback = (userId, fallback) => {
51
+ if (!userId) return fallback || "";
52
+ const displayName = userMap.value.get(userId);
53
+ if (displayName) return displayName;
54
+ return fallback !== void 0 ? fallback : userId;
55
+ };
56
+ return {
57
+ userTeamMembers,
58
+ isUserTeamMembersLoading,
59
+ userMap,
60
+ getUserName,
61
+ getUserNameWithFallback
62
+ };
63
+ }
64
+
65
+ //#endregion
66
+ //#region src/slices/note/noteUpdateMetadata.ts
67
+ const noteUpdateMetadata = withMetadata(NoteUpdateSchema.pick({
68
+ body: true,
69
+ tag: true
70
+ }), "noteUpdateForm", {
71
+ body: {
72
+ label: "Note",
73
+ placeholder: "Enter your note here...",
74
+ inputType: "textarea",
75
+ helpText: "Update the note content"
76
+ },
77
+ tag: {
78
+ label: "Tag",
79
+ inputType: "combobox",
80
+ helpText: "Optional tag to categorize this note"
81
+ }
82
+ });
83
+
84
+ //#endregion
85
+ //#region src/slices/note/components/EditNoteModal.vue
86
+ const _hoisted_1$1 = { class: "modal-box" };
87
+ const _hoisted_2$1 = { class: "form-control" };
88
+ const _hoisted_3$1 = { class: "label" };
89
+ const _hoisted_4$1 = {
90
+ key: 0,
91
+ class: "alert alert-error mt-2"
92
+ };
93
+ const _hoisted_5$1 = { class: "flex justify-end gap-2 mt-6" };
94
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
95
+ __name: "EditNoteModal",
96
+ props: {
97
+ note: {},
98
+ isOpen: { type: Boolean }
99
+ },
100
+ emits: ["close", "success"],
101
+ setup(__props, { emit: __emit }) {
102
+ const props = __props;
103
+ const emit = __emit;
104
+ const modal = ref();
105
+ const isInternalNote = ref(false);
106
+ const { data: noteTagsData, loading: noteTagsLoading, error: noteTagsError, refetch: refetchNoteTags } = useQuery((api) => api.notes.getNoteTags());
107
+ const loadNoteTags = async () => {
108
+ while (noteTagsLoading.value) await new Promise((resolve) => setTimeout(resolve, 100));
109
+ if (noteTagsError.value) return [];
110
+ return (noteTagsData.value || []).map((tag) => ({
111
+ value: tag,
112
+ label: tag
113
+ }));
114
+ };
115
+ const { form, zinia, ZiniaForm, ZiniaSubmitButton, ZiniaFormErrorsSummary, clearSavedFormState, refreshFormData } = useForm(noteUpdateMetadata, {
116
+ storeName: `edit-note-form-${props.note?.id || "new"}`,
117
+ persistToLocalStorage: false,
118
+ renderStyle: "daisy_ui",
119
+ dataLoaders: { tag: loadNoteTags },
120
+ fetchData: async () => {
121
+ if (!props.note) return {
122
+ body: "",
123
+ tag: null
124
+ };
125
+ return {
126
+ body: props.note.body || "",
127
+ tag: props.note.tag || null
128
+ };
129
+ }
130
+ });
131
+ const { mutate: updateNote } = useMutation((api, input) => api.notes.updateNote(input), {
132
+ invalidate: /^notes?:/,
133
+ onSuccess: () => {
134
+ refetchNoteTags();
135
+ }
136
+ });
137
+ const handleSubmit = async (formData) => {
138
+ if (!props.note) throw new Error("No note selected for editing");
139
+ const response = await updateNote({
140
+ id: props.note.id,
141
+ body: formData.body,
142
+ tag: formData.tag || null
143
+ });
144
+ if (!response) throw new Error("Failed to update note");
145
+ return response;
146
+ };
147
+ const handleSuccess = async () => {
148
+ clearSavedFormState();
149
+ refreshFormData();
150
+ toast.success("Note updated successfully!");
151
+ emit("success");
152
+ closeModal();
153
+ };
154
+ const handleError = (error) => {
155
+ form.setSubmitError(error instanceof Error ? error.message : "An unknown error occurred");
156
+ };
157
+ const closeModal = () => {
158
+ emit("close");
159
+ };
160
+ watch(() => props.isOpen, (isOpen) => {
161
+ if (isOpen && modal.value) modal.value.showModal();
162
+ else if (!isOpen && modal.value) {
163
+ modal.value.close();
164
+ refreshFormData();
165
+ }
166
+ });
167
+ watch(() => props.note, () => {
168
+ if (props.note && props.isOpen) {
169
+ form.setValue("body", props.note.body || "");
170
+ form.setValue("tag", props.note.tag || null);
171
+ isInternalNote.value = props.note.is_internal || false;
172
+ }
173
+ }, { immediate: true });
174
+ return (_ctx, _cache) => {
175
+ return openBlock(), createElementBlock("dialog", {
176
+ ref_key: "modal",
177
+ ref: modal,
178
+ class: "modal"
179
+ }, [createElementVNode("div", _hoisted_1$1, [_cache[1] || (_cache[1] = createElementVNode("h3", { class: "font-bold text-lg mb-4" }, "Edit Note", -1)), createVNode(unref(ZiniaForm), {
180
+ onHandleSubmit: handleSubmit,
181
+ onSuccess: handleSuccess,
182
+ onError: handleError,
183
+ title: "",
184
+ subtitle: ""
185
+ }, {
186
+ default: withCtx(() => [
187
+ createVNode(unref(zinia).TagField, {
188
+ "select-options": unref(form).extraData.tag || [],
189
+ "allow-create": true
190
+ }, null, 8, ["select-options"]),
191
+ createVNode(unref(zinia).BodyField),
192
+ createCommentVNode(" Show visibility status (read-only) "),
193
+ createElementVNode("div", _hoisted_2$1, [createElementVNode("label", _hoisted_3$1, [_cache[0] || (_cache[0] = createElementVNode("span", { class: "label-text" }, "Visibility", -1)), createElementVNode("span", { class: normalizeClass(["badge", isInternalNote.value ? "badge-warning" : "badge-info"]) }, toDisplayString(isInternalNote.value ? "Internal" : "External"), 3)])]),
194
+ unref(form).submitError ? (openBlock(), createElementBlock("div", _hoisted_4$1, [createElementVNode("span", null, toDisplayString(unref(form).submitError), 1)])) : createCommentVNode("v-if", true),
195
+ createElementVNode("div", _hoisted_5$1, [createElementVNode("button", {
196
+ type: "button",
197
+ class: "btn btn-ghost",
198
+ onClick: closeModal
199
+ }, "Cancel"), createVNode(unref(ZiniaSubmitButton), {
200
+ submitText: "Update Note",
201
+ submittingText: "Updating..."
202
+ })]),
203
+ createVNode(unref(ZiniaFormErrorsSummary), { title: "Please fix the following errors:" })
204
+ ]),
205
+ _: 1
206
+ })]), createElementVNode("form", {
207
+ method: "dialog",
208
+ class: "modal-backdrop"
209
+ }, [createElementVNode("button", { onClick: closeModal }, "close")])], 512);
210
+ };
211
+ }
212
+ });
213
+ var EditNoteModal_default = _sfc_main$1;
214
+
215
+ //#endregion
216
+ //#region src/slices/note/noteFormMetadata.ts
217
+ const noteCreateMetadata = withMetadata(NoteCreateSchema.pick({
218
+ body: true,
219
+ is_internal: true,
220
+ tag: true
221
+ }), "noteCreateForm", {
222
+ body: {
223
+ label: "Note",
224
+ placeholder: "Enter your note here...",
225
+ inputType: "textarea",
226
+ helpText: "Add a note about this record"
227
+ },
228
+ is_internal: {
229
+ label: "Internal Note",
230
+ helpText: "Check this box to make this note visible only to staff"
231
+ },
232
+ tag: {
233
+ label: "Tag",
234
+ inputType: "combobox",
235
+ helpText: "Optional tag to categorize this note"
236
+ }
237
+ });
238
+
239
+ //#endregion
240
+ //#region src/slices/note/noteRowSchema.ts
241
+ const noteRowSchemaWithMetadata = withMetadata(NoteReadSchema, "noteRowSchema", {
242
+ body: { label: "Note" },
243
+ tag: {
244
+ label: "Tag",
245
+ sortable: true
246
+ },
247
+ is_internal: {
248
+ label: "Visibility",
249
+ sortable: true
250
+ },
251
+ created_at: {
252
+ label: "Created",
253
+ sortable: true
254
+ },
255
+ created_by: {
256
+ label: "Created By",
257
+ sortable: true
258
+ },
259
+ updated_at: {
260
+ label: "Updated",
261
+ sortable: true
262
+ }
263
+ });
264
+
265
+ //#endregion
266
+ //#region src/slices/note/components/NoteList.vue
267
+ const _hoisted_1 = { class: "space-y-6" };
268
+ const _hoisted_2 = { class: "mt-4" };
269
+ const _hoisted_3 = {
270
+ key: 0,
271
+ class: "alert alert-error mt-2"
272
+ };
273
+ const _hoisted_4 = { class: "flex justify-end mt-6" };
274
+ const _hoisted_5 = { class: "whitespace-pre-wrap" };
275
+ const _sfc_main = /* @__PURE__ */ defineComponent({
276
+ __name: "NoteList",
277
+ props: {
278
+ recordId: {},
279
+ recordType: {},
280
+ mode: { default: "customer" }
281
+ },
282
+ setup(__props) {
283
+ const props = __props;
284
+ const selectedNote = ref(null);
285
+ const isEditModalOpen = ref(false);
286
+ const isInternalNote = computed(() => {
287
+ return props.mode === "internal";
288
+ });
289
+ const { getUserNameWithFallback } = useUserLookup((api) => api.teamMembers.getUserTeamMembers());
290
+ const queryFilters = ref({
291
+ record_id: {
292
+ operator: OPERATORS.EQUALS,
293
+ value: props.recordId
294
+ },
295
+ record_type: {
296
+ operator: OPERATORS.EQUALS,
297
+ value: props.recordType
298
+ }
299
+ });
300
+ const currentPaginationToken = ref();
301
+ const { data: noteTagsData, loading: noteTagsLoading, error: noteTagsError, refetch: refetchNoteTags } = useQuery((api) => api.notes.getNoteTags());
302
+ const loadNoteTags = async () => {
303
+ while (noteTagsLoading.value) await new Promise((resolve) => setTimeout(resolve, 100));
304
+ if (noteTagsError.value) return [];
305
+ return (noteTagsData.value || []).map((tag) => ({
306
+ value: tag,
307
+ label: tag
308
+ }));
309
+ };
310
+ const { form, zinia, ZiniaForm, ZiniaSubmitButton, ZiniaFormErrorsSummary, refreshFormData } = useForm(noteCreateMetadata, {
311
+ storeName: `note-form-${props.recordId}`,
312
+ persistToLocalStorage: false,
313
+ renderStyle: "daisy_ui",
314
+ dataLoaders: { tag: loadNoteTags },
315
+ fetchData: async () => ({
316
+ body: "",
317
+ tag: null,
318
+ is_internal: isInternalNote.value
319
+ })
320
+ });
321
+ const { ZiniaDataTable, refresh } = useCursorDataTable(noteRowSchemaWithMetadata, {
322
+ fetchData: async ({ cursor, pageSize, sort, filters, search }) => {
323
+ const variables = {
324
+ first: pageSize,
325
+ sortBy: sort?.field ? sort.field : "created_at",
326
+ sortDirection: sort?.direction === "asc" ? "asc" : "desc",
327
+ ...cursor ? { after: cursor } : {},
328
+ ...currentPaginationToken.value ? { paginationToken: currentPaginationToken.value } : {},
329
+ ...search ? { search } : {},
330
+ record_id: {
331
+ operator: OPERATORS.EQUALS,
332
+ value: props.recordId
333
+ },
334
+ record_type: {
335
+ operator: OPERATORS.EQUALS,
336
+ value: props.recordType
337
+ },
338
+ ...filters
339
+ };
340
+ if (props.mode === "customer") variables.is_internal = {
341
+ operator: OPERATORS.EQUALS,
342
+ value: false
343
+ };
344
+ else if (props.mode === "internal") variables.is_internal = {
345
+ operator: OPERATORS.EQUALS,
346
+ value: true
347
+ };
348
+ queryFilters.value = variables;
349
+ const result = await executeWithAuth(async (api) => {
350
+ return await api.notes.getNotes(variables);
351
+ }, { refreshTokenHandler: getRefreshTokenHandler() });
352
+ currentPaginationToken.value = result?.pageInfo?.paginationToken;
353
+ return {
354
+ data: result?.items || [],
355
+ hasNextPage: result?.pageInfo?.hasNextPage ?? false,
356
+ hasPreviousPage: result?.pageInfo?.hasPreviousPage ?? false,
357
+ prevPageCursor: result?.pageInfo?.prevPageCursor ?? void 0,
358
+ nextPageCursor: result?.pageInfo?.nextPageCursor ?? void 0
359
+ };
360
+ },
361
+ columns: {
362
+ created_by: {
363
+ label: "Created By",
364
+ field: "created_by",
365
+ sortable: true,
366
+ verticalAlign: "top"
367
+ },
368
+ updated_at: {
369
+ label: "Updated",
370
+ field: "updated_at",
371
+ sortable: true,
372
+ verticalAlign: "top"
373
+ },
374
+ tag: {
375
+ label: "Tag",
376
+ field: "tag",
377
+ sortable: true,
378
+ filterable: true,
379
+ filterType: "select",
380
+ filterOptionsLoader: loadNoteTags,
381
+ verticalAlign: "top"
382
+ },
383
+ body: {
384
+ label: "Note",
385
+ field: "body",
386
+ sortable: false
387
+ }
388
+ },
389
+ actions: {
390
+ column: { verticalAlign: "top" },
391
+ items: [{
392
+ key: "edit",
393
+ icon: ActionIcons.edit,
394
+ size: "xs",
395
+ variant: "primary",
396
+ type: "button",
397
+ onClick: (row) => openEditModal(row)
398
+ }]
399
+ },
400
+ pagination: { pageSize: 25 }
401
+ });
402
+ const { mutate: createNote } = useMutation((api, input) => api.notes.createNote(input), {
403
+ invalidate: /^notes?:/,
404
+ onSuccess: () => {
405
+ refetchNoteTags();
406
+ }
407
+ });
408
+ const handleSubmit = async (formData) => {
409
+ const result = await createNote({
410
+ record_id: props.recordId,
411
+ record_type: props.recordType,
412
+ body: formData.body,
413
+ tag: formData.tag || null,
414
+ is_internal: isInternalNote.value
415
+ });
416
+ refresh();
417
+ return result;
418
+ };
419
+ const handleSuccess = async () => {
420
+ refreshFormData();
421
+ toast.success("Note added successfully!");
422
+ refresh();
423
+ };
424
+ const handleError = (error) => {
425
+ form.setSubmitError(error instanceof Error ? error.message : "An unknown error occurred");
426
+ };
427
+ const openEditModal = (note) => {
428
+ selectedNote.value = note;
429
+ isEditModalOpen.value = true;
430
+ };
431
+ const closeEditModal = () => {
432
+ isEditModalOpen.value = false;
433
+ selectedNote.value = null;
434
+ };
435
+ const handleEditSuccess = async () => {
436
+ await refetchNoteTags();
437
+ refresh();
438
+ };
439
+ watch(() => [props.recordId, props.recordType], () => {
440
+ if (props.recordId && props.recordType) refresh();
441
+ });
442
+ watch(noteTagsData, async () => {
443
+ if (form.extraData && form.extraData.tag !== void 0) {
444
+ const newTags = await loadNoteTags();
445
+ form.extraData.tag = newTags;
446
+ }
447
+ }, { deep: true });
448
+ return (_ctx, _cache) => {
449
+ return openBlock(), createElementBlock("div", _hoisted_1, [
450
+ createCommentVNode(" Add Note Form "),
451
+ createElementVNode("div", _hoisted_2, [createVNode(unref(ZiniaForm), {
452
+ onHandleSubmit: handleSubmit,
453
+ onSuccess: handleSuccess,
454
+ onError: handleError,
455
+ title: "",
456
+ subtitle: ""
457
+ }, {
458
+ default: withCtx(() => [
459
+ createVNode(unref(zinia).TagField, {
460
+ "select-options": unref(form).extraData.tag || [],
461
+ "allow-create": true
462
+ }, null, 8, ["select-options"]),
463
+ createVNode(unref(zinia).BodyField),
464
+ unref(form).submitError ? (openBlock(), createElementBlock("div", _hoisted_3, [createElementVNode("span", null, toDisplayString(unref(form).submitError), 1)])) : createCommentVNode("v-if", true),
465
+ createElementVNode("div", _hoisted_4, [createVNode(unref(ZiniaSubmitButton), {
466
+ submitText: "Add Note",
467
+ submittingText: "Adding..."
468
+ })]),
469
+ createVNode(unref(ZiniaFormErrorsSummary), { title: "Please fix the following errors:" })
470
+ ]),
471
+ _: 1
472
+ })]),
473
+ createCommentVNode(" Notes Table "),
474
+ createVNode(unref(ZiniaDataTable), null, {
475
+ "cell-created_by": withCtx(({ row }) => [createTextVNode(toDisplayString(unref(getUserNameWithFallback)(row.created_by)), 1)]),
476
+ "cell-created_at": withCtx(({ row }) => [createTextVNode(toDisplayString(unref(formatSystemTimestamp)(row.created_at)), 1)]),
477
+ "cell-tag": withCtx(({ row }) => [createTextVNode(toDisplayString(row.tag || "-"), 1)]),
478
+ "cell-updated_at": withCtx(({ row }) => [createTextVNode(toDisplayString(row.updated_at ? unref(formatSystemTimestamp)(row.updated_at) : "-"), 1)]),
479
+ "cell-body": withCtx(({ row }) => [createElementVNode("div", _hoisted_5, toDisplayString(row.body || "No content"), 1)]),
480
+ _: 1
481
+ }),
482
+ createCommentVNode(" Edit Modal "),
483
+ createVNode(EditNoteModal_default, {
484
+ note: selectedNote.value,
485
+ "is-open": isEditModalOpen.value,
486
+ onClose: closeEditModal,
487
+ onSuccess: handleEditSuccess
488
+ }, null, 8, ["note", "is-open"])
489
+ ]);
490
+ };
491
+ }
492
+ });
493
+ var NoteList_default = _sfc_main;
494
+
495
+ //#endregion
496
+ export { noteUpdateMetadata as a, EditNoteModal_default as i, noteRowSchemaWithMetadata as n, useUserLookup as o, noteCreateMetadata as r, NoteList_default as t };
497
+ //# sourceMappingURL=NoteList-C0hRPNMO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NoteList-C0hRPNMO.js","names":["variables: NoteFiltersDto"],"sources":["../src/composables/useUserLookup.ts","../src/slices/note/noteUpdateMetadata.ts","../src/slices/note/components/EditNoteModal.vue","../src/slices/note/noteFormMetadata.ts","../src/slices/note/noteRowSchema.ts","../src/slices/note/components/NoteList.vue"],"sourcesContent":["import { computed } from 'vue';\nimport type { DragoncoreApi } from '@dragonmastery/dragoncore-shared';\nimport type { QueryFunction, UseQueryOptions } from './types';\nimport { useQuery } from './useQuery';\n\n/**\n * Team member item with user identification fields\n */\nexport interface TeamMemberItem {\n user_id: string | null;\n display_name?: string | null;\n email_address?: string | null;\n}\n\n/**\n * Response type for user team members query\n */\nexport interface UserTeamMembersResponse {\n items: TeamMemberItem[];\n}\n\n/**\n * Generic composable for looking up user information by user ID\n * Fetches team members from the user's teams and caches them\n * Provides a map of user_id -> display_name for easy lookups\n *\n * @param queryFn - Function that queries team members from the API\n * @param options - Optional query options (cacheKey defaults to 'user-team-members')\n */\nexport function useUserLookup<TApi extends Record<string, any> = DragoncoreApi>(\n queryFn: QueryFunction<TApi, UserTeamMembersResponse>,\n options?: Omit<UseQueryOptions, 'cacheKey'> & { cacheKey?: string },\n) {\n // Fetch user team members for lookups\n const { data: userTeamMembers, loading: isUserTeamMembersLoading } = useQuery<\n TApi,\n UserTeamMembersResponse\n >(queryFn, {\n cacheKey: options?.cacheKey ?? 'user-team-members',\n staleTime: options?.staleTime ?? 24 * 60 * 60 * 1000, // 24 hours\n ...options,\n });\n\n // Create a user lookup map: user_id -> display_name (or email_address as fallback)\n const userMap = computed(() => {\n const map = new Map<string, string>();\n userTeamMembers.value?.items?.forEach((member: TeamMemberItem) => {\n if (member.user_id) {\n // Use display_name if available, otherwise fall back to email_address\n const displayName = member.display_name || member.email_address;\n if (displayName) {\n map.set(member.user_id, displayName);\n }\n }\n });\n return map;\n });\n\n /**\n * Get the display name for a user ID\n * @param userId - The user ID to look up\n * @returns The display name if found, or null if not found\n */\n const getUserName = (userId: string | null | undefined): string | null => {\n if (!userId) return null;\n return userMap.value.get(userId) || null;\n };\n\n /**\n * Get the display name for a user ID, with a fallback\n * @param userId - The user ID to look up\n * @param fallback - The fallback text to use if not found (default: the userId itself)\n * @returns The display name if found, or the fallback (or userId) if not found\n */\n const getUserNameWithFallback = (\n userId: string | null | undefined,\n fallback?: string,\n ): string => {\n if (!userId) return fallback || '';\n const displayName = userMap.value.get(userId);\n if (displayName) return displayName;\n // If not found, return the fallback if provided, otherwise return the userId\n return fallback !== undefined ? fallback : userId;\n };\n\n return {\n userTeamMembers,\n isUserTeamMembersLoading,\n userMap,\n getUserName,\n getUserNameWithFallback,\n };\n}\n","import { withMetadata } from '@dragonmastery/zinia-forms-core';\nimport { NoteUpdateSchema } from '@dragonmastery/dragoncore-shared';\n\nexport const noteUpdateMetadata = withMetadata(\n NoteUpdateSchema.pick({ body: true, tag: true }),\n 'noteUpdateForm',\n {\n body: {\n label: 'Note',\n placeholder: 'Enter your note here...',\n inputType: 'textarea',\n helpText: 'Update the note content',\n },\n tag: {\n label: 'Tag',\n inputType: 'combobox',\n helpText: 'Optional tag to categorize this note',\n },\n },\n);\n","<template>\n <dialog ref=\"modal\" class=\"modal\">\n <div class=\"modal-box\">\n <h3 class=\"font-bold text-lg mb-4\">Edit Note</h3>\n\n <ZiniaForm\n @handle-submit=\"handleSubmit\"\n @success=\"handleSuccess\"\n @error=\"handleError\"\n title=\"\"\n subtitle=\"\"\n >\n <zinia.TagField :select-options=\"form.extraData.tag || []\" :allow-create=\"true\" />\n <zinia.BodyField />\n\n <!-- Show visibility status (read-only) -->\n <div class=\"form-control\">\n <label class=\"label\">\n <span class=\"label-text\">Visibility</span>\n <span class=\"badge\" :class=\"isInternalNote ? 'badge-warning' : 'badge-info'\">\n {{ isInternalNote ? 'Internal' : 'External' }}\n </span>\n </label>\n </div>\n\n <div v-if=\"form.submitError\" class=\"alert alert-error mt-2\">\n <span>{{ form.submitError }}</span>\n </div>\n\n <div class=\"flex justify-end gap-2 mt-6\">\n <button type=\"button\" class=\"btn btn-ghost\" @click=\"closeModal\">Cancel</button>\n <ZiniaSubmitButton submitText=\"Update Note\" submittingText=\"Updating...\" />\n </div>\n\n <ZiniaFormErrorsSummary title=\"Please fix the following errors:\" />\n </ZiniaForm>\n </div>\n <form method=\"dialog\" class=\"modal-backdrop\">\n <button @click=\"closeModal\">close</button>\n </form>\n </dialog>\n</template>\n\n<script setup lang=\"ts\">\nimport { useForm } from '@dragonmastery/zinia-forms-core';\nimport { ref, watch } from 'vue';\nimport { toast } from 'vue3-toastify';\nimport { useMutation } from '../../../composables/useMutation';\nimport { useQuery } from '../../../composables/useQuery';\nimport type { NoteRow } from '../noteRowSchema';\nimport { noteUpdateMetadata } from '../noteUpdateMetadata';\n\ninterface Props {\n note: NoteRow | null;\n isOpen: boolean;\n}\n\ninterface Emits {\n (e: 'close'): void;\n (e: 'success'): void;\n}\n\nconst props = defineProps<Props>();\nconst emit = defineEmits<Emits>();\n\nconst modal = ref<HTMLDialogElement>();\n\n// Internal note toggle state\nconst isInternalNote = ref(false);\n\n// Fetch note tags for combobox\nconst {\n data: noteTagsData,\n loading: noteTagsLoading,\n error: noteTagsError,\n refetch: refetchNoteTags,\n} = useQuery((api) => api.notes.getNoteTags());\n\n// Load note tags for combobox options\nconst loadNoteTags = async () => {\n // Wait for query to complete\n while (noteTagsLoading.value) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n if (noteTagsError.value) {\n return [];\n }\n\n const tags = noteTagsData.value || [];\n\n return tags.map((tag: string) => ({\n value: tag,\n label: tag,\n }));\n};\n\nconst {\n form,\n zinia,\n ZiniaForm,\n ZiniaSubmitButton,\n ZiniaFormErrorsSummary,\n clearSavedFormState,\n refreshFormData,\n} = useForm(noteUpdateMetadata, {\n storeName: `edit-note-form-${props.note?.id || 'new'}`,\n persistToLocalStorage: false,\n renderStyle: 'daisy_ui',\n dataLoaders: {\n tag: loadNoteTags,\n },\n fetchData: async () => {\n if (!props.note) {\n return { body: '', tag: null };\n }\n return {\n body: props.note.body || '',\n tag: props.note.tag || null,\n };\n },\n});\n\nconst { mutate: updateNote } = useMutation(\n (api, input: { id: string; body: string; tag?: string | null }) =>\n api.notes.updateNote(input),\n {\n invalidate: /^notes?:/,\n onSuccess: () => {\n // Refetch tags to include any new tags\n refetchNoteTags();\n },\n },\n);\n\nconst handleSubmit = async (formData: any) => {\n if (!props.note) {\n throw new Error('No note selected for editing');\n }\n\n const response = await updateNote({\n id: props.note.id,\n body: formData.body,\n tag: formData.tag || null,\n });\n\n if (!response) {\n throw new Error('Failed to update note');\n }\n\n return response;\n};\n\nconst handleSuccess = async () => {\n clearSavedFormState();\n refreshFormData(); // Reset form to initial state\n toast.success('Note updated successfully!');\n emit('success');\n closeModal();\n};\n\nconst handleError = (error: Error | unknown) => {\n form.setSubmitError(error instanceof Error ? error.message : 'An unknown error occurred');\n};\n\nconst closeModal = () => {\n emit('close');\n};\n\n// Watch for modal open/close\nwatch(\n () => props.isOpen,\n (isOpen) => {\n if (isOpen && modal.value) {\n modal.value.showModal();\n } else if (!isOpen && modal.value) {\n modal.value.close();\n // Reset form when modal closes\n refreshFormData();\n }\n },\n);\n\n// Watch for note changes to refresh form data\nwatch(\n () => props.note,\n () => {\n if (props.note && props.isOpen) {\n form.setValue('body', props.note.body || '');\n form.setValue('tag', props.note.tag || null);\n isInternalNote.value = props.note.is_internal || false;\n }\n },\n { immediate: true },\n);\n</script>\n","import { withMetadata } from '@dragonmastery/zinia-forms-core';\nimport { NoteCreateSchema } from '@dragonmastery/dragoncore-shared';\n\nexport const noteCreateMetadata = withMetadata(\n NoteCreateSchema.pick({ body: true, is_internal: true, tag: true }),\n 'noteCreateForm',\n {\n body: {\n label: 'Note',\n placeholder: 'Enter your note here...',\n inputType: 'textarea',\n helpText: 'Add a note about this record',\n },\n is_internal: {\n label: 'Internal Note',\n helpText: 'Check this box to make this note visible only to staff',\n },\n tag: {\n label: 'Tag',\n inputType: 'combobox',\n helpText: 'Optional tag to categorize this note',\n },\n },\n);\n","import { withMetadata } from '@dragonmastery/zinia-forms-core';\nimport { NoteReadSchema } from '@dragonmastery/dragoncore-shared';\nimport { z } from 'zod';\n\nexport const noteRowSchemaWithMetadata = withMetadata(NoteReadSchema, 'noteRowSchema', {\n body: { label: 'Note' },\n tag: { label: 'Tag', sortable: true },\n is_internal: { label: 'Visibility', sortable: true },\n created_at: { label: 'Created', sortable: true },\n created_by: { label: 'Created By', sortable: true },\n updated_at: { label: 'Updated', sortable: true },\n});\n\nexport type NoteRow = z.infer<typeof NoteReadSchema>;\n","<template>\n <div class=\"space-y-6\">\n <!-- Add Note Form -->\n <div class=\"mt-4\">\n <ZiniaForm\n @handle-submit=\"handleSubmit\"\n @success=\"handleSuccess\"\n @error=\"handleError\"\n title=\"\"\n subtitle=\"\"\n >\n <zinia.TagField :select-options=\"form.extraData.tag || []\" :allow-create=\"true\" />\n <zinia.BodyField />\n\n <div v-if=\"form.submitError\" class=\"alert alert-error mt-2\">\n <span>{{ form.submitError }}</span>\n </div>\n\n <div class=\"flex justify-end mt-6\">\n <ZiniaSubmitButton submitText=\"Add Note\" submittingText=\"Adding...\" />\n </div>\n\n <ZiniaFormErrorsSummary title=\"Please fix the following errors:\" />\n </ZiniaForm>\n </div>\n\n <!-- Notes Table -->\n <ZiniaDataTable>\n <template #cell-created_by=\"{ row }\">\n {{ getUserNameWithFallback(row.created_by) }}\n </template>\n <template #cell-created_at=\"{ row }\">\n {{ formatSystemTimestamp(row.created_at) }}\n </template>\n\n <template #cell-tag=\"{ row }\">\n {{ row.tag || '-' }}\n </template>\n\n <template #cell-updated_at=\"{ row }\">\n {{ row.updated_at ? formatSystemTimestamp(row.updated_at) : '-' }}\n </template>\n\n <template #cell-body=\"{ row }\">\n <div class=\"whitespace-pre-wrap\">\n {{ row.body || 'No content' }}\n </div>\n </template>\n </ZiniaDataTable>\n\n <!-- Edit Modal -->\n <EditNoteModal\n :note=\"selectedNote\"\n :is-open=\"isEditModalOpen\"\n @close=\"closeEditModal\"\n @success=\"handleEditSuccess\"\n />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { executeWithAuth } from '../../../composables/useRpcAuth';\nimport { getRefreshTokenHandler } from '../../../utils/EnhancedRefreshTokenHandler';\nimport { useMutation } from '../../../composables/useMutation';\nimport { useQuery } from '../../../composables/useQuery';\nimport { useUserLookup } from '../../../composables/useUserLookup';\nimport { formatSystemTimestamp } from '../../../utils/convertToLocalDateTime';\nimport EditNoteModal from './EditNoteModal.vue';\nimport { noteCreateMetadata } from '../noteFormMetadata';\nimport { noteRowSchemaWithMetadata, type NoteRow } from '../noteRowSchema';\nimport { ActionIcons, useCursorDataTable, useForm } from '@dragonmastery/zinia-forms-core';\nimport { OPERATORS, type NoteFiltersDto } from '@dragonmastery/dragoncore-shared';\nimport { computed, ref, watch } from 'vue';\nimport { toast } from 'vue3-toastify';\n\ninterface Props {\n recordId: string;\n recordType: string;\n mode?: 'customer' | 'internal';\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n mode: 'customer',\n});\n\n// Edit modal state\nconst selectedNote = ref<NoteRow | null>(null);\nconst isEditModalOpen = ref(false);\n\n// Computed properties for component intelligence\nconst isInternalNote = computed(() => {\n // Determine internal state based on mode\n return props.mode === 'internal';\n});\n\n// User lookup for mapping user IDs to usernames\nconst { getUserNameWithFallback } = useUserLookup((api) => api.teamMembers.getUserTeamMembers());\n\n// Query filters state\nconst queryFilters = ref<NoteFiltersDto>({\n record_id: { operator: OPERATORS.EQUALS, value: props.recordId },\n record_type: { operator: OPERATORS.EQUALS, value: props.recordType as any },\n});\n\n// Pagination token for breadcrumb navigation\nconst currentPaginationToken = ref<string | undefined | null>();\n\n// Fetch note tags for filter and form\nconst {\n data: noteTagsData,\n loading: noteTagsLoading,\n error: noteTagsError,\n refetch: refetchNoteTags,\n} = useQuery((api) => api.notes.getNoteTags());\n\n// Load note tags for filter options and form combobox\n// This function reads from noteTagsData.value, which is reactive\n// When refetchNoteTags() is called, noteTagsData.value updates\n// The next time this function is called (when filter dropdown opens), it will get fresh data\nconst loadNoteTags = async () => {\n // If query is loading, wait for it to complete to ensure we have fresh data\n while (noteTagsLoading.value) {\n await new Promise((resolve) => setTimeout(resolve, 100));\n }\n\n if (noteTagsError.value) {\n return [];\n }\n\n const tags = noteTagsData.value || [];\n\n return tags.map((tag: string) => ({\n value: tag,\n label: tag,\n }));\n};\n\n// Form setup\nconst { form, zinia, ZiniaForm, ZiniaSubmitButton, ZiniaFormErrorsSummary, refreshFormData } =\n useForm(noteCreateMetadata, {\n storeName: `note-form-${props.recordId}`,\n persistToLocalStorage: false,\n renderStyle: 'daisy_ui',\n dataLoaders: {\n tag: loadNoteTags,\n },\n fetchData: async () => ({\n body: '',\n tag: null,\n is_internal: isInternalNote.value,\n }),\n });\n\n// Data table configuration\nconst { ZiniaDataTable, refresh } = useCursorDataTable(noteRowSchemaWithMetadata, {\n fetchData: async ({ cursor, pageSize, sort, filters, search }) => {\n // Build query variables\n const variables: NoteFiltersDto = {\n first: pageSize,\n sortBy: sort?.field ? (sort.field as string) : 'created_at',\n sortDirection: (sort?.direction === 'asc' ? 'asc' : 'desc') as any,\n ...(cursor ? { after: cursor } : {}),\n ...(currentPaginationToken.value\n ? { paginationToken: currentPaginationToken.value }\n : {}),\n ...(search ? { search } : {}),\n record_id: { operator: OPERATORS.EQUALS, value: props.recordId },\n record_type: { operator: OPERATORS.EQUALS, value: props.recordType as any },\n ...filters,\n };\n\n // Apply visibility filter based on mode\n if (props.mode === 'customer') {\n variables.is_internal = { operator: OPERATORS.EQUALS, value: false };\n } else if (props.mode === 'internal') {\n variables.is_internal = { operator: OPERATORS.EQUALS, value: true };\n }\n // For 'all' mode, no filter is applied (shows everything)\n\n // Update query filters and execute\n queryFilters.value = variables;\n const result = await executeWithAuth(\n async (api) => {\n return await api.notes.getNotes(variables);\n },\n { refreshTokenHandler: getRefreshTokenHandler() },\n );\n currentPaginationToken.value = result?.pageInfo?.paginationToken;\n\n // Return paginated data\n return {\n data: result?.items || [],\n hasNextPage: result?.pageInfo?.hasNextPage ?? false,\n hasPreviousPage: result?.pageInfo?.hasPreviousPage ?? false,\n prevPageCursor: result?.pageInfo?.prevPageCursor ?? undefined,\n nextPageCursor: result?.pageInfo?.nextPageCursor ?? undefined,\n };\n },\n\n // Column configuration\n columns: {\n created_by: {\n label: 'Created By',\n field: 'created_by',\n sortable: true,\n verticalAlign: 'top',\n },\n updated_at: {\n label: 'Updated',\n field: 'updated_at',\n sortable: true,\n verticalAlign: 'top',\n },\n tag: {\n label: 'Tag',\n field: 'tag',\n sortable: true,\n filterable: true,\n filterType: 'select',\n filterOptionsLoader: loadNoteTags,\n verticalAlign: 'top',\n },\n body: {\n label: 'Note',\n field: 'body',\n sortable: false,\n },\n },\n\n // Action buttons\n actions: {\n column: {\n verticalAlign: 'top',\n },\n items: [\n {\n key: 'edit',\n icon: ActionIcons.edit,\n size: 'xs',\n variant: 'primary',\n type: 'button',\n onClick: (row: NoteRow) => openEditModal(row),\n },\n ],\n },\n\n // Pagination settings\n pagination: {\n pageSize: 25,\n },\n});\n\n// Mutations\nconst { mutate: createNote } = useMutation((api, input: any) => api.notes.createNote(input), {\n invalidate: /^notes?:/,\n onSuccess: () => {\n // Refetch tags to include any new tags\n refetchNoteTags();\n },\n});\n\n// Form handlers\nconst handleSubmit = async (formData: any) => {\n const result = await createNote({\n record_id: props.recordId,\n record_type: props.recordType,\n body: formData.body,\n tag: formData.tag || null,\n is_internal: isInternalNote.value,\n });\n refresh();\n return result;\n};\n\nconst handleSuccess = async () => {\n refreshFormData();\n toast.success('Note added successfully!');\n refresh();\n};\n\nconst handleError = (error: Error | unknown) => {\n form.setSubmitError(error instanceof Error ? error.message : 'An unknown error occurred');\n};\n\n// Edit modal handlers\nconst openEditModal = (note: NoteRow) => {\n selectedNote.value = note;\n isEditModalOpen.value = true;\n};\n\nconst closeEditModal = () => {\n isEditModalOpen.value = false;\n selectedNote.value = null;\n};\n\nconst handleEditSuccess = async () => {\n // Refetch tags to include any new tags from the updated note\n await refetchNoteTags();\n // Refresh the data table to show updated note\n refresh();\n};\n\n// Watch for changes in recordId or recordType to refresh the data table\nwatch(\n () => [props.recordId, props.recordType],\n () => {\n if (props.recordId && props.recordType) {\n refresh();\n }\n },\n);\n\n// Watch for changes in noteTagsData to refresh form's data loaders\n// This ensures the create note form's tag combobox gets updated options\nwatch(\n noteTagsData,\n async () => {\n // Reload the tag data loader to refresh form.extraData.tag\n if (form.extraData && form.extraData.tag !== undefined) {\n const newTags = await loadNoteTags();\n form.extraData.tag = newTags;\n }\n },\n { deep: true },\n);\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAAgB,cACd,SACA,SACA;CAEA,MAAM,EAAE,MAAM,iBAAiB,SAAS,6BAA6B,SAGnE,SAAS;EACT,UAAU,SAAS,YAAY;EAC/B,WAAW,SAAS,aAAa,OAAU,KAAK;EAChD,GAAG;EACJ,CAAC;CAGF,MAAM,UAAU,eAAe;EAC7B,MAAM,sBAAM,IAAI,KAAqB;AACrC,kBAAgB,OAAO,OAAO,SAAS,WAA2B;AAChE,OAAI,OAAO,SAAS;IAElB,MAAM,cAAc,OAAO,gBAAgB,OAAO;AAClD,QAAI,YACF,KAAI,IAAI,OAAO,SA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