@wisemen/wise-crm-web 2.0.0-alpha.8 → 3.0.0-alpha.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.
@@ -0,0 +1,561 @@
1
+ import { defineComponent as h, computed as y, openBlock as u, createBlock as m, unref as e, ref as k, withCtx as w, createCommentVNode as U, toValue as $, useTemplateRef as J, createElementBlock as I, withKeys as W, withModifiers as X, createElementVNode as T, createVNode as D, mergeProps as Y, toDisplayString as Z, nextTick as ee, watch as A, useModel as ae, mergeModels as te, Fragment as le, renderList as ne } from "vue";
2
+ import { useRouteParams as oe } from "@vueuse/router";
3
+ import { useOverlay as S, useToast as re, UIConfirmDialog as se, UIIconButton as q, UIDropdownMenuItem as ie, UITextField as ue, toFormField as de, UIButton as B, createSelectOptions as L, UIBadgeSelect as K, UIBadge as Q } from "@wisemen/vue-core-design-system";
4
+ import { u as N, y as ce, D as R, b as P, i as j, j as me, k as pe, E as fe, l as ye, n as ve, o as ge, c as M, p as _e, q as be, r as we, s as De, t as Ce, A as E, v as he, w as xe } from "./index-BddOTAwb.js";
5
+ import { useI18n as x } from "vue-i18n";
6
+ import { bB as Ue, bs as F } from "./uuid.util-DUuuAgdg.js";
7
+ import { N as z, _ as ke, u as Ne, a as Te, b as Ie, c as Se, d as Me, e as Ve } from "./CrmDetailHeaderBadge.vue_vue_type_script_setup_true_lang-kIUc1Vkb.js";
8
+ import { useMutation as V, useKeysetInfiniteQuery as $e, useQuery as Be } from "@wisemen/vue-core-api-utils";
9
+ import { useForm as Ee } from "formango";
10
+ import O from "zod";
11
+ function Fe() {
12
+ return V({
13
+ queryFn: async ({
14
+ body: n,
15
+ params: a
16
+ }) => await z.create(n, {
17
+ dealUuid: a.dealUuid
18
+ }),
19
+ queryKeysToInvalidate: {
20
+ noteDealIndex: {}
21
+ }
22
+ });
23
+ }
24
+ function Oe(n, a) {
25
+ return $e("noteDealIndex", {
26
+ params: {
27
+ params: a?.params
28
+ },
29
+ queryFn: (o) => z.getDealNotes({
30
+ pagination: o
31
+ }, n.value)
32
+ });
33
+ }
34
+ const Ae = /* @__PURE__ */ h({
35
+ __name: "DealDialogSidebarNotesContent",
36
+ props: {
37
+ deal: {}
38
+ },
39
+ setup(n) {
40
+ const a = n, i = S().create(ke), d = N(), c = Fe(), r = Ne(), t = Oe(
41
+ y(() => a.deal.uuid)
42
+ ), p = y(() => t.result.value.isOk() ? t.result.value.getValue().data : []);
43
+ async function _(l) {
44
+ await c.execute({
45
+ body: l,
46
+ params: {
47
+ dealUuid: a.deal.uuid
48
+ }
49
+ });
50
+ }
51
+ async function f(l) {
52
+ try {
53
+ await r.execute({
54
+ params: {
55
+ noteUuid: l
56
+ }
57
+ });
58
+ } catch (s) {
59
+ d.show(s);
60
+ }
61
+ }
62
+ function b(l) {
63
+ i.open({
64
+ note: l
65
+ });
66
+ }
67
+ return (l, s) => (u(), m(Te, {
68
+ "is-loading": e(t).isLoading.value,
69
+ notes: p.value,
70
+ "on-submit": _,
71
+ "has-next-page": e(t).hasNextPage.value,
72
+ onNext: s[0] || (s[0] = (v) => e(t).fetchNextPage()),
73
+ onDelete: f,
74
+ onUpdate: b
75
+ }, null, 8, ["is-loading", "notes", "has-next-page"]));
76
+ }
77
+ }), qe = /* @__PURE__ */ h({
78
+ __name: "DealActivityNotesPane",
79
+ props: {
80
+ deal: {}
81
+ },
82
+ setup(n) {
83
+ const a = n, o = x(), i = k(
84
+ "notes"
85
+ /* NOTES */
86
+ ), d = y(() => [
87
+ {
88
+ icon: ce,
89
+ label: o.t("wise_crm.shared.notes"),
90
+ value: "notes"
91
+ /* NOTES */
92
+ }
93
+ ]);
94
+ return (c, r) => (u(), m(Ie, {
95
+ modelValue: i.value,
96
+ "onUpdate:modelValue": r[0] || (r[0] = (t) => i.value = t),
97
+ tabs: d.value
98
+ }, {
99
+ default: w(() => [
100
+ i.value === "notes" ? (u(), m(Ae, {
101
+ key: 0,
102
+ deal: a.deal
103
+ }, null, 8, ["deal"])) : U("", !0)
104
+ ]),
105
+ _: 1
106
+ }, 8, ["modelValue", "tabs"]));
107
+ }
108
+ });
109
+ function Le() {
110
+ return V({
111
+ queryFn: async ({
112
+ params: n
113
+ }) => await R.delete(n.dealUuid),
114
+ queryKeysToInvalidate: {
115
+ dealIndex: {}
116
+ }
117
+ });
118
+ }
119
+ function G(n) {
120
+ const a = x(), o = re(), i = P(), c = S().create(se), r = Le();
121
+ function t() {
122
+ c.open({
123
+ title: a.t("wise_crm.deal.detail.sidebar.delete.title"),
124
+ isDestructive: !0,
125
+ confirmLabel: a.t("wise_crm.shared.delete"),
126
+ description: a.t("wise_crm.deal.detail.sidebar.delete.description", {
127
+ name: $(n).name
128
+ }),
129
+ onConfirm: async () => {
130
+ const p = await r.execute({
131
+ params: {
132
+ dealUuid: $(n).uuid
133
+ }
134
+ });
135
+ if (p.isErr()) {
136
+ o.apiError(p.error);
137
+ return;
138
+ }
139
+ c.close(), i.goToReturnRoute();
140
+ }
141
+ });
142
+ }
143
+ return {
144
+ onDelete: t
145
+ };
146
+ }
147
+ const Ke = /* @__PURE__ */ h({
148
+ __name: "DealDetailSidebarDeleteButton",
149
+ props: {
150
+ deal: {}
151
+ },
152
+ setup(n) {
153
+ const a = n, o = x(), i = G(() => a.deal);
154
+ return (d, c) => (u(), m(e(q), {
155
+ label: e(o).t("wise_crm.deal.detail.sidebar.delete.label"),
156
+ icon: e(j),
157
+ variant: "tertiary",
158
+ size: "sm",
159
+ class: "shrink-0",
160
+ onClick: e(i).onDelete
161
+ }, null, 8, ["label", "icon", "onClick"]));
162
+ }
163
+ }), Qe = /* @__PURE__ */ h({
164
+ __name: "DealDetailSidebarDeleteMenuItem",
165
+ props: {
166
+ deal: {}
167
+ },
168
+ setup(n) {
169
+ const a = n, o = x(), i = G(() => a.deal), d = {
170
+ left: {
171
+ icon: j,
172
+ type: "icon"
173
+ }
174
+ };
175
+ return (c, r) => (u(), m(e(ie), {
176
+ "is-destructive": !0,
177
+ config: d,
178
+ label: e(o).t("wise_crm.deal.detail.sidebar.delete.label"),
179
+ onSelect: e(i).onDelete
180
+ }, null, 8, ["label", "onSelect"]));
181
+ }
182
+ }), Re = { class: "flex items-center gap-md" }, Pe = { class: "min-w-0 flex-1" }, je = {
183
+ key: 1,
184
+ class: "flex items-center gap-xs"
185
+ }, ze = { class: "text-xl font-bold text-primary" }, Ge = /* @__PURE__ */ h({
186
+ __name: "DealDetailSidebarNameField",
187
+ props: {
188
+ deal: {}
189
+ },
190
+ setup(n) {
191
+ const a = n, o = x(), i = N(), d = k(!1), c = J("nameFieldContainerRef"), r = me(), t = Ee({
192
+ schema: O.object({
193
+ name: O.string().min(1)
194
+ }),
195
+ onSubmit: async (l) => {
196
+ try {
197
+ await r.execute({
198
+ body: {
199
+ name: l.name
200
+ },
201
+ params: {
202
+ dealUuid: a.deal.uuid
203
+ }
204
+ });
205
+ } catch (s) {
206
+ i.show(s);
207
+ } finally {
208
+ d.value = !1;
209
+ }
210
+ }
211
+ }), p = t.register("name", a.deal.name);
212
+ async function _() {
213
+ p.setValue(a.deal.name), d.value = !0, await ee(), f();
214
+ }
215
+ function f() {
216
+ c.value?.querySelector(
217
+ "input"
218
+ )?.focus();
219
+ }
220
+ function b() {
221
+ p.setValue(a.deal.name), d.value = !1;
222
+ }
223
+ return (l, s) => (u(), I("div", {
224
+ ref_key: "nameFieldContainerRef",
225
+ ref: c
226
+ }, [
227
+ d.value ? (u(), m(pe, {
228
+ key: 0,
229
+ form: e(t),
230
+ "data-name-editing": "",
231
+ onKeydown: W(X(b, ["prevent"]), ["escape"])
232
+ }, {
233
+ default: w(() => [
234
+ T("div", Re, [
235
+ T("div", Pe, [
236
+ D(e(ue), Y(e(de)(e(p)), {
237
+ "aria-label": e(o).t("wise_crm.deal.detail.sidebar.name_field.label")
238
+ }), null, 16, ["aria-label"])
239
+ ]),
240
+ D(e(B), {
241
+ label: e(o).t("wise_crm.form.cancel"),
242
+ variant: "secondary",
243
+ type: "button",
244
+ onClick: b
245
+ }, null, 8, ["label"]),
246
+ D(e(B), {
247
+ label: e(o).t("wise_crm.form.save"),
248
+ "is-loading": e(t).isSubmitting.value,
249
+ type: "submit"
250
+ }, null, 8, ["label", "is-loading"])
251
+ ])
252
+ ]),
253
+ _: 1
254
+ }, 8, ["form", "onKeydown"])) : (u(), I("div", je, [
255
+ T("h2", ze, Z(a.deal.name), 1),
256
+ D(e(q), {
257
+ label: e(o).t("wise_crm.deal.detail.sidebar.name_field.edit_label"),
258
+ icon: e(fe),
259
+ variant: "tertiary",
260
+ class: "shrink-0",
261
+ onClick: _
262
+ }, null, 8, ["label", "icon"])
263
+ ]))
264
+ ], 512));
265
+ }
266
+ }), He = /* @__PURE__ */ h({
267
+ __name: "DealDetailSidebarOwnerSelect",
268
+ props: {
269
+ deal: {}
270
+ },
271
+ setup(n) {
272
+ const a = n, o = x(), i = N(), d = ye(), c = ve({
273
+ persistInUrl: !1
274
+ }), r = ge({
275
+ params: {
276
+ search: c.debouncedSearch
277
+ }
278
+ }), t = k(a.deal.owner);
279
+ A(() => a.deal.owner, (l) => {
280
+ t.value = l;
281
+ });
282
+ const p = y(() => {
283
+ const l = (r.result.value.isOk() ? r.result.value.getValue().data : []).map((s) => ({
284
+ uuid: s.uuid,
285
+ name: `${s.firstName} ${s.lastName}`
286
+ }));
287
+ return L(l);
288
+ });
289
+ function _(l) {
290
+ return {
291
+ color: "neutral",
292
+ left: {
293
+ name: l.name,
294
+ type: "avatar"
295
+ }
296
+ };
297
+ }
298
+ function f(l) {
299
+ c.updateSearch(l);
300
+ }
301
+ async function b(l) {
302
+ if (t.value = l, l !== null)
303
+ try {
304
+ await d.execute({
305
+ body: {
306
+ dealOwner: l
307
+ },
308
+ params: {
309
+ dealUuid: a.deal.uuid
310
+ }
311
+ });
312
+ } catch (s) {
313
+ t.value = a.deal.owner, i.show(s);
314
+ }
315
+ }
316
+ return (l, s) => (u(), m(e(K), {
317
+ "model-value": t.value,
318
+ items: p.value,
319
+ "display-fn": (v) => v.name,
320
+ "get-item-config": _,
321
+ "get-item-key": (v) => v.uuid,
322
+ "is-loading": e(r).isLoading.value,
323
+ "is-saving": e(d).isLoading.value,
324
+ label: e(o).t("wise_crm.deal.detail.sidebar.owner_select.label"),
325
+ placeholder: e(o).t("wise_crm.deal.detail.sidebar.owner_select.placeholder"),
326
+ class: "shrink-0 text-nowrap",
327
+ search: "remote",
328
+ "onUpdate:modelValue": b,
329
+ "onUpdate:search": f,
330
+ onNextPage: s[0] || (s[0] = (v) => e(r).fetchNextPage())
331
+ }, null, 8, ["model-value", "items", "display-fn", "get-item-key", "is-loading", "is-saving", "label", "placeholder"]));
332
+ }
333
+ });
334
+ function Je() {
335
+ const n = M();
336
+ return V({
337
+ queryFn: async ({
338
+ body: a,
339
+ params: o
340
+ }) => {
341
+ const i = await R.transition(o.dealUuid, a.toBoardColumnUuid);
342
+ return i.isOk() && n.notifyDealChanged(o.dealUuid, _e.TRANSITION), i;
343
+ },
344
+ queryKeysToInvalidate: {
345
+ dealDetail: {
346
+ dealUuid: (a) => a.dealUuid
347
+ },
348
+ dealIndex: {}
349
+ }
350
+ });
351
+ }
352
+ function We(n, a) {
353
+ return Be("boardColumnsTransition", {
354
+ params: {
355
+ boardColumnUuid: n
356
+ },
357
+ queryFn: () => be.getTransitions(n.value, a.value)
358
+ });
359
+ }
360
+ const Xe = /* @__PURE__ */ h({
361
+ __name: "DealDetailSidebarTransitionSelect",
362
+ props: /* @__PURE__ */ te({
363
+ deal: {}
364
+ }, {
365
+ modelValue: {
366
+ required: !0
367
+ },
368
+ modelModifiers: {}
369
+ }),
370
+ emits: ["update:modelValue"],
371
+ setup(n) {
372
+ const a = n, o = x(), i = M(), c = S().create(we), r = ae(n, "modelValue"), t = N(), p = Je(), _ = We(
373
+ y(() => r.value.toColumnUuid),
374
+ y(() => i.getOptions().deals?.allowedTransitionTriggerTypes ?? [])
375
+ ), f = y(() => (_.result.value.isOk() ? _.result.value.getValue() : []).flatMap((C) => C.triggers.length === 0 ? [
376
+ C
377
+ ] : C.triggers.map((H) => ({
378
+ ...C,
379
+ toColumnDisplayName: C.toColumnDisplayName,
380
+ triggers: [
381
+ H
382
+ ]
383
+ }))));
384
+ function b(g) {
385
+ return g?.toColumnDisplayName ?? "-";
386
+ }
387
+ function l(g) {
388
+ return {
389
+ color: De[g.toColumnColor],
390
+ left: {
391
+ type: "dot"
392
+ }
393
+ };
394
+ }
395
+ const s = y(() => L(f.value));
396
+ async function v(g) {
397
+ if (!(g === null || g.triggers.length === 0)) {
398
+ if (g.triggers[0]?.triggerType === Ue.EMAIL) {
399
+ c.open({
400
+ dealUuid: a.deal.uuid,
401
+ client: {
402
+ uuid: a.deal.client.uuid,
403
+ type: a.deal.client.type
404
+ },
405
+ templateKey: g.triggers[0].config.mailTemplateKey
406
+ });
407
+ return;
408
+ }
409
+ try {
410
+ r.value = g, await p.execute({
411
+ body: {
412
+ toBoardColumnUuid: g.toColumnUuid
413
+ },
414
+ params: {
415
+ dealUuid: a.deal.uuid
416
+ }
417
+ });
418
+ } catch (C) {
419
+ t.show(C);
420
+ }
421
+ }
422
+ }
423
+ return (g, C) => f.value.length === 0 ? (u(), m(e(Q), {
424
+ key: 0,
425
+ "class-config": {
426
+ root: "text-nowrap"
427
+ },
428
+ label: r.value.toColumnDisplayName,
429
+ left: l(r.value).left,
430
+ color: l(r.value).color,
431
+ variant: "translucent"
432
+ }, null, 8, ["label", "left", "color"])) : (u(), m(e(K), {
433
+ key: 1,
434
+ "model-value": r.value,
435
+ "is-saving": e(p).isLoading.value,
436
+ "display-fn": b,
437
+ "get-item-config": l,
438
+ items: s.value,
439
+ placeholder: e(o).t("wise_crm.deal.transition.placeholder"),
440
+ label: e(o).t("wise_crm.deal.transition.label"),
441
+ class: "shrink-0 text-nowrap",
442
+ "content-width-class": "min-w-40",
443
+ "onUpdate:modelValue": v
444
+ }, null, 8, ["model-value", "is-saving", "items", "placeholder", "label"]));
445
+ }
446
+ }), ia = /* @__PURE__ */ h({
447
+ __name: "DealDetailView",
448
+ props: {
449
+ tabs: {}
450
+ },
451
+ setup(n) {
452
+ const a = n, o = x(), i = P(), d = M(), c = oe("dealUuid"), r = Ce(
453
+ y(() => c.value)
454
+ ), t = y(() => r.result.value.isOk() ? r.result.value.getValue() : null), p = y(
455
+ () => d.getOptions().deals?.headerBadges ?? []
456
+ ), _ = y(() => t.value?.createdAt ?? null), f = k(null);
457
+ A(t, (l) => {
458
+ l === null || f.value !== null || (f.value = {
459
+ uuid: "",
460
+ toColumnUuid: l.boardColumn.uuid,
461
+ toColumnColor: l.boardColumn.color,
462
+ toColumnDisplayName: l.boardColumn.displayName,
463
+ toColumnKey: "",
464
+ triggers: []
465
+ });
466
+ }, {
467
+ immediate: !0
468
+ });
469
+ const b = y(() => [
470
+ ...a.tabs,
471
+ {
472
+ label: y(() => o.t("wise_crm.deal.detail_view.communication_tab_label")),
473
+ to: "deal-communication"
474
+ }
475
+ ]);
476
+ return (l, s) => (u(), m(Se, {
477
+ key: e(c),
478
+ "entity-type": e(F).BUSINESS,
479
+ "background-color": f.value?.toColumnColor ?? t.value?.boardColumn.color ?? null,
480
+ tabs: b.value,
481
+ "created-at": t.value?.createdAt ?? null,
482
+ "last-activity-at": _.value
483
+ }, {
484
+ header: w(() => [
485
+ e(r).isLoading.value ? (u(), m(E, {
486
+ key: 0,
487
+ class: "h-24 w-full"
488
+ })) : t.value ? (u(), m(Me, {
489
+ key: 1,
490
+ "entity-type": e(F).BUSINESS,
491
+ "entity-label": null,
492
+ name: t.value.name,
493
+ identifier: t.value.dealNumber,
494
+ status: null,
495
+ owner: t.value.owner?.name ?? null,
496
+ "created-at": t.value.createdAt,
497
+ address: null,
498
+ email: null,
499
+ "mobile-phone": null,
500
+ phone: null
501
+ }, {
502
+ name: w(() => [
503
+ D(Ge, { deal: t.value }, null, 8, ["deal"])
504
+ ]),
505
+ actions: w(() => [
506
+ D(Ke, { deal: t.value }, null, 8, ["deal"])
507
+ ]),
508
+ "menu-actions": w(() => [
509
+ D(Qe, { deal: t.value }, null, 8, ["deal"])
510
+ ]),
511
+ badges: w(() => [
512
+ D(he, {
513
+ class: "max-w-40 min-w-0",
514
+ onClick: s[0] || (s[0] = (v) => e(i).openBusinessDetail(t.value.client.uuid))
515
+ }, {
516
+ default: w(() => [
517
+ D(e(Q), {
518
+ icon: e(xe),
519
+ label: t.value.client.name,
520
+ color: "brand",
521
+ variant: "translucent",
522
+ class: "max-w-full"
523
+ }, null, 8, ["icon", "label"])
524
+ ]),
525
+ _: 1
526
+ }),
527
+ f.value !== null ? (u(), m(Xe, {
528
+ key: 0,
529
+ modelValue: f.value,
530
+ "onUpdate:modelValue": s[1] || (s[1] = (v) => f.value = v),
531
+ deal: t.value
532
+ }, null, 8, ["modelValue", "deal"])) : U("", !0),
533
+ (u(!0), I(le, null, ne(p.value, (v) => (u(), m(Ve, {
534
+ key: v.key,
535
+ badge: v,
536
+ uuid: t.value.uuid,
537
+ entity: "deal"
538
+ }, null, 8, ["badge", "uuid"]))), 128))
539
+ ]),
540
+ owner: w(() => [
541
+ D(He, { deal: t.value }, null, 8, ["deal"])
542
+ ]),
543
+ _: 1
544
+ }, 8, ["entity-type", "name", "identifier", "owner", "created-at"])) : U("", !0)
545
+ ]),
546
+ sidebar: w(() => [
547
+ e(r).isLoading.value ? (u(), m(E, {
548
+ key: 0,
549
+ class: "h-full"
550
+ })) : t.value ? (u(), m(qe, {
551
+ key: 1,
552
+ deal: t.value
553
+ }, null, 8, ["deal"])) : U("", !0)
554
+ ]),
555
+ _: 1
556
+ }, 8, ["entity-type", "background-color", "tabs", "created-at", "last-activity-at"]));
557
+ }
558
+ });
559
+ export {
560
+ ia as default
561
+ };