@wisemen/wise-crm-web 2.0.0-alpha.4 → 2.0.0-alpha.41

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