@wisemen/wise-crm-web 2.0.0-alpha.2 → 2.0.0-alpha.20

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,1508 @@
1
+ import { defineComponent as x, openBlock as d, createBlock as g, unref as e, ref as V, useTemplateRef as Se, createElementBlock as q, withCtx as r, createVNode as o, mergeProps as O, createElementVNode as S, toDisplayString as z, nextTick as ke, computed as w, createCommentVNode as F, Fragment as te, createTextVNode as ie, renderList as Fe, useModel as $e, mergeModels as Te } from "vue";
2
+ import { useRouteParams as Me } from "@vueuse/router";
3
+ import { useI18n as I } from "vue-i18n";
4
+ import { bq as fe, bv as Ve, bx as qe, bA as Ee } from "./uuid.util-8nyk7pzI.js";
5
+ import { _ as Le } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-BRN9QeuV.js";
6
+ import { c as k, d as pe, e as Oe, f as $, h as L, i as Qe, E as _e, C as ge, j as Ae, k as Be, l as Ke, n as je, o as R, g as Re, J as ze, p as Ge, q as re, r as Ye, I as Ze, s as ye, t as A, v as He, w as be, x as Je, y as Xe, U as We, z as ea, u as aa, B as ta, Q as na, F as la, G as oa, H as ia, K as se, L as he, N as ra, O as ue, P as sa, R as ua, S as ca, T as da, V as ve, W as ma, X as fa, Y as pa, Z as _a, $ as ga, a0 as ya, a1 as ba, a2 as ha, a3 as va, a4 as Ua, A as Ca } from "./index-BAluxtb7.js";
7
+ import { useToast as Ue, useOverlay as H, UIConfirmDialog as wa, UIIconButton as ne, UITextField as G, toFormField as Q, UIDropdownMenu as Pa, UIDropdownMenuGroup as Da, UIDropdownMenuItem as ce, UIPhoneNumberField as de, UIFormLayout as le, UIFormFieldGroup as B, UIFormFieldGrid as K, UIFormDialog as Ce, UIDialogHeader as we, UIForm as me, UIDialogBody as J, UIDialogFooter as X, UIDialogFooterSubmit as W, createAutocompleteOptions as xa, createSelectOptions as ee, UIAutocomplete as Ia, UISelect as ae, UIButton as Na, UIBadge as Pe } from "@wisemen/vue-core-design-system";
8
+ import { useMutation as T, useQuery as De, useOffsetInfiniteQuery as Sa, useKeysetInfiniteQuery as ka } from "@wisemen/vue-core-api-utils";
9
+ import { useForm as Y } from "formango";
10
+ import Z, { z as N } from "zod";
11
+ import { Motion as Fa } from "motion-v";
12
+ import { useQueryClient as $a, useMutation as Ta } from "@tanstack/vue-query";
13
+ function Ma() {
14
+ return T({
15
+ queryFn: async ({
16
+ params: n
17
+ }) => await k.delete(n.dealUuid),
18
+ queryKeysToInvalidate: {
19
+ dealIndex: {}
20
+ }
21
+ });
22
+ }
23
+ const Va = /* @__PURE__ */ x({
24
+ __name: "DealDetailSidebarDeleteButton",
25
+ props: {
26
+ deal: {}
27
+ },
28
+ setup(n) {
29
+ const a = n, t = I(), l = Ue(), i = pe(), c = H().create(wa), m = Ma();
30
+ function f() {
31
+ c.open({
32
+ title: t.t("wise_crm.deal.detail.sidebar.delete.title"),
33
+ isDestructive: !0,
34
+ confirmLabel: t.t("wise_crm.shared.delete"),
35
+ description: t.t("wise_crm.deal.detail.sidebar.delete.description", {
36
+ name: a.deal.name
37
+ }),
38
+ onConfirm: async () => {
39
+ const u = await m.execute({
40
+ params: {
41
+ dealUuid: a.deal.uuid
42
+ }
43
+ });
44
+ if (u.isErr()) {
45
+ l.apiError(u.error);
46
+ return;
47
+ }
48
+ c.close(), i.goToReturnRoute();
49
+ }
50
+ });
51
+ }
52
+ return (u, y) => (d(), g(e(ne), {
53
+ label: e(t).t("wise_crm.deal.detail.sidebar.delete.label"),
54
+ icon: e(Oe),
55
+ variant: "tertiary",
56
+ class: "shrink-0",
57
+ onClick: f
58
+ }, null, 8, ["label", "icon"]));
59
+ }
60
+ });
61
+ function qa() {
62
+ const n = $();
63
+ return T({
64
+ queryFn: async ({
65
+ body: a,
66
+ params: t
67
+ }) => {
68
+ const l = await k.update(t.dealUuid, {
69
+ dealLanguage: a.dealLanguage
70
+ });
71
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
72
+ },
73
+ queryKeysToInvalidate: {
74
+ dealDetail: {
75
+ dealUuid: (a) => a.dealUuid
76
+ },
77
+ dealIndex: {}
78
+ }
79
+ });
80
+ }
81
+ function Ea() {
82
+ const n = $();
83
+ return T({
84
+ queryFn: async ({
85
+ body: a,
86
+ params: t
87
+ }) => {
88
+ const l = await k.update(t.dealUuid, {
89
+ dealSource: a.dealSource
90
+ });
91
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
92
+ },
93
+ queryKeysToInvalidate: {
94
+ dealDetail: {
95
+ dealUuid: (a) => a.dealUuid
96
+ },
97
+ dealIndex: {}
98
+ }
99
+ });
100
+ }
101
+ function La() {
102
+ const n = $();
103
+ return T({
104
+ queryFn: async ({
105
+ body: a,
106
+ params: t
107
+ }) => {
108
+ const l = await k.update(t.dealUuid, {
109
+ dealOwner: a.dealOwner
110
+ });
111
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
112
+ },
113
+ queryKeysToInvalidate: {
114
+ dealDetail: {
115
+ dealUuid: (a) => a.dealUuid
116
+ },
117
+ dealIndex: {}
118
+ }
119
+ });
120
+ }
121
+ function Oa() {
122
+ const n = $();
123
+ return T({
124
+ queryFn: async ({
125
+ body: a,
126
+ params: t
127
+ }) => {
128
+ const l = await k.update(t.dealUuid, {
129
+ name: a.name
130
+ });
131
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
132
+ },
133
+ queryKeysToInvalidate: {
134
+ dealDetail: {
135
+ dealUuid: (a) => a.dealUuid
136
+ },
137
+ dealIndex: {}
138
+ }
139
+ });
140
+ }
141
+ const Qa = {
142
+ key: 1,
143
+ class: "flex justify-between"
144
+ }, Aa = { class: "text-xl font-bold text-primary" }, Ba = /* @__PURE__ */ x({
145
+ __name: "DealDetailSidebarNameField",
146
+ props: {
147
+ deal: {}
148
+ },
149
+ setup(n) {
150
+ const a = n, t = I(), l = L(), i = V(!1), s = Se("nameFieldContainerRef"), c = Oa(), m = Y({
151
+ schema: Z.object({
152
+ name: Z.string().min(1)
153
+ }),
154
+ onSubmit: async (_) => {
155
+ try {
156
+ await c.execute({
157
+ body: {
158
+ name: _.name
159
+ },
160
+ params: {
161
+ dealUuid: a.deal.uuid
162
+ }
163
+ });
164
+ } catch (b) {
165
+ l.show(b);
166
+ } finally {
167
+ i.value = !1;
168
+ }
169
+ }
170
+ }), f = m.register("name", a.deal.name);
171
+ async function u() {
172
+ i.value = !0, await ke(), y();
173
+ }
174
+ function y() {
175
+ s.value?.querySelector(
176
+ "input"
177
+ )?.focus();
178
+ }
179
+ function h() {
180
+ if (!m.isDirty.value) {
181
+ i.value = !1;
182
+ return;
183
+ }
184
+ m.submit();
185
+ }
186
+ return (_, b) => (d(), q("div", {
187
+ ref_key: "nameFieldContainerRef",
188
+ ref: s
189
+ }, [
190
+ i.value ? (d(), g(Qe, {
191
+ key: 0,
192
+ form: e(m)
193
+ }, {
194
+ default: r(() => [
195
+ o(e(G), O(e(Q)(e(f)), {
196
+ "is-loading": e(m).isSubmitting.value,
197
+ label: e(t).t("wise_crm.deal.detail.sidebar.name_field.label"),
198
+ class: "[&_input]:text-xl [&_input]:font-bold",
199
+ onBlur: h
200
+ }), null, 16, ["is-loading", "label"]),
201
+ b[0] || (b[0] = S("button", {
202
+ type: "submit",
203
+ class: "sr-only"
204
+ }, null, -1))
205
+ ]),
206
+ _: 1
207
+ }, 8, ["form"])) : (d(), q("div", Qa, [
208
+ S("h2", Aa, z(a.deal.name), 1),
209
+ o(e(ne), {
210
+ label: e(t).t("wise_crm.deal.detail.sidebar.name_field.edit_label"),
211
+ icon: e(_e),
212
+ variant: "tertiary",
213
+ class: "shrink-0",
214
+ onClick: u
215
+ }, null, 8, ["label", "icon"])
216
+ ]))
217
+ ], 512));
218
+ }
219
+ });
220
+ function Ka() {
221
+ const n = $a(), a = $(), t = "dealDetail", l = Ta({
222
+ mutationFn: async (i) => {
223
+ const s = await k.setPrimaryContactPerson(i.dealUuid, i.contactPersonUuid);
224
+ if (s.isErr())
225
+ throw s.error;
226
+ a.notifyDealChanged(i.dealUuid);
227
+ },
228
+ onError: (i, s, c) => {
229
+ n.setQueryData(
230
+ [
231
+ t,
232
+ {
233
+ dealUuid: s.dealUuid
234
+ }
235
+ ],
236
+ c?.previousData
237
+ );
238
+ },
239
+ onMutate: async (i) => {
240
+ await n.cancelQueries({
241
+ queryKey: [
242
+ t,
243
+ {
244
+ dealUuid: i.dealUuid
245
+ }
246
+ ]
247
+ });
248
+ const s = n.getQueryData(
249
+ [
250
+ t,
251
+ {
252
+ dealUuid: i.dealUuid
253
+ }
254
+ ]
255
+ );
256
+ return s === void 0 ? {} : (n.setQueryData(
257
+ [
258
+ t,
259
+ {
260
+ dealUuid: i.dealUuid
261
+ }
262
+ ],
263
+ s.map((c) => ({
264
+ ...c,
265
+ contactPersons: c.contactPersons.map((m) => ({
266
+ ...m,
267
+ isPrimary: m.uuid === i.contactPersonUuid
268
+ }))
269
+ }))
270
+ ), {
271
+ previousData: s
272
+ });
273
+ },
274
+ onSettled: (i, s, c) => {
275
+ c !== void 0 && n.invalidateQueries({
276
+ queryKey: [
277
+ t,
278
+ {
279
+ dealUuid: c.dealUuid
280
+ }
281
+ ]
282
+ });
283
+ }
284
+ });
285
+ return {
286
+ isLoading: w(() => l.isPending.value),
287
+ data: w(() => l.data.value),
288
+ execute: async (i) => await l.mutateAsync(i.params)
289
+ };
290
+ }
291
+ function ja() {
292
+ const n = $();
293
+ return T({
294
+ queryFn: async ({
295
+ body: a,
296
+ params: t
297
+ }) => {
298
+ const l = await k.unlinkContactPerson(t.dealUuid, a.contactPersonUuid);
299
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
300
+ },
301
+ queryKeysToInvalidate: {
302
+ dealDetail: {
303
+ dealUuid: (a) => a.dealUuid
304
+ },
305
+ dealIndex: {}
306
+ }
307
+ });
308
+ }
309
+ const Ra = { class: "flex items-start justify-between" }, za = { class: "flex flex-col items-start" }, Ga = {
310
+ key: 1,
311
+ class: "mt-sm text-brand-700"
312
+ }, Ya = { class: "-mt-2 -mr-2 flex items-center justify-end" }, Za = { class: "grid gap-lg" }, Ha = /* @__PURE__ */ x({
313
+ __name: "CrmDetailSidebarAccordionGenericContactPersonInfo",
314
+ props: {
315
+ contactPerson: {},
316
+ description: { default: null },
317
+ onToggleIsPrimary: {}
318
+ },
319
+ emits: ["delete", "update"],
320
+ setup(n, { emit: a }) {
321
+ const t = n, l = a, i = I(), s = t.contactPerson.uuid ?? t.contactPerson.contactPersonUuid, c = {
322
+ left: {
323
+ icon: _e,
324
+ type: "icon"
325
+ }
326
+ }, m = {
327
+ left: {
328
+ icon: Ke,
329
+ type: "icon"
330
+ }
331
+ };
332
+ function f() {
333
+ l("update");
334
+ }
335
+ function u() {
336
+ l("delete");
337
+ }
338
+ function y() {
339
+ t.onToggleIsPrimary();
340
+ }
341
+ return (h, _) => (d(), g(ge, { class: "flex flex-col gap-lg" }, {
342
+ default: r(() => [
343
+ S("div", Ra, [
344
+ S("div", za, [
345
+ e(s) ? (d(), g(Ae, {
346
+ key: 0,
347
+ label: `${t.contactPerson.firstName} ${t.contactPerson.lastName}`,
348
+ "entity-type": e(fe).INDIVIDUAL,
349
+ uuid: e(s),
350
+ class: "-m-xs"
351
+ }, null, 8, ["label", "entity-type", "uuid"])) : F("", !0),
352
+ t.description ? (d(), q("p", Ga, z(t.description), 1)) : F("", !0)
353
+ ]),
354
+ S("div", Ya, [
355
+ o(Be, {
356
+ "is-active": t.contactPerson.isPrimary,
357
+ onClick: y
358
+ }, null, 8, ["is-active"]),
359
+ o(e(Pa), { "popover-align": "end" }, {
360
+ trigger: r(() => [
361
+ o(e(ne), {
362
+ icon: e(je),
363
+ variant: "tertiary",
364
+ size: "sm",
365
+ label: "actionMenu"
366
+ }, null, 8, ["icon"])
367
+ ]),
368
+ content: r(() => [
369
+ o(e(Da), null, {
370
+ default: r(() => [
371
+ o(e(ce), {
372
+ config: c,
373
+ label: e(i).t("wise_crm.info_dialog.sidebar.overview.update_contact_person"),
374
+ onSelect: f
375
+ }, null, 8, ["label"]),
376
+ o(e(ce), {
377
+ "is-destructive": !0,
378
+ "is-disabled": t.contactPerson.isPrimary,
379
+ config: m,
380
+ label: e(i).t("wise_crm.info_dialog.sidebar.overview.delete_contact_person"),
381
+ onSelect: u
382
+ }, null, 8, ["is-disabled", "label"])
383
+ ]),
384
+ _: 1
385
+ })
386
+ ]),
387
+ _: 1
388
+ })
389
+ ])
390
+ ]),
391
+ S("div", Za, [
392
+ t.contactPerson.email !== null ? (d(), g(R, {
393
+ key: 0,
394
+ label: t.contactPerson.email,
395
+ icon: e(Re)
396
+ }, null, 8, ["label", "icon"])) : F("", !0),
397
+ t.contactPerson.mobilePhone !== null ? (d(), g(R, {
398
+ key: 1,
399
+ label: t.contactPerson.mobilePhone,
400
+ icon: e(ze)
401
+ }, null, 8, ["label", "icon"])) : F("", !0),
402
+ t.contactPerson.phone !== null ? (d(), g(R, {
403
+ key: 2,
404
+ label: t.contactPerson.phone,
405
+ icon: e(Ge)
406
+ }, null, 8, ["label", "icon"])) : F("", !0)
407
+ ])
408
+ ]),
409
+ _: 1
410
+ }));
411
+ }
412
+ });
413
+ function Ja() {
414
+ const n = $();
415
+ return T({
416
+ queryFn: async ({
417
+ body: a,
418
+ params: t
419
+ }) => {
420
+ const l = await k.linkContactPerson(
421
+ t.dealUuid,
422
+ a.contactPersonUuid,
423
+ a.contactInfo
424
+ );
425
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
426
+ },
427
+ queryKeysToInvalidate: {
428
+ dealDetail: {
429
+ dealUuid: (a) => a.dealUuid
430
+ },
431
+ dealIndex: {}
432
+ }
433
+ });
434
+ }
435
+ const oe = /* @__PURE__ */ x({
436
+ __name: "ContactPersonFormContactField",
437
+ props: {
438
+ email: {},
439
+ mobilePhone: {},
440
+ phone: {}
441
+ },
442
+ setup(n) {
443
+ const a = n, t = I();
444
+ return (l, i) => (d(), q(te, null, [
445
+ o(e(G), O(e(Q)(a.email), {
446
+ label: e(t).t("wise_crm.contact.create_dialog.form.fields.email"),
447
+ placeholder: e(t).t("wise_crm.contact.create_dialog.form.fields.email"),
448
+ class: "col-span-2"
449
+ }), null, 16, ["label", "placeholder"]),
450
+ o(re, { class: "col-span-2" }, {
451
+ default: r(() => [
452
+ ie(z(e(t).t("wise_crm.contact.create_dialog.form.seperator_label")), 1)
453
+ ]),
454
+ _: 1
455
+ }),
456
+ o(e(de), O(e(Q)(a.mobilePhone), {
457
+ label: e(t).t("wise_crm.contact.create_dialog.form.fields.mobile_phone"),
458
+ placeholder: e(t).t("wise_crm.contact.create_dialog.form.fields.mobile_phone"),
459
+ class: "col-span-2"
460
+ }), null, 16, ["label", "placeholder"]),
461
+ o(re, { class: "col-span-2" }, {
462
+ default: r(() => [
463
+ ie(z(e(t).t("wise_crm.contact.create_dialog.form.seperator_label")), 1)
464
+ ]),
465
+ _: 1
466
+ }),
467
+ o(e(de), O(e(Q)(a.phone), {
468
+ label: e(t).t("wise_crm.contact.create_dialog.form.fields.phone"),
469
+ placeholder: e(t).t("wise_crm.contact.create_dialog.form.fields.phone"),
470
+ class: "col-span-2"
471
+ }), null, 16, ["label", "placeholder"])
472
+ ], 64));
473
+ }
474
+ }), Xa = /* @__PURE__ */ x({
475
+ __name: "DealContactPersonCreateExistingForm",
476
+ props: {
477
+ form: {}
478
+ },
479
+ emits: ["createNewContactPerson"],
480
+ setup(n, { emit: a }) {
481
+ const t = n, l = a, i = I(), s = t.form.register("email"), c = t.form.register("phone"), m = t.form.register("mobile"), f = t.form.register("existingContactPerson"), u = V(null);
482
+ async function y(h) {
483
+ if (u.value = h, f.setValue(h?.uuid ?? null), h === null)
484
+ return;
485
+ const _ = await Ze.getByUuid(h.uuid);
486
+ if (_.isErr())
487
+ return;
488
+ const b = _.value;
489
+ s.setValue(b.email), c.setValue(b.phone), m.setValue(b.mobilePhone);
490
+ }
491
+ return (h, _) => (d(), g(e(le), null, {
492
+ default: r(() => [
493
+ o(e(B), null, {
494
+ default: r(() => [
495
+ o(Ye, {
496
+ modelValue: u.value,
497
+ "onUpdate:modelValue": [
498
+ _[0] || (_[0] = (b) => u.value = b),
499
+ y
500
+ ],
501
+ label: e(i).t("wise_crm.contact.create_dialog.form.fields.contact_person"),
502
+ onCreateNew: _[1] || (_[1] = (b) => l("createNewContactPerson"))
503
+ }, null, 8, ["modelValue", "label"])
504
+ ]),
505
+ _: 1
506
+ }),
507
+ o(e(B), null, {
508
+ default: r(() => [
509
+ o(e(K), {
510
+ sm: 1,
511
+ lg: 1,
512
+ variant: "card"
513
+ }, {
514
+ default: r(() => [
515
+ o(oe, {
516
+ email: e(s),
517
+ "mobile-phone": e(m),
518
+ phone: e(c)
519
+ }, null, 8, ["email", "mobile-phone", "phone"])
520
+ ]),
521
+ _: 1
522
+ })
523
+ ]),
524
+ _: 1
525
+ })
526
+ ]),
527
+ _: 1
528
+ }));
529
+ }
530
+ }), xe = /* @__PURE__ */ x({
531
+ __name: "ContactPersonFormNameField",
532
+ props: {
533
+ firstName: {},
534
+ lastName: {}
535
+ },
536
+ setup(n) {
537
+ const a = n, t = I();
538
+ return (l, i) => (d(), q(te, null, [
539
+ o(e(G), O(e(Q)(a.firstName), {
540
+ label: e(t).t("wise_crm.contact.create_dialog.form.fields.first_name"),
541
+ placeholder: e(t).t("wise_crm.contact.create_dialog.form.fields.first_name")
542
+ }), null, 16, ["label", "placeholder"]),
543
+ o(e(G), O(e(Q)(a.lastName), {
544
+ label: e(t).t("wise_crm.contact.create_dialog.form.fields.last_name"),
545
+ placeholder: e(t).t("wise_crm.contact.create_dialog.form.fields.last_name")
546
+ }), null, 16, ["label", "placeholder"])
547
+ ], 64));
548
+ }
549
+ }), Wa = /* @__PURE__ */ x({
550
+ __name: "DealContactPersonCreateNewForm",
551
+ props: {
552
+ form: {}
553
+ },
554
+ setup(n) {
555
+ const a = n, t = a.form.register("firstName"), l = a.form.register("lastName"), i = a.form.register("email"), s = a.form.register("mobilePhone"), c = a.form.register("phone");
556
+ return (m, f) => (d(), g(e(le), null, {
557
+ default: r(() => [
558
+ o(e(B), null, {
559
+ default: r(() => [
560
+ o(e(K), {
561
+ sm: 1,
562
+ lg: 2
563
+ }, {
564
+ default: r(() => [
565
+ o(xe, {
566
+ "first-name": e(t),
567
+ "last-name": e(l)
568
+ }, null, 8, ["first-name", "last-name"])
569
+ ]),
570
+ _: 1
571
+ })
572
+ ]),
573
+ _: 1
574
+ }),
575
+ o(e(B), null, {
576
+ default: r(() => [
577
+ o(e(K), {
578
+ sm: 1,
579
+ lg: 1,
580
+ variant: "card"
581
+ }, {
582
+ default: r(() => [
583
+ o(oe, {
584
+ email: e(i),
585
+ "mobile-phone": e(s),
586
+ phone: e(c)
587
+ }, null, 8, ["email", "mobile-phone", "phone"])
588
+ ]),
589
+ _: 1
590
+ }),
591
+ o(ye, {
592
+ form: a.form
593
+ }, null, 8, ["form"])
594
+ ]),
595
+ _: 1
596
+ })
597
+ ]),
598
+ _: 1
599
+ }));
600
+ }
601
+ }), et = Z.object({
602
+ email: Z.email().nullable(),
603
+ existingContactPerson: He.nullable(),
604
+ mobile: A.nullable(),
605
+ phone: A.nullable()
606
+ }), at = N.object({
607
+ email: N.literal("").or(N.email()).nullable(),
608
+ firstName: N.string().min(1),
609
+ lastName: N.string().min(1),
610
+ mobilePhone: A.nullable(),
611
+ phone: A.nullable()
612
+ }).superRefine((n, a) => {
613
+ n.email !== null && n.email !== "" || n.mobilePhone !== null && n.mobilePhone !== "" || n.phone !== null && n.phone !== "" || a.addIssue({
614
+ code: N.ZodIssueCode.custom,
615
+ message: be.global.t("wise_crm.form.errors.at_least_one")
616
+ });
617
+ }), tt = /* @__PURE__ */ x({
618
+ __name: "DealContactPersonCreateDialog",
619
+ props: {
620
+ dealUuid: {},
621
+ isCreatingNewContactPerson: { type: Boolean, default: !1 }
622
+ },
623
+ emits: ["close", "createNewContactPerson"],
624
+ setup(n, { emit: a }) {
625
+ const t = n, l = a, i = I(), s = L(), c = Ue(), m = Ja(), f = Je(), u = V(t.isCreatingNewContactPerson), y = Y({
626
+ schema: at,
627
+ onSubmit: async (p) => {
628
+ try {
629
+ const P = await f.execute({
630
+ body: {
631
+ email: p.email,
632
+ firstName: p.firstName,
633
+ lastName: p.lastName,
634
+ mobilePhone: p.mobilePhone,
635
+ phone: p.phone
636
+ }
637
+ });
638
+ if (P.isErr()) {
639
+ s.show(P.error);
640
+ return;
641
+ }
642
+ const M = P.value;
643
+ if (!t.isCreatingNewContactPerson) {
644
+ const j = await m.execute({
645
+ body: {
646
+ contactPersonUuid: M,
647
+ contactInfo: {
648
+ email: p.email,
649
+ mobilePhone: p.mobilePhone,
650
+ phone: p.phone
651
+ }
652
+ },
653
+ params: {
654
+ dealUuid: t.dealUuid
655
+ }
656
+ });
657
+ if (j.isErr()) {
658
+ s.show(j.error);
659
+ return;
660
+ }
661
+ }
662
+ C({
663
+ label: `${p.firstName} ${p.lastName}`,
664
+ value: M
665
+ });
666
+ } catch (P) {
667
+ s.show(P);
668
+ }
669
+ },
670
+ onSubmitError: () => {
671
+ c.unableToSave();
672
+ }
673
+ }), h = Y({
674
+ schema: et,
675
+ onSubmit: async (p) => {
676
+ await v(
677
+ p.existingContactPerson,
678
+ {
679
+ email: p.email,
680
+ mobilePhone: p.mobile,
681
+ phone: p.phone
682
+ }
683
+ );
684
+ },
685
+ onSubmitError: () => {
686
+ c.unableToSave();
687
+ }
688
+ }), _ = w(
689
+ () => u.value ? y : h
690
+ );
691
+ function b() {
692
+ u.value = !0;
693
+ }
694
+ async function v(p, P) {
695
+ if (p !== null)
696
+ try {
697
+ await m.execute({
698
+ body: {
699
+ contactPersonUuid: p,
700
+ contactInfo: P
701
+ },
702
+ params: {
703
+ dealUuid: t.dealUuid
704
+ }
705
+ }), C();
706
+ } catch (M) {
707
+ s.show(M);
708
+ }
709
+ }
710
+ function C(p) {
711
+ if (p === void 0) {
712
+ l("close");
713
+ return;
714
+ }
715
+ l("createNewContactPerson", p), l("close");
716
+ }
717
+ return (p, P) => (d(), g(e(Ce), {
718
+ form: _.value,
719
+ size: "md",
720
+ "render-own-form-component": "",
721
+ onClose: C
722
+ }, {
723
+ default: r(() => [
724
+ o(e(we), {
725
+ title: e(i).t("wise_crm.info_dialog.contact_person_create.title"),
726
+ description: e(i).t("wise_crm.info_dialog.contact_person_create.description")
727
+ }, null, 8, ["title", "description"]),
728
+ u.value ? (d(), g(e(me), {
729
+ key: 0,
730
+ form: e(y),
731
+ "prompt-on-unsaved-changes": !1
732
+ }, {
733
+ default: r(() => [
734
+ o(e(J), null, {
735
+ default: r(() => [
736
+ o(Wa, { form: e(y) }, null, 8, ["form"])
737
+ ]),
738
+ _: 1
739
+ }),
740
+ o(e(X), null, {
741
+ right: r(() => [
742
+ o(e(W), {
743
+ "is-loading": e(y).isSubmitting.value,
744
+ label: e(i).t("wise_crm.shared.create")
745
+ }, null, 8, ["is-loading", "label"])
746
+ ]),
747
+ _: 1
748
+ })
749
+ ]),
750
+ _: 1
751
+ }, 8, ["form"])) : (d(), g(e(me), {
752
+ key: 1,
753
+ form: e(h),
754
+ "prompt-on-unsaved-changes": !1
755
+ }, {
756
+ default: r(() => [
757
+ o(e(J), null, {
758
+ default: r(() => [
759
+ o(Xa, {
760
+ form: e(h),
761
+ onCreateNewContactPerson: b
762
+ }, null, 8, ["form"])
763
+ ]),
764
+ _: 1
765
+ }),
766
+ o(e(X), null, {
767
+ right: r(() => [
768
+ o(e(W), {
769
+ "is-loading": e(h).isSubmitting.value,
770
+ label: e(i).t("wise_crm.shared.create")
771
+ }, null, 8, ["is-loading", "label"])
772
+ ]),
773
+ _: 1
774
+ })
775
+ ]),
776
+ _: 1
777
+ }, 8, ["form"]))
778
+ ]),
779
+ _: 1
780
+ }, 8, ["form"]));
781
+ }
782
+ });
783
+ function nt() {
784
+ const n = $();
785
+ return T({
786
+ queryFn: async ({
787
+ body: a,
788
+ params: t
789
+ }) => {
790
+ const l = await k.updateContactPerson(t.dealUuid, t.contactPersonUuid, a.form);
791
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
792
+ },
793
+ queryKeysToInvalidate: {
794
+ dealContactPersonDetail: {
795
+ contactPersonUuid: (a) => a.contactPersonUuid,
796
+ dealUuid: (a) => a.dealUuid
797
+ },
798
+ dealDetail: {
799
+ dealUuid: (a) => a.dealUuid
800
+ },
801
+ dealIndex: {}
802
+ }
803
+ });
804
+ }
805
+ function lt(n, a) {
806
+ return De("dealContactPersonDetail", {
807
+ params: {
808
+ contactPersonUuid: a,
809
+ dealUuid: n
810
+ },
811
+ queryFn: () => k.getContactPerson(n.value, a.value)
812
+ });
813
+ }
814
+ const ot = N.object({
815
+ email: N.literal("").or(N.email()).nullable(),
816
+ firstName: N.string().min(1),
817
+ lastName: N.string().min(1),
818
+ mobilePhone: A.nullable(),
819
+ phone: A.nullable()
820
+ }).superRefine((n, a) => {
821
+ n.email !== null && n.email !== "" || n.mobilePhone !== null && n.mobilePhone !== "" || n.phone !== null && n.phone !== "" || a.addIssue({
822
+ code: N.ZodIssueCode.custom,
823
+ message: be.global.t("wise_crm.form.errors.at_least_one")
824
+ });
825
+ }), it = /* @__PURE__ */ x({
826
+ __name: "DealContactPersonUpdateDialog",
827
+ props: {
828
+ contactPersonUuid: {},
829
+ dealUuid: {}
830
+ },
831
+ emits: ["close"],
832
+ setup(n, { emit: a }) {
833
+ const t = n, l = a, i = I(), s = L(), c = nt(), m = lt(
834
+ w(() => t.dealUuid),
835
+ w(() => t.contactPersonUuid)
836
+ ), f = w(() => m.result.value.isOk() ? m.result.value.getValue() : null), u = Y({
837
+ initialState: w(() => f.value === null ? null : {
838
+ email: f.value.email,
839
+ firstName: f.value.firstName,
840
+ lastName: f.value.lastName,
841
+ mobilePhone: f.value.mobilePhone,
842
+ phone: f.value.phone
843
+ }),
844
+ schema: ot,
845
+ onSubmit: async (P) => {
846
+ await C(P);
847
+ }
848
+ }), y = u.register("firstName"), h = u.register("lastName"), _ = u.register("email"), b = u.register("mobilePhone"), v = u.register("phone");
849
+ async function C(P) {
850
+ try {
851
+ await c.execute({
852
+ body: {
853
+ form: P
854
+ },
855
+ params: {
856
+ contactPersonUuid: t.contactPersonUuid,
857
+ dealUuid: t.dealUuid
858
+ }
859
+ }), l("close");
860
+ } catch (M) {
861
+ s.show(M);
862
+ }
863
+ }
864
+ function p() {
865
+ l("close");
866
+ }
867
+ return (P, M) => (d(), g(e(Ce), {
868
+ form: e(u),
869
+ size: "md",
870
+ onClose: p
871
+ }, {
872
+ default: r(() => [
873
+ o(e(we), {
874
+ title: e(i).t("wise_crm.info_dialog.contact_person_update.title"),
875
+ description: e(i).t("wise_crm.info_dialog.contact_person_create.description")
876
+ }, null, 8, ["title", "description"]),
877
+ f.value !== null ? (d(), g(e(J), { key: 0 }, {
878
+ default: r(() => [
879
+ o(e(le), null, {
880
+ default: r(() => [
881
+ o(e(B), null, {
882
+ default: r(() => [
883
+ o(e(K), {
884
+ sm: 1,
885
+ lg: 2
886
+ }, {
887
+ default: r(() => [
888
+ o(xe, {
889
+ "first-name": e(y),
890
+ "last-name": e(h)
891
+ }, null, 8, ["first-name", "last-name"])
892
+ ]),
893
+ _: 1
894
+ })
895
+ ]),
896
+ _: 1
897
+ }),
898
+ o(Xe, {
899
+ title: e(i).t("wise_crm.shared.contact_info")
900
+ }, {
901
+ default: r(() => [
902
+ o(e(K), {
903
+ sm: 1,
904
+ lg: 1,
905
+ variant: "card"
906
+ }, {
907
+ default: r(() => [
908
+ o(oe, {
909
+ email: e(_),
910
+ "mobile-phone": e(b),
911
+ phone: e(v)
912
+ }, null, 8, ["email", "mobile-phone", "phone"])
913
+ ]),
914
+ _: 1
915
+ }),
916
+ o(ye, { form: e(u) }, null, 8, ["form"])
917
+ ]),
918
+ _: 1
919
+ }, 8, ["title"])
920
+ ]),
921
+ _: 1
922
+ })
923
+ ]),
924
+ _: 1
925
+ })) : F("", !0),
926
+ o(e(X), null, {
927
+ right: r(() => [
928
+ o(e(W), {
929
+ "is-loading": e(u).isSubmitting.value,
930
+ label: e(i).t("wise_crm.shared.save_changes")
931
+ }, null, 8, ["is-loading", "label"])
932
+ ]),
933
+ _: 1
934
+ })
935
+ ]),
936
+ _: 1
937
+ }, 8, ["form"]));
938
+ }
939
+ });
940
+ function rt(n) {
941
+ return Sa("userIndex", {
942
+ params: n,
943
+ queryFn: (a) => We.getAll({
944
+ pagination: a,
945
+ search: n.params.search?.value
946
+ })
947
+ });
948
+ }
949
+ const st = { class: "p-lg" }, ut = /* @__PURE__ */ x({
950
+ __name: "DealDetailSidebarGeneralInfo",
951
+ props: {
952
+ deal: {}
953
+ },
954
+ setup(n) {
955
+ const a = n, t = I(), l = L(), i = qa(), s = Ea(), c = La(), m = ea({
956
+ persistInUrl: !1
957
+ }), f = rt({
958
+ params: {
959
+ search: m.debouncedSearch
960
+ }
961
+ }), u = V(a.deal.dealLanguage), y = V(a.deal.dealSource), h = V(
962
+ a.deal.owner ? {
963
+ uuid: a.deal.owner.uuid,
964
+ name: a.deal.owner.name
965
+ } : null
966
+ ), _ = w(() => {
967
+ const U = (f.result.value.isOk() ? f.result.value.getValue().data : []).map((D) => ({
968
+ uuid: D.uuid,
969
+ name: `${D.firstName} ${D.lastName}`
970
+ }));
971
+ return xa(U);
972
+ });
973
+ function b(U) {
974
+ return t.t(la.getI18nKey(U));
975
+ }
976
+ function v(U) {
977
+ return t.t(oa.getI18nKey(U));
978
+ }
979
+ const C = ee(Object.values(Ve)), p = ee(Object.values(qe)), P = aa();
980
+ function M(U) {
981
+ m.updateSearch(U);
982
+ }
983
+ async function j(U) {
984
+ if (u.value = U, U !== null)
985
+ try {
986
+ await i.execute({
987
+ body: {
988
+ dealLanguage: U
989
+ },
990
+ params: {
991
+ dealUuid: a.deal.uuid
992
+ }
993
+ });
994
+ } catch (D) {
995
+ l.show(D);
996
+ }
997
+ }
998
+ async function Ie(U) {
999
+ if (y.value = U, U !== null)
1000
+ try {
1001
+ await s.execute({
1002
+ body: {
1003
+ dealSource: U
1004
+ },
1005
+ params: {
1006
+ dealUuid: a.deal.uuid
1007
+ }
1008
+ });
1009
+ } catch (D) {
1010
+ l.show(D);
1011
+ }
1012
+ }
1013
+ async function Ne(U) {
1014
+ if (h.value = U, U !== null)
1015
+ try {
1016
+ await c.execute({
1017
+ body: {
1018
+ dealOwner: U
1019
+ },
1020
+ params: {
1021
+ dealUuid: a.deal.uuid
1022
+ }
1023
+ });
1024
+ } catch (D) {
1025
+ l.show(D);
1026
+ }
1027
+ }
1028
+ return (U, D) => (d(), q("div", null, [
1029
+ o(ge, null, {
1030
+ default: r(() => [
1031
+ S("form", null, [
1032
+ o(ta, { cols: 1 }, {
1033
+ default: r(() => [
1034
+ o(e(Ia), {
1035
+ modelValue: h.value,
1036
+ "onUpdate:modelValue": [
1037
+ D[0] || (D[0] = (E) => h.value = E),
1038
+ Ne
1039
+ ],
1040
+ items: _.value,
1041
+ "display-fn": (E) => E.name,
1042
+ "is-loading": e(f).isLoading.value || e(c).isLoading.value,
1043
+ "search-mode": "remote",
1044
+ placeholder: "Select deal owner",
1045
+ label: "Deal owner",
1046
+ "onUpdate:search": M
1047
+ }, null, 8, ["modelValue", "items", "display-fn", "is-loading"]),
1048
+ o(e(ae), {
1049
+ modelValue: u.value,
1050
+ "onUpdate:modelValue": [
1051
+ D[1] || (D[1] = (E) => u.value = E),
1052
+ j
1053
+ ],
1054
+ label: e(t).t("wise_crm.deal.form.fields.language"),
1055
+ placeholder: e(t).t("wise_crm.deal.form.fields.language_placeholder"),
1056
+ "display-fn": b,
1057
+ "is-loading": e(i).isLoading.value,
1058
+ items: e(C)
1059
+ }, null, 8, ["modelValue", "label", "placeholder", "is-loading", "items"]),
1060
+ o(e(ae), {
1061
+ modelValue: y.value,
1062
+ "onUpdate:modelValue": [
1063
+ D[2] || (D[2] = (E) => y.value = E),
1064
+ Ie
1065
+ ],
1066
+ "display-fn": v,
1067
+ label: e(t).t("wise_crm.deal.form.fields.source"),
1068
+ placeholder: e(t).t("wise_crm.deal.form.fields.source_placeholder"),
1069
+ "is-loading": e(s).isLoading.value,
1070
+ items: e(p)
1071
+ }, null, 8, ["modelValue", "label", "placeholder", "is-loading", "items"])
1072
+ ]),
1073
+ _: 1
1074
+ })
1075
+ ])
1076
+ ]),
1077
+ _: 1
1078
+ }),
1079
+ S("div", st, [
1080
+ o(R, {
1081
+ label: e(t).t("wise_crm.deal.sidebar.created_at", {
1082
+ date: e(P).toDate(a.deal.createdAt.toPlainDate())
1083
+ }),
1084
+ icon: e(na),
1085
+ "text-color": "text-quaternary",
1086
+ class: "text-sm"
1087
+ }, null, 8, ["label", "icon"])
1088
+ ])
1089
+ ]));
1090
+ }
1091
+ }), ct = /* @__PURE__ */ x({
1092
+ __name: "DealDetailSidebarOverviewContent",
1093
+ props: {
1094
+ deal: {}
1095
+ },
1096
+ setup(n) {
1097
+ const a = n, t = I(), l = L(), i = Ka(), s = ja(), c = H(), m = c.create(tt), f = c.create(it), u = w(() => a.deal.contactPersons.length > 0);
1098
+ function y() {
1099
+ m.open({
1100
+ dealUuid: a.deal.uuid
1101
+ });
1102
+ }
1103
+ function h(v) {
1104
+ f.open({
1105
+ contactPersonUuid: v,
1106
+ dealUuid: a.deal.uuid
1107
+ });
1108
+ }
1109
+ async function _(v) {
1110
+ try {
1111
+ await s.execute({
1112
+ body: {
1113
+ contactPersonUuid: v
1114
+ },
1115
+ params: {
1116
+ dealUuid: a.deal.uuid
1117
+ }
1118
+ });
1119
+ } catch (C) {
1120
+ l.show(C);
1121
+ }
1122
+ }
1123
+ function b(v) {
1124
+ i.execute({
1125
+ params: {
1126
+ contactPersonUuid: v,
1127
+ dealUuid: a.deal.uuid
1128
+ }
1129
+ });
1130
+ }
1131
+ return (v, C) => (d(), g(ia, { "default-values": ["general-info", "contact-persons"] }, {
1132
+ default: r(() => [
1133
+ o(se, {
1134
+ label: e(t).t("wise_crm.deal.detail.sidebar.accordion.general_info"),
1135
+ icon: e(he),
1136
+ value: "general-info"
1137
+ }, {
1138
+ default: r(() => [
1139
+ o(ut, {
1140
+ deal: a.deal
1141
+ }, null, 8, ["deal"])
1142
+ ]),
1143
+ _: 1
1144
+ }, 8, ["label", "icon"]),
1145
+ o(se, {
1146
+ "is-empty": !u.value,
1147
+ label: e(t).t("wise_crm.info_dialog.sidebar.overview.contact_persons_label"),
1148
+ icon: e(ra),
1149
+ value: "contact-persons",
1150
+ onAdd: y
1151
+ }, {
1152
+ actions: r(() => [
1153
+ u.value ? F("", !0) : (d(), g(sa, {
1154
+ key: 0,
1155
+ label: e(t).t("wise_crm.info_dialog.sidebar.overview.contact_persons_label"),
1156
+ icon: e(ue),
1157
+ class: "z-1",
1158
+ onClick: y
1159
+ }, null, 8, ["label", "icon"]))
1160
+ ]),
1161
+ default: r(() => [
1162
+ (d(!0), q(te, null, Fe(a.deal.contactPersons, (p) => (d(), g(e(Fa), {
1163
+ key: p.uuid,
1164
+ "layout-id": p.uuid
1165
+ }, {
1166
+ default: r(() => [
1167
+ o(Ha, {
1168
+ "contact-person": p,
1169
+ "on-toggle-is-primary": () => b(p.uuid),
1170
+ description: p.phone,
1171
+ onUpdate: (P) => h(p.uuid),
1172
+ onDelete: (P) => _(p.uuid)
1173
+ }, null, 8, ["contact-person", "on-toggle-is-primary", "description", "onUpdate", "onDelete"])
1174
+ ]),
1175
+ _: 2
1176
+ }, 1032, ["layout-id"]))), 128)),
1177
+ u.value ? (d(), g(e(Na), {
1178
+ key: 0,
1179
+ "icon-left": e(ue),
1180
+ label: e(t).t("wise_crm.shared.add"),
1181
+ variant: "tertiary",
1182
+ size: "sm",
1183
+ onClick: y
1184
+ }, null, 8, ["icon-left", "label"])) : F("", !0)
1185
+ ]),
1186
+ _: 1
1187
+ }, 8, ["is-empty", "label", "icon"])
1188
+ ]),
1189
+ _: 1
1190
+ }));
1191
+ }
1192
+ });
1193
+ function dt() {
1194
+ const n = $();
1195
+ return T({
1196
+ queryFn: async ({
1197
+ body: a,
1198
+ params: t
1199
+ }) => {
1200
+ const l = await k.transition(t.dealUuid, a.toBoardColumnUuid);
1201
+ return l.isOk() && n.notifyDealChanged(t.dealUuid), l;
1202
+ },
1203
+ queryKeysToInvalidate: {
1204
+ dealDetail: {
1205
+ dealUuid: (a) => a.dealUuid
1206
+ },
1207
+ dealIndex: {}
1208
+ }
1209
+ });
1210
+ }
1211
+ function mt(n, a) {
1212
+ return De("boardColumnsTransition", {
1213
+ params: {
1214
+ boardColumnUuid: n
1215
+ },
1216
+ queryFn: () => ua.getTransitions(n.value, a.value)
1217
+ });
1218
+ }
1219
+ const ft = /* @__PURE__ */ x({
1220
+ __name: "DealDetailSidebarTransitionSelect",
1221
+ props: /* @__PURE__ */ Te({
1222
+ deal: {}
1223
+ }, {
1224
+ modelValue: {
1225
+ required: !0
1226
+ },
1227
+ modelModifiers: {}
1228
+ }),
1229
+ emits: ["update:modelValue"],
1230
+ setup(n) {
1231
+ const a = n, t = I(), l = $(), s = H().create(ca), c = $e(n, "modelValue"), m = L(), f = dt(), u = mt(
1232
+ w(() => c.value.toColumnUuid),
1233
+ w(() => l.getOptions().deals?.allowedTransitionTriggerTypes ?? [])
1234
+ ), y = w(() => (u.result.value.isOk() ? u.result.value.getValue() : []).flatMap((C) => C.triggers.length === 0 ? [
1235
+ C
1236
+ ] : C.triggers.map((p) => ({
1237
+ ...C,
1238
+ toColumnDisplayName: C.toColumnDisplayName,
1239
+ triggers: [
1240
+ p
1241
+ ]
1242
+ }))));
1243
+ function h(v) {
1244
+ return v?.toColumnDisplayName ?? "-";
1245
+ }
1246
+ const _ = w(() => ee(y.value));
1247
+ async function b(v) {
1248
+ if (v.triggers.length !== 0) {
1249
+ if (v.triggers[0]?.triggerType === Ee.EMAIL) {
1250
+ s.open({
1251
+ dealUuid: a.deal.uuid,
1252
+ client: {
1253
+ uuid: a.deal.client.uuid,
1254
+ type: a.deal.client.type
1255
+ },
1256
+ templateKey: v.triggers[0].config.mailTemplateKey
1257
+ });
1258
+ return;
1259
+ }
1260
+ try {
1261
+ c.value = v, await f.execute({
1262
+ body: {
1263
+ toBoardColumnUuid: v.toColumnUuid
1264
+ },
1265
+ params: {
1266
+ dealUuid: a.deal.uuid
1267
+ }
1268
+ });
1269
+ } catch (C) {
1270
+ m.show(C);
1271
+ }
1272
+ }
1273
+ }
1274
+ return (v, C) => (d(), g(da, {
1275
+ color: c.value?.toColumnColor ?? null
1276
+ }, {
1277
+ default: r(() => [
1278
+ y.value.length === 0 ? (d(), g(e(Pe), {
1279
+ key: 0,
1280
+ "class-config": {
1281
+ root: "text-nowrap"
1282
+ },
1283
+ label: c.value.toColumnDisplayName,
1284
+ variant: "translucent",
1285
+ color: "brand"
1286
+ }, null, 8, ["label"])) : (d(), g(e(ae), {
1287
+ key: 1,
1288
+ "model-value": c.value,
1289
+ "is-loading": e(f).isLoading.value,
1290
+ "display-fn": h,
1291
+ items: _.value,
1292
+ "is-label-hidden": !0,
1293
+ placeholder: e(t).t("wise_crm.deal.transition.placeholder"),
1294
+ label: e(t).t("wise_crm.deal.transition.label"),
1295
+ class: "w-fit shrink-0 text-nowrap",
1296
+ size: "sm",
1297
+ "onUpdate:modelValue": b
1298
+ }, null, 8, ["model-value", "is-loading", "items", "placeholder", "label"]))
1299
+ ]),
1300
+ _: 1
1301
+ }, 8, ["color"]));
1302
+ }
1303
+ });
1304
+ function pt() {
1305
+ return T({
1306
+ queryFn: async ({
1307
+ body: n,
1308
+ params: a
1309
+ }) => await ve.create(n, {
1310
+ dealUuid: a.dealUuid
1311
+ }),
1312
+ queryKeysToInvalidate: {
1313
+ noteDealIndex: {}
1314
+ }
1315
+ });
1316
+ }
1317
+ function _t(n, a) {
1318
+ return ka("noteDealIndex", {
1319
+ params: {
1320
+ params: a?.params
1321
+ },
1322
+ queryFn: (t) => ve.getDealNotes({
1323
+ pagination: t
1324
+ }, n.value)
1325
+ });
1326
+ }
1327
+ const gt = /* @__PURE__ */ x({
1328
+ __name: "DealDialogSidebarNotesContent",
1329
+ props: {
1330
+ deal: {}
1331
+ },
1332
+ setup(n) {
1333
+ const a = n, l = H().create(ma), i = L(), s = pt(), c = fa(), m = _t(
1334
+ w(() => a.deal.uuid)
1335
+ ), f = w(() => m.result.value.isOk() ? m.result.value.getValue().data : []);
1336
+ async function u(_) {
1337
+ await s.execute({
1338
+ body: _,
1339
+ params: {
1340
+ dealUuid: a.deal.uuid
1341
+ }
1342
+ });
1343
+ }
1344
+ async function y(_) {
1345
+ try {
1346
+ await c.execute({
1347
+ params: {
1348
+ noteUuid: _
1349
+ }
1350
+ });
1351
+ } catch (b) {
1352
+ i.show(b);
1353
+ }
1354
+ }
1355
+ function h(_) {
1356
+ l.open({
1357
+ note: _
1358
+ });
1359
+ }
1360
+ return (_, b) => (d(), g(pa, {
1361
+ "is-loading": e(m).isLoading.value,
1362
+ notes: f.value,
1363
+ "on-submit": u,
1364
+ "has-next-page": e(m).hasNextPage.value,
1365
+ onNext: b[0] || (b[0] = (v) => e(m).fetchNextPage()),
1366
+ onDelete: y,
1367
+ onUpdate: h
1368
+ }, null, 8, ["is-loading", "notes", "has-next-page"]));
1369
+ }
1370
+ }), yt = { class: "flex h-full flex-1 flex-col" }, bt = { class: "flex flex-col gap-xl rounded-2xl border border-primary p-xl" }, ht = { class: "flex items-start gap-xs" }, vt = { class: "flex w-full flex-wrap items-center justify-between gap-sm" }, Ut = /* @__PURE__ */ x({
1371
+ __name: "DealDetailSidebar",
1372
+ props: {
1373
+ deal: {}
1374
+ },
1375
+ setup(n) {
1376
+ const a = n, t = I(), l = pe(), i = V(
1377
+ "overview"
1378
+ /* OVERVIEW */
1379
+ ), s = V({
1380
+ // There is no uuid available for the initial value, so a placeholder is used
1381
+ uuid: "",
1382
+ toColumnUuid: a.deal.boardColumn.uuid,
1383
+ toColumnColor: a.deal.boardColumn.color,
1384
+ toColumnDisplayName: a.deal.boardColumn.displayName,
1385
+ toColumnKey: "",
1386
+ triggers: []
1387
+ }), c = w(() => [
1388
+ {
1389
+ icon: he,
1390
+ label: t.t("wise_crm.shared.overview"),
1391
+ value: "overview"
1392
+ /* OVERVIEW */
1393
+ },
1394
+ {
1395
+ icon: _a,
1396
+ label: t.t("wise_crm.shared.notes"),
1397
+ value: "notes"
1398
+ /* NOTES */
1399
+ }
1400
+ ]);
1401
+ return (m, f) => (d(), q("div", yt, [
1402
+ S("div", bt, [
1403
+ S("div", ht, [
1404
+ o(Ba, {
1405
+ deal: a.deal,
1406
+ class: "min-w-0 flex-1"
1407
+ }, null, 8, ["deal"]),
1408
+ o(Va, {
1409
+ deal: a.deal
1410
+ }, null, 8, ["deal"])
1411
+ ]),
1412
+ S("div", vt, [
1413
+ o(ga, {
1414
+ class: "max-w-full min-w-0",
1415
+ onClick: f[0] || (f[0] = (u) => e(l).openBusinessDetail(
1416
+ a.deal.client.uuid
1417
+ ))
1418
+ }, {
1419
+ default: r(() => [
1420
+ o(e(Pe), {
1421
+ icon: e(ya),
1422
+ label: a.deal.client.name,
1423
+ variant: "translucent",
1424
+ color: "brand",
1425
+ class: "max-w-full"
1426
+ }, null, 8, ["icon", "label"])
1427
+ ]),
1428
+ _: 1
1429
+ }),
1430
+ o(ft, {
1431
+ modelValue: s.value,
1432
+ "onUpdate:modelValue": f[1] || (f[1] = (u) => s.value = u),
1433
+ deal: a.deal
1434
+ }, null, 8, ["modelValue", "deal"])
1435
+ ])
1436
+ ]),
1437
+ o(ba, {
1438
+ modelValue: i.value,
1439
+ "onUpdate:modelValue": f[2] || (f[2] = (u) => i.value = u),
1440
+ tabs: c.value
1441
+ }, {
1442
+ default: r(() => [
1443
+ i.value === "overview" ? (d(), g(ct, {
1444
+ key: 0,
1445
+ deal: a.deal
1446
+ }, null, 8, ["deal"])) : i.value === "notes" ? (d(), g(gt, {
1447
+ key: 1,
1448
+ deal: a.deal
1449
+ }, null, 8, ["deal"])) : F("", !0)
1450
+ ]),
1451
+ _: 1
1452
+ }, 8, ["modelValue", "tabs"])
1453
+ ]));
1454
+ }
1455
+ }), Ct = /* @__PURE__ */ x({
1456
+ __name: "DealDetailSidebarProvider",
1457
+ props: {
1458
+ dealUuid: {}
1459
+ },
1460
+ setup(n) {
1461
+ const a = n, t = ha(
1462
+ w(() => a.dealUuid)
1463
+ ), l = I();
1464
+ return (i, s) => (d(), g(va, null, {
1465
+ default: r(() => [
1466
+ e(t).isError.value ? (d(), g(Ua, {
1467
+ key: 0,
1468
+ message: e(l).t("error.deal_details.description"),
1469
+ title: e(l).t("error.deal_details.title")
1470
+ }, null, 8, ["message", "title"])) : e(t).isLoading.value ? (d(), g(Ca, {
1471
+ key: 1,
1472
+ class: "h-full"
1473
+ })) : e(t).result.value.isOk() ? (d(), g(Ut, {
1474
+ key: e(t).result.value.getValue().boardColumn.uuid,
1475
+ deal: e(t).result.value.getValue()
1476
+ }, null, 8, ["deal"])) : F("", !0)
1477
+ ]),
1478
+ _: 1
1479
+ }));
1480
+ }
1481
+ }), Vt = /* @__PURE__ */ x({
1482
+ __name: "DealDetailView",
1483
+ props: {
1484
+ tabs: {}
1485
+ },
1486
+ setup(n) {
1487
+ const a = n, t = I(), l = Me("dealUuid"), i = w(() => [
1488
+ ...a.tabs,
1489
+ {
1490
+ label: w(() => t.t("wise_crm.deal.detail_view.communication_tab_label")),
1491
+ to: "deal-communication"
1492
+ }
1493
+ ]);
1494
+ return (s, c) => (d(), g(Le, {
1495
+ key: e(l),
1496
+ "entity-type": e(fe).BUSINESS,
1497
+ tabs: i.value
1498
+ }, {
1499
+ sidebar: r(() => [
1500
+ o(Ct, { "deal-uuid": e(l) }, null, 8, ["deal-uuid"])
1501
+ ]),
1502
+ _: 1
1503
+ }, 8, ["entity-type", "tabs"]));
1504
+ }
1505
+ });
1506
+ export {
1507
+ Vt as default
1508
+ };