@wisemen/wise-crm-web 2.0.0-alpha.43 → 2.0.0-alpha.45

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,1136 @@
1
+ import { defineComponent as x, computed as f, openBlock as a, createBlock as m, unref as e, createElementBlock as k, renderSlot as se, withCtx as _, createVNode as u, mergeProps as pe, createTextVNode as _e, toDisplayString as O, createElementVNode as S, resolveDynamicComponent as V, ref as L, Fragment as T, createCommentVNode as D, normalizeClass as fe, renderList as K } from "vue";
2
+ import { useRouteParams as ve } from "@vueuse/router";
3
+ import { useI18n as N } from "vue-i18n";
4
+ import { B as I, u as q, _ as ye, a as ge, b as he, c as Ce, d as Ue, e as xe, f as we, l as Be, A as Pe, g as Se, h as ke, i as De, j as ne, S as W, k as Ne, m as $e, J as X, o as J, n as te, p as Ie, q as Ae, W as Fe, r as Ee, s as Me, V as Qe, Q as Ve, t as Te, v as ie, I as ae, w as qe, x as ze, y as Oe, z as Le, C as Ke, D as je, E as Re, F as Ge, G as He } from "./index-DSFHgVvi.js";
5
+ import { N as oe, _ as Je, u as We, a as Xe, b as Ye, c as Ze, d as ue, e as Q, C as re, f as F, g as es, h as ss, i as ns, j as ts, k as is } from "./CrmDetailView.vue_vue_type_script_setup_true_lang-7UUg6E4g.js";
6
+ import { z as H } from "zod";
7
+ import { bs as E } from "./uuid.util-DUuuAgdg.js";
8
+ import { _ as as, c as os, a as us, b as Y, d as rs, e as ls, f as cs, u as ds, g as ms, h as bs, i as ps } from "./CrmDetailSidebarMapCard.vue_vue_type_script_setup_true_lang-CCUsR4oc.js";
9
+ import { useKeysetInfiniteQuery as le, useMutation as z, useQuery as _s } from "@wisemen/vue-core-api-utils";
10
+ import { useOverlay as ce, UIButton as R, createAutocompleteOptions as fs, UIAutocomplete as vs, toFormField as ys, UIDialog as gs, UIFormDialog as de, UIDialogHeader as me, UIForm as Z, UIDialogFooter as hs, UIDialogFooterSubmit as Cs, UIIconButton as ee, UIPopover as Us, UIConfirmDialog as xs } from "@wisemen/vue-core-design-system";
11
+ import { Motion as ws } from "motion-v";
12
+ import { useQueryClient as Bs, useMutation as Ps } from "@tanstack/vue-query";
13
+ import { useForm as j } from "formango";
14
+ function Ss(n) {
15
+ return le("businessActivityIndex", {
16
+ queryFn: (s) => I.getActivity(n.value, s.key)
17
+ });
18
+ }
19
+ const ks = /* @__PURE__ */ x({
20
+ __name: "BusinessDetailSidebarActivityContent",
21
+ props: {
22
+ business: {}
23
+ },
24
+ setup(n) {
25
+ const s = n, t = f(() => s.business.uuid), i = Ss(t), o = f(() => i.result.value.isOk() ? i.result.value.getValue().data : []);
26
+ async function l() {
27
+ await i.fetchNextPage();
28
+ }
29
+ return (r, b) => (a(), m(as, {
30
+ "on-next": l,
31
+ "is-loading": e(i).isLoading.value,
32
+ activities: o.value
33
+ }, null, 8, ["is-loading", "activities"]));
34
+ }
35
+ });
36
+ function Ds() {
37
+ return z({
38
+ queryFn: async ({
39
+ body: n,
40
+ params: s
41
+ }) => await oe.create(n, {
42
+ businessUuid: s.businessUuid
43
+ }),
44
+ queryKeysToInvalidate: {
45
+ noteBusinessIndex: {}
46
+ }
47
+ });
48
+ }
49
+ function Ns(n, s) {
50
+ return le("noteBusinessIndex", {
51
+ params: {
52
+ params: s?.params
53
+ },
54
+ queryFn: (t) => oe.getBusinessNotes({
55
+ pagination: t
56
+ }, n.value)
57
+ });
58
+ }
59
+ const $s = /* @__PURE__ */ x({
60
+ __name: "BusinessDetailSidebarNotesContent",
61
+ props: {
62
+ business: {}
63
+ },
64
+ setup(n) {
65
+ const s = n, i = ce().create(Je), o = q(), l = Ds(), r = We(), b = Ns(
66
+ f(() => s.business.uuid)
67
+ ), p = f(() => b.result.value.isOk() ? b.result.value.getValue().data : []);
68
+ async function y(d) {
69
+ await l.execute({
70
+ body: d,
71
+ params: {
72
+ businessUuid: s.business.uuid
73
+ }
74
+ });
75
+ }
76
+ async function v(d) {
77
+ try {
78
+ await r.execute({
79
+ params: {
80
+ noteUuid: d
81
+ }
82
+ });
83
+ } catch (C) {
84
+ o.show(C);
85
+ }
86
+ }
87
+ function h(d) {
88
+ i.open({
89
+ note: d
90
+ });
91
+ }
92
+ return (d, C) => (a(), m(Xe, {
93
+ "is-loading": e(b).isLoading.value,
94
+ notes: p.value,
95
+ "on-submit": y,
96
+ "has-next-page": e(b).hasNextPage.value,
97
+ onNext: C[0] || (C[0] = (w) => e(b).fetchNextPage()),
98
+ onDelete: v,
99
+ onUpdate: h
100
+ }, null, 8, ["is-loading", "notes", "has-next-page"]));
101
+ }
102
+ });
103
+ function Is() {
104
+ const n = Bs(), s = "wiseCrmBusinessDetail", t = Ps({
105
+ mutationFn: async (i) => {
106
+ const {
107
+ businessUuid: o,
108
+ contactPersonUuid: l
109
+ } = i, r = await I.setPrimaryContactPersonForBusiness(o, l);
110
+ if (r.isErr())
111
+ throw r.error;
112
+ },
113
+ onError: (i, o, l) => {
114
+ n.setQueryData(
115
+ [
116
+ s,
117
+ {
118
+ businessUuid: o.businessUuid
119
+ }
120
+ ],
121
+ l?.previousData
122
+ );
123
+ },
124
+ onMutate: async (i) => {
125
+ await n.cancelQueries({
126
+ queryKey: [
127
+ s,
128
+ {
129
+ businessUuid: i.businessUuid
130
+ }
131
+ ]
132
+ });
133
+ const o = n.getQueryData(
134
+ [
135
+ s,
136
+ {
137
+ businessUuid: i.businessUuid
138
+ }
139
+ ]
140
+ );
141
+ return o === void 0 ? {} : (n.setQueryData(
142
+ [
143
+ s,
144
+ {
145
+ businessUuid: i.businessUuid
146
+ }
147
+ ],
148
+ o.map((l) => ({
149
+ ...l,
150
+ contactPersons: l.contactPersons.map((r) => r.uuid === i.contactPersonUuid ? {
151
+ ...r,
152
+ isPrimary: !r.isPrimary
153
+ } : {
154
+ ...r,
155
+ isPrimary: !1
156
+ })
157
+ }))
158
+ ), {
159
+ previousData: o
160
+ });
161
+ },
162
+ onSettled: (i, o, l) => {
163
+ n.invalidateQueries({
164
+ queryKey: [
165
+ s,
166
+ {
167
+ businessUuid: l.businessUuid
168
+ }
169
+ ]
170
+ });
171
+ }
172
+ });
173
+ return {
174
+ isLoading: f(() => t.isPending.value),
175
+ data: f(() => t.data.value),
176
+ execute: async (i) => await t.mutateAsync(i.params)
177
+ };
178
+ }
179
+ function As() {
180
+ return z({
181
+ queryFn: async ({
182
+ body: n,
183
+ params: s
184
+ }) => await I.unlinkContactPerson(s.businessUuid, n.contactPersonUuid),
185
+ queryKeysToInvalidate: {
186
+ businessIndex: {},
187
+ wiseCrmBusinessDetail: {
188
+ businessUuid: (n) => n.businessUuid
189
+ }
190
+ }
191
+ });
192
+ }
193
+ function Fs() {
194
+ return z({
195
+ queryFn: async ({
196
+ params: n
197
+ }) => await I.addChildBusiness(n.parentUuid, n.childUuid),
198
+ queryKeysToInvalidate: {
199
+ businessIndex: {},
200
+ wiseCrmBusinessDetail: {
201
+ businessUuid: (n) => n.parentUuid
202
+ }
203
+ }
204
+ });
205
+ }
206
+ const Es = {}, Ms = { class: "flex w-full justify-end gap-md pt-xl" };
207
+ function Qs(n, s) {
208
+ return a(), k("div", Ms, [
209
+ se(n.$slots, "default")
210
+ ]);
211
+ }
212
+ const Vs = /* @__PURE__ */ ye(Es, [["render", Qs]]), Ts = /* @__PURE__ */ x({
213
+ __name: "AppSidebarFormSubmitButton",
214
+ props: {
215
+ isLoading: { type: Boolean },
216
+ label: {},
217
+ type: { default: "submit" }
218
+ },
219
+ emits: ["submit"],
220
+ setup(n, { emit: s }) {
221
+ const t = n, i = s;
222
+ function o() {
223
+ i("submit");
224
+ }
225
+ return (l, r) => (a(), m(e(R), {
226
+ "is-loading": t.isLoading,
227
+ label: t.label,
228
+ "icon-left": e(ge),
229
+ type: "submit",
230
+ size: "lg",
231
+ onClick: o
232
+ }, null, 8, ["is-loading", "label", "icon-left"]));
233
+ }
234
+ }), qs = /* @__PURE__ */ x({
235
+ __name: "BusinessAddExistingChildForm",
236
+ props: {
237
+ parentBusinessUuid: {},
238
+ onSubmit: { type: Function }
239
+ },
240
+ emits: ["createNew"],
241
+ setup(n, { emit: s }) {
242
+ const t = n, i = s, o = N(), l = he({
243
+ persistInUrl: !1
244
+ }), r = Ce({
245
+ params: {
246
+ search: l.debouncedSearch
247
+ }
248
+ }), b = j({
249
+ initialState: {
250
+ business: null
251
+ },
252
+ schema: H.object({
253
+ business: H.object({
254
+ uuid: Ue,
255
+ name: H.string()
256
+ })
257
+ }),
258
+ onSubmit: async (d) => {
259
+ await t.onSubmit(d.business.uuid);
260
+ }
261
+ }), p = b.register("business"), y = f(() => {
262
+ const w = (r.result.value.isOk() ? r.result.value.getValue().data : []).filter((c) => c.uuid !== t.parentBusinessUuid).map((c) => ({
263
+ uuid: c.uuid,
264
+ name: c.name
265
+ }));
266
+ return fs(w);
267
+ });
268
+ function v(d) {
269
+ l.updateSearch(d);
270
+ }
271
+ function h() {
272
+ i("createNew");
273
+ }
274
+ return (d, C) => (a(), m(xe, { form: e(b) }, {
275
+ default: _(() => [
276
+ u(we, { cols: 1 }, {
277
+ default: _(() => [
278
+ u(e(vs), pe(e(ys)(e(p)), {
279
+ items: y.value,
280
+ "display-fn": (w) => w.name,
281
+ "is-loading": e(r).isFetching.value,
282
+ label: e(o).t("wise_crm.info_dialog.search_an_existing_one"),
283
+ "icon-left": e(Be),
284
+ "search-mode": "remote",
285
+ "onUpdate:search": v
286
+ }), null, 16, ["items", "display-fn", "is-loading", "label", "icon-left"]),
287
+ u(Pe, null, {
288
+ default: _(() => [
289
+ _e(O(e(o).t("wise_crm.shared.or")), 1)
290
+ ]),
291
+ _: 1
292
+ }),
293
+ u(e(R), {
294
+ label: e(o).t("wise_crm.info_dialog.add_business_child_dialog.create_a_new_one"),
295
+ class: "w-full",
296
+ size: "lg",
297
+ variant: "secondary",
298
+ onClick: h
299
+ }, null, 8, ["label"]),
300
+ u(Vs, null, {
301
+ default: _(() => [
302
+ u(Ts, {
303
+ "is-loading": e(b).isSubmitting.value,
304
+ label: e(o).t("wise_crm.shared.add")
305
+ }, null, 8, ["is-loading", "label"])
306
+ ]),
307
+ _: 1
308
+ })
309
+ ]),
310
+ _: 1
311
+ })
312
+ ]),
313
+ _: 1
314
+ }, 8, ["form"]));
315
+ }
316
+ }), zs = { class: "grid grid-cols-[auto_2rem]" }, Os = { class: "flex items-center gap-xl" }, Ls = { class: "flex size-10 shrink-0 items-center justify-center rounded-full bg-brand-200" }, Ks = { class: "text-md font-semibold text-primary" }, js = { class: "text-sm text-tertiary" }, Rs = /* @__PURE__ */ x({
317
+ __name: "AppDialogHeader",
318
+ props: {
319
+ title: {},
320
+ description: {},
321
+ icon: {}
322
+ },
323
+ setup(n) {
324
+ const s = n;
325
+ return (t, i) => (a(), k("header", zs, [
326
+ S("div", Os, [
327
+ S("div", Ls, [
328
+ (a(), m(V(s.icon), { class: "size-5 shrink-0 text-brand-600" }))
329
+ ]),
330
+ S("div", null, [
331
+ S("h1", Ks, O(s.title), 1),
332
+ S("p", js, O(s.description), 1)
333
+ ])
334
+ ]),
335
+ se(t.$slots, "closse-button")
336
+ ]));
337
+ }
338
+ }), Gs = /* @__PURE__ */ x({
339
+ __name: "BusinessAddChildBusinessDialog",
340
+ props: {
341
+ businessUuid: {}
342
+ },
343
+ emits: ["close"],
344
+ setup(n, { emit: s }) {
345
+ const t = n, i = s, o = N(), l = q(), r = L(!1), b = L(null), p = Fs();
346
+ function y() {
347
+ i("close");
348
+ }
349
+ const {
350
+ isCheckingExistence: v,
351
+ isCheckingVatNumber: h,
352
+ isDataFromCbe: d,
353
+ checkVatNumberValidity: C,
354
+ form: w,
355
+ onCreateNewBusiness: c,
356
+ onUpdateCbeSearchItem: g
357
+ } = Se({
358
+ onClose: y,
359
+ onCreate: async (A) => {
360
+ try {
361
+ await p.execute({
362
+ params: {
363
+ childUuid: A,
364
+ parentUuid: t.businessUuid
365
+ }
366
+ });
367
+ } catch (U) {
368
+ l.show(U);
369
+ }
370
+ }
371
+ });
372
+ async function P(A) {
373
+ try {
374
+ await p.execute({
375
+ params: {
376
+ childUuid: A,
377
+ parentUuid: t.businessUuid
378
+ }
379
+ }), i("close");
380
+ } catch (U) {
381
+ l.show(U);
382
+ }
383
+ }
384
+ function M() {
385
+ r.value = !1;
386
+ }
387
+ function G() {
388
+ c(), r.value = !0;
389
+ }
390
+ return (A, U) => (a(), m(e(gs), { onClose: y }, {
391
+ default: _(() => [
392
+ r.value ? (a(), m(ke, {
393
+ key: 0,
394
+ "check-vat-number-validity": e(C),
395
+ form: e(w),
396
+ "is-checking-existence": e(v),
397
+ "is-checking-vat-number": e(h),
398
+ "is-data-from-cbe": e(d),
399
+ "on-update-cbe-search-item": e(g),
400
+ onBack: M
401
+ }, null, 8, ["check-vat-number-validity", "form", "is-checking-existence", "is-checking-vat-number", "is-data-from-cbe", "on-update-cbe-search-item"])) : (a(), m(De, {
402
+ key: 1,
403
+ class: "flex flex-1 flex-col gap-xl"
404
+ }, {
405
+ default: _(() => [
406
+ u(Rs, {
407
+ title: e(o).t("wise_crm.info_dialog.add_business_child_dialog.title"),
408
+ description: e(o).t("wise_crm.info_dialog.add_business_child_dialog.description"),
409
+ icon: e(ne)
410
+ }, null, 8, ["title", "description", "icon"]),
411
+ u(qs, {
412
+ modelValue: b.value,
413
+ "onUpdate:modelValue": U[0] || (U[0] = ($) => b.value = $),
414
+ "parent-business-uuid": t.businessUuid,
415
+ "on-submit": P,
416
+ onCreateNew: G
417
+ }, null, 8, ["modelValue", "parent-business-uuid"])
418
+ ]),
419
+ _: 1
420
+ }))
421
+ ]),
422
+ _: 1
423
+ }));
424
+ }
425
+ });
426
+ function Hs() {
427
+ return z({
428
+ queryFn: async ({
429
+ body: n,
430
+ params: s
431
+ }) => await I.linkContactPerson(
432
+ s.businessUuid,
433
+ n.contactPersonUuid,
434
+ n.position,
435
+ n.contactInfo
436
+ ),
437
+ queryKeysToInvalidate: {
438
+ businessIndex: {},
439
+ wiseCrmBusinessDetail: {
440
+ businessUuid: (n) => n.businessUuid
441
+ }
442
+ }
443
+ });
444
+ }
445
+ const Js = /* @__PURE__ */ x({
446
+ __name: "BusinessContactPersonCreateDialog",
447
+ props: {
448
+ businessUuid: {},
449
+ isCreatingNewContactPerson: { type: Boolean, default: !1 }
450
+ },
451
+ emits: ["close", "createNewContactPerson"],
452
+ setup(n, { emit: s }) {
453
+ const t = n, i = s, o = N(), l = q(), r = Hs(), b = Ye(), p = L(t.isCreatingNewContactPerson), y = j({
454
+ schema: os,
455
+ onSubmit: async (c) => {
456
+ await d(c);
457
+ }
458
+ }), v = j({
459
+ initialState: {
460
+ email: null,
461
+ existingContactPerson: null,
462
+ mobile: null,
463
+ phone: null,
464
+ position: null
465
+ },
466
+ schema: us,
467
+ onSubmit: async (c) => {
468
+ await C(
469
+ c.existingContactPerson,
470
+ {
471
+ email: c.email,
472
+ mobilePhone: c.mobile,
473
+ phone: c.phone
474
+ },
475
+ c.position
476
+ );
477
+ }
478
+ }), h = f(() => p.value ? y : v);
479
+ async function d(c) {
480
+ try {
481
+ const g = await b.execute({
482
+ body: {
483
+ email: c.email,
484
+ firstName: c.firstName,
485
+ lastName: c.lastName,
486
+ mobilePhone: c.mobilePhone,
487
+ phone: c.phone
488
+ }
489
+ });
490
+ if (g.isErr()) {
491
+ l.show(g.error);
492
+ return;
493
+ }
494
+ const P = g.value;
495
+ t.isCreatingNewContactPerson || await r.execute({
496
+ body: {
497
+ contactPersonUuid: P,
498
+ contactInfo: {
499
+ email: c.email,
500
+ mobilePhone: c.mobilePhone,
501
+ phone: c.phone
502
+ },
503
+ position: W.trimOrNull(c.position)
504
+ },
505
+ params: {
506
+ businessUuid: t.businessUuid
507
+ }
508
+ }), w({
509
+ label: `${c.firstName} ${c.lastName}`,
510
+ value: P
511
+ });
512
+ } catch (g) {
513
+ l.show(g);
514
+ }
515
+ }
516
+ async function C(c, g, P) {
517
+ if (c !== null)
518
+ try {
519
+ await r.execute({
520
+ body: {
521
+ contactPersonUuid: c,
522
+ contactInfo: g,
523
+ position: W.trimOrNull(P)
524
+ },
525
+ params: {
526
+ businessUuid: t.businessUuid
527
+ }
528
+ }), w();
529
+ } catch (M) {
530
+ l.show(M);
531
+ }
532
+ }
533
+ function w(c) {
534
+ if (c === void 0) {
535
+ i("close");
536
+ return;
537
+ }
538
+ i("createNewContactPerson", c), i("close");
539
+ }
540
+ return (c, g) => (a(), m(e(de), {
541
+ form: h.value,
542
+ size: "md",
543
+ "render-own-form-component": "",
544
+ onClose: w
545
+ }, {
546
+ default: _(() => [
547
+ u(e(me), {
548
+ title: e(o).t("wise_crm.info_dialog.contact_person_create.title"),
549
+ description: e(o).t("wise_crm.info_dialog.contact_person_create.description")
550
+ }, null, 8, ["title", "description"]),
551
+ p.value ? (a(), m(e(Z), {
552
+ key: 0,
553
+ form: e(y),
554
+ "prompt-on-unsaved-changes": !1
555
+ }, {
556
+ default: _(() => [
557
+ u(Y, {
558
+ "is-new-mode": p.value,
559
+ "onUpdate:isNewMode": g[0] || (g[0] = (P) => p.value = P),
560
+ "create-form": e(y),
561
+ "existing-form": e(v)
562
+ }, null, 8, ["is-new-mode", "create-form", "existing-form"])
563
+ ]),
564
+ _: 1
565
+ }, 8, ["form"])) : (a(), m(e(Z), {
566
+ key: 1,
567
+ form: e(v),
568
+ "prompt-on-unsaved-changes": !1
569
+ }, {
570
+ default: _(() => [
571
+ u(Y, {
572
+ "is-new-mode": p.value,
573
+ "onUpdate:isNewMode": g[1] || (g[1] = (P) => p.value = P),
574
+ "create-form": e(y),
575
+ "existing-form": e(v)
576
+ }, null, 8, ["is-new-mode", "create-form", "existing-form"])
577
+ ]),
578
+ _: 1
579
+ }, 8, ["form"]))
580
+ ]),
581
+ _: 1
582
+ }, 8, ["form"]));
583
+ }
584
+ });
585
+ function Ws() {
586
+ return z({
587
+ queryFn: async ({
588
+ body: n,
589
+ params: s
590
+ }) => await I.updateContactPerson(s.businessUuid, s.contactPersonUuid, n),
591
+ queryKeysToInvalidate: {
592
+ businessIndex: {},
593
+ contactPersonDetail: {
594
+ contactPersonUuid: (n) => n.contactPersonUuid
595
+ },
596
+ wiseCrmBusinessDetail: {
597
+ businessUuid: (n) => n.businessUuid
598
+ }
599
+ }
600
+ });
601
+ }
602
+ function Xs(n, s) {
603
+ return _s("contactPersonDetail", {
604
+ isEnabled: f(() => n.value !== null && s.value !== null),
605
+ params: {
606
+ contactPersonUuid: s
607
+ },
608
+ queryFn: () => {
609
+ if (n.value === null)
610
+ throw new Error("Business UUID is null");
611
+ if (s.value === null)
612
+ throw new Error("Contact Person UUID is null");
613
+ return I.getContactPerson(n.value, s.value);
614
+ }
615
+ });
616
+ }
617
+ const Ys = /* @__PURE__ */ x({
618
+ __name: "BusinessContactPersonUpdateForm",
619
+ props: {
620
+ contactPerson: {},
621
+ form: {}
622
+ },
623
+ setup(n) {
624
+ const s = n, t = N();
625
+ return (i, o) => (a(), k(T, null, [
626
+ u(rs, {
627
+ form: s.form
628
+ }, null, 8, ["form"]),
629
+ u(e(hs), null, {
630
+ right: _(() => [
631
+ u(e(Cs), {
632
+ "is-loading": s.form.isSubmitting.value,
633
+ label: e(t).t("wise_crm.shared.save_changes")
634
+ }, null, 8, ["is-loading", "label"])
635
+ ]),
636
+ _: 1
637
+ })
638
+ ], 64));
639
+ }
640
+ }), Zs = /* @__PURE__ */ x({
641
+ __name: "BusinessContactPersonUpdateDialog",
642
+ props: {
643
+ businessUuid: {},
644
+ contactPersonUuid: {}
645
+ },
646
+ emits: ["close"],
647
+ setup(n, { emit: s }) {
648
+ const t = n, i = s, o = N(), l = q(), r = Ws(), b = Xs(
649
+ f(() => t.businessUuid),
650
+ f(() => t.contactPersonUuid)
651
+ ), p = f(() => b.result.value.isOk() ? b.result.value.getValue() : null), y = j({
652
+ initialState: f(() => p.value === null ? null : {
653
+ email: p.value.email,
654
+ firstName: p.value.firstName,
655
+ lastName: p.value.lastName,
656
+ mobilePhone: p.value.mobilePhone,
657
+ phone: p.value.phone,
658
+ position: p.value.position
659
+ }),
660
+ schema: ls,
661
+ onSubmit: async (d) => {
662
+ await v(d);
663
+ }
664
+ });
665
+ async function v(d) {
666
+ try {
667
+ await r.execute({
668
+ body: d,
669
+ params: {
670
+ businessUuid: t.businessUuid,
671
+ contactPersonUuid: t.contactPersonUuid
672
+ }
673
+ }), i("close");
674
+ } catch (C) {
675
+ l.show(C);
676
+ }
677
+ }
678
+ function h() {
679
+ i("close");
680
+ }
681
+ return (d, C) => (a(), m(e(de), {
682
+ form: e(y),
683
+ size: "md",
684
+ onClose: h
685
+ }, {
686
+ default: _(() => [
687
+ u(e(me), {
688
+ title: e(o).t("wise_crm.info_dialog.contact_person_update.title"),
689
+ description: e(o).t("wise_crm.info_dialog.contact_person_create.description")
690
+ }, null, 8, ["title", "description"]),
691
+ p.value !== null ? (a(), m(Ys, {
692
+ key: 0,
693
+ "contact-person": p.value,
694
+ form: e(y)
695
+ }, null, 8, ["contact-person", "form"])) : D("", !0)
696
+ ]),
697
+ _: 1
698
+ }, 8, ["form"]));
699
+ }
700
+ }), en = { class: "flex items-start gap-md" }, sn = { class: "flex-1" }, nn = {
701
+ key: 0,
702
+ class: "mt-xxs"
703
+ }, tn = { class: "flex flex-1 items-center justify-between text-secondary" }, an = { class: "flex items-center gap-sm" }, on = { class: "font-semibold" }, un = { class: "flex w-100 flex-col gap-md p-md" }, rn = /* @__PURE__ */ x({
704
+ __name: "BusinessDetailSidebarAccordionBusinessInfoChildren",
705
+ props: {
706
+ business: {}
707
+ },
708
+ emits: ["addChild"],
709
+ setup(n, { emit: s }) {
710
+ const t = n, i = s, o = N(), l = Ne(), r = f(() => t.business.children), b = f(() => r.value.length > 1 ? o.t("wise_crm.shared.departments_amount", {
711
+ value: r.value.length
712
+ }) : r.value[0]?.name ?? "");
713
+ function p() {
714
+ i("addChild");
715
+ }
716
+ function y(v) {
717
+ l.open(E.BUSINESS, v);
718
+ }
719
+ return (v, h) => (a(), k("div", en, [
720
+ (a(), m(V(e($e)), { class: "mt-xs size-4 shrink-0" })),
721
+ S("div", sn, [
722
+ t.business.parent !== null ? (a(), k("div", nn, [
723
+ u(Ze, {
724
+ label: t.business.parent.name,
725
+ "entity-type": e(E).BUSINESS,
726
+ uuid: t.business.parent.uuid
727
+ }, null, 8, ["label", "entity-type", "uuid"])
728
+ ])) : D("", !0),
729
+ S("div", tn, [
730
+ S("div", an, [
731
+ t.business.parent !== null ? (a(), m(V(e(X)), {
732
+ key: 0,
733
+ class: "size-4 text-brand-500"
734
+ })) : D("", !0),
735
+ S("p", on, O(t.business.name), 1)
736
+ ]),
737
+ u(e(ee), {
738
+ label: e(o).t("wise_crm.info_dialog.sidebar.business.add_icon"),
739
+ icon: e(J),
740
+ variant: "tertiary",
741
+ size: "sm",
742
+ onClick: p
743
+ }, null, 8, ["label", "icon"])
744
+ ]),
745
+ r.value.length > 0 ? (a(), k("div", {
746
+ key: 1,
747
+ class: fe([{
748
+ "ml-2xl": t.business.parent !== null
749
+ }, "flex items-center gap-sm"])
750
+ }, [
751
+ (a(), m(V(e(X)), { class: "size-4 text-brand-500" })),
752
+ u(e(Us), {
753
+ "popover-align": "start",
754
+ "popover-side": "right"
755
+ }, {
756
+ trigger: _(() => [
757
+ u(e(R), {
758
+ label: b.value,
759
+ class: "font-normal h-auto rounded-none border-none bg-transparent p-0 text-sm text-primary underline shadow-none",
760
+ variant: "secondary"
761
+ }, null, 8, ["label"])
762
+ ]),
763
+ content: _(() => [
764
+ S("div", un, [
765
+ u(ue, {
766
+ "default-values": r.value[0]?.uuid ?? "",
767
+ type: "single"
768
+ }, {
769
+ default: _(() => [
770
+ (a(!0), k(T, null, K(r.value, (d) => (a(), m(Q, {
771
+ key: d.uuid,
772
+ label: d.name,
773
+ value: d.uuid,
774
+ icon: e(ne)
775
+ }, {
776
+ actions: _(() => [
777
+ u(e(ee), {
778
+ label: e(o).t("wise_crm.info_dialog.sidebar.business.add_icon"),
779
+ icon: e(Me),
780
+ variant: "tertiary",
781
+ size: "sm",
782
+ onClick: (C) => y(d.uuid)
783
+ }, null, 8, ["label", "icon", "onClick"])
784
+ ]),
785
+ default: _(() => [
786
+ u(re, { class: "flex flex-col gap-md" }, {
787
+ default: _(() => [
788
+ u(F, {
789
+ label: d.vatNumber ?? "-",
790
+ icon: e(te)
791
+ }, null, 8, ["label", "icon"]),
792
+ u(F, {
793
+ label: d.email ?? "-",
794
+ icon: e(Ie)
795
+ }, null, 8, ["label", "icon"]),
796
+ u(F, {
797
+ label: d.mobilePhone ?? d.phone ?? "-",
798
+ icon: e(Ae)
799
+ }, null, 8, ["label", "icon"]),
800
+ u(F, {
801
+ label: d.address ? e(Ee).formatShort(d.address) : "-",
802
+ icon: e(Fe)
803
+ }, null, 8, ["label", "icon"])
804
+ ]),
805
+ _: 2
806
+ }, 1024)
807
+ ]),
808
+ _: 2
809
+ }, 1032, ["label", "value", "icon"]))), 128))
810
+ ]),
811
+ _: 1
812
+ }, 8, ["default-values"])
813
+ ])
814
+ ]),
815
+ _: 1
816
+ })
817
+ ], 2)) : D("", !0)
818
+ ])
819
+ ]));
820
+ }
821
+ }), ln = { class: "flex flex-col gap-md" }, cn = { class: "flex flex-col gap-sm border-b border-secondary pb-sm" }, dn = { class: "pt-lg" }, mn = /* @__PURE__ */ x({
822
+ __name: "BusinessDetailSidebarAccordionBusinessInfo",
823
+ props: {
824
+ business: {}
825
+ },
826
+ emits: ["addChild"],
827
+ setup(n, { emit: s }) {
828
+ const t = n, i = s, o = N();
829
+ function l() {
830
+ i("addChild");
831
+ }
832
+ return (r, b) => (a(), k("div", ln, [
833
+ u(re, null, {
834
+ default: _(() => [
835
+ S("div", cn, [
836
+ u(F, {
837
+ label: t.business.vatNumber ? e(Qe).format(t.business.vatNumber) : "-",
838
+ icon: e(te)
839
+ }, null, 8, ["label", "icon"]),
840
+ u(rn, {
841
+ business: n.business,
842
+ onAddChild: l
843
+ }, null, 8, ["business"])
844
+ ]),
845
+ S("div", dn, [
846
+ u(F, {
847
+ label: e(o).t("wise_crm.info_dialog.sidebar.overview.created_at_label", {
848
+ value: t.business.createdAt ? e(Te)().toDateTime(t.business.createdAt) : "-"
849
+ }),
850
+ icon: e(Ve)
851
+ }, null, 8, ["label", "icon"])
852
+ ])
853
+ ]),
854
+ _: 1
855
+ }),
856
+ u(cs, {
857
+ address: t.business.address
858
+ }, null, 8, ["address"])
859
+ ]));
860
+ }
861
+ }), bn = /* @__PURE__ */ x({
862
+ __name: "BusinessDetailSidebarOverviewContent",
863
+ props: {
864
+ business: {}
865
+ },
866
+ setup(n) {
867
+ const s = n, t = N(), i = q(), o = ie(), l = f(
868
+ () => o.getOptions().business?.sidebarSections ?? []
869
+ ), r = ds(
870
+ l,
871
+ f(() => ({
872
+ businessUuid: s.business.uuid
873
+ }))
874
+ ), b = ce(), p = b.create(xs), y = Is(), v = As(), h = b.create(Js), d = b.create(Zs), C = b.create(Gs), w = f(() => s.business.contactPersons.length > 0), c = f(() => s.business.contactPersons.toSorted((U, $) => Number($.isPrimary) - Number(U.isPrimary)));
875
+ function g() {
876
+ h.open({
877
+ businessUuid: s.business.uuid
878
+ });
879
+ }
880
+ function P(U) {
881
+ d.open({
882
+ businessUuid: s.business.uuid,
883
+ contactPersonUuid: U
884
+ });
885
+ }
886
+ function M(U) {
887
+ p.open({
888
+ title: t.t("wise_crm.info_dialog.sidebar.overview.delete_contact_person_title"),
889
+ isDestructive: !0,
890
+ confirmLabel: t.t("shared.delete"),
891
+ description: t.t("wise_crm.info_dialog.sidebar.overview.delete_contact_person_description"),
892
+ onConfirm: async () => {
893
+ const $ = await v.execute({
894
+ body: {
895
+ contactPersonUuid: U
896
+ },
897
+ params: {
898
+ businessUuid: s.business.uuid
899
+ }
900
+ });
901
+ p.close(), $.isErr() && i.show($.error);
902
+ }
903
+ });
904
+ }
905
+ function G(U) {
906
+ y.execute({
907
+ params: {
908
+ businessUuid: s.business.uuid,
909
+ contactPersonUuid: U
910
+ }
911
+ });
912
+ }
913
+ function A() {
914
+ C.open({
915
+ businessUuid: s.business.uuid
916
+ });
917
+ }
918
+ return (U, $) => (a(), m(ue, {
919
+ "default-values": ["business", "invoice", "contact-persons", ...l.value.map((B) => `custom-${B.key}`)]
920
+ }, {
921
+ default: _(() => [
922
+ u(Q, {
923
+ label: e(t).t("wise_crm.info_dialog.sidebar.overview.business_info"),
924
+ icon: e(ae),
925
+ value: "business"
926
+ }, {
927
+ default: _(() => [
928
+ u(mn, {
929
+ business: n.business,
930
+ onAddChild: A
931
+ }, null, 8, ["business"])
932
+ ]),
933
+ _: 1
934
+ }, 8, ["label", "icon"]),
935
+ u(Q, {
936
+ "is-empty": s.business.billingInformation === null,
937
+ label: e(t).t("wise_crm.info_dialog.sidebar.overview.invoice_label"),
938
+ icon: e(qe),
939
+ value: "invoice"
940
+ }, {
941
+ default: _(() => [
942
+ s.business.billingInformation ? (a(), m(ms, {
943
+ key: 0,
944
+ "invoice-address": s.business.billingInformation?.location?.address ?? null,
945
+ "invoice-email": s.business.billingInformation?.invoiceEmail
946
+ }, null, 8, ["invoice-address", "invoice-email"])) : D("", !0)
947
+ ]),
948
+ _: 1
949
+ }, 8, ["is-empty", "label", "icon"]),
950
+ u(Q, {
951
+ "is-empty": !w.value,
952
+ label: e(t).t("wise_crm.info_dialog.sidebar.overview.contact_persons_label"),
953
+ icon: e(ze),
954
+ value: "contact-persons",
955
+ onAdd: g
956
+ }, {
957
+ actions: _(() => [
958
+ w.value ? D("", !0) : (a(), m(es, {
959
+ key: 0,
960
+ label: e(t).t("wise_crm.info_dialog.sidebar.overview.contact_persons_label"),
961
+ icon: e(J),
962
+ class: "z-1",
963
+ onClick: g
964
+ }, null, 8, ["label", "icon"]))
965
+ ]),
966
+ default: _(() => [
967
+ (a(!0), k(T, null, K(c.value, (B) => (a(), m(e(ws), {
968
+ key: B.uuid,
969
+ "layout-id": B.uuid
970
+ }, {
971
+ default: _(() => [
972
+ u(bs, {
973
+ "contact-person": B,
974
+ "on-toggle-is-primary": () => G(B.uuid),
975
+ onUpdate: (be) => P(B.uuid),
976
+ onDelete: (be) => M(B.uuid)
977
+ }, null, 8, ["contact-person", "on-toggle-is-primary", "onUpdate", "onDelete"])
978
+ ]),
979
+ _: 2
980
+ }, 1032, ["layout-id"]))), 128)),
981
+ w.value ? (a(), m(e(R), {
982
+ key: 0,
983
+ "icon-left": e(J),
984
+ label: e(t).t("wise_crm.shared.add"),
985
+ variant: "tertiary",
986
+ size: "sm",
987
+ onClick: g
988
+ }, null, 8, ["icon-left", "label"])) : D("", !0)
989
+ ]),
990
+ _: 1
991
+ }, 8, ["is-empty", "label", "icon"]),
992
+ (a(!0), k(T, null, K(e(r), (B) => (a(), m(Q, {
993
+ key: B.key,
994
+ label: B.label.value,
995
+ icon: B.icon,
996
+ value: `custom-${B.key}`
997
+ }, {
998
+ default: _(() => [
999
+ (a(), m(V(B.component), {
1000
+ "business-uuid": s.business.uuid
1001
+ }, null, 8, ["business-uuid"]))
1002
+ ]),
1003
+ _: 2
1004
+ }, 1032, ["label", "icon", "value"]))), 128))
1005
+ ]),
1006
+ _: 1
1007
+ }, 8, ["default-values"]));
1008
+ }
1009
+ }), pn = /* @__PURE__ */ x({
1010
+ __name: "BusinessDetailSidebar",
1011
+ props: {
1012
+ business: {}
1013
+ },
1014
+ setup(n) {
1015
+ const s = n, t = N(), i = Oe(), o = ie(), l = f(() => i.getEntityConfig(E.BUSINESS)), r = f(
1016
+ () => o.getOptions().business?.headerBadges ?? []
1017
+ ), b = L(
1018
+ "overview"
1019
+ /* OVERVIEW */
1020
+ ), p = f(() => [
1021
+ {
1022
+ icon: ae,
1023
+ label: t.t("wise_crm.shared.overview"),
1024
+ value: "overview"
1025
+ /* OVERVIEW */
1026
+ },
1027
+ {
1028
+ icon: Le,
1029
+ label: t.t("wise_crm.shared.activity"),
1030
+ value: "activity"
1031
+ /* ACTIVITY */
1032
+ },
1033
+ {
1034
+ icon: Ke,
1035
+ label: t.t("wise_crm.shared.notes"),
1036
+ value: "notes"
1037
+ /* NOTES */
1038
+ }
1039
+ ]);
1040
+ return (y, v) => (a(), m(je, {
1041
+ color: e(i).getEntityConfig(e(E).BUSINESS)?.color ?? null,
1042
+ class: "flex h-full flex-col"
1043
+ }, {
1044
+ default: _(() => [
1045
+ u(ps, {
1046
+ "entity-type": e(E).BUSINESS,
1047
+ name: s.business.name,
1048
+ address: s.business.address,
1049
+ email: s.business.email,
1050
+ "mobile-phone": s.business.mobilePhone,
1051
+ "entity-name": l.value?.name ?? null,
1052
+ phone: s.business.phone
1053
+ }, {
1054
+ badges: _(() => [
1055
+ (a(!0), k(T, null, K(r.value, (h) => (a(), m(ss, {
1056
+ key: h.key,
1057
+ badge: h,
1058
+ uuid: s.business.uuid,
1059
+ entity: "business"
1060
+ }, null, 8, ["badge", "uuid"]))), 128))
1061
+ ]),
1062
+ _: 1
1063
+ }, 8, ["entity-type", "name", "address", "email", "mobile-phone", "entity-name", "phone"]),
1064
+ u(ns, {
1065
+ modelValue: b.value,
1066
+ "onUpdate:modelValue": v[0] || (v[0] = (h) => b.value = h),
1067
+ tabs: p.value
1068
+ }, {
1069
+ default: _(() => [
1070
+ b.value === "overview" ? (a(), m(bn, {
1071
+ key: 0,
1072
+ business: s.business
1073
+ }, null, 8, ["business"])) : D("", !0),
1074
+ b.value === "activity" ? (a(), m(ks, {
1075
+ key: 1,
1076
+ business: s.business
1077
+ }, null, 8, ["business"])) : D("", !0),
1078
+ b.value === "notes" ? (a(), m($s, {
1079
+ key: 2,
1080
+ business: s.business
1081
+ }, null, 8, ["business"])) : D("", !0)
1082
+ ]),
1083
+ _: 1
1084
+ }, 8, ["modelValue", "tabs"])
1085
+ ]),
1086
+ _: 1
1087
+ }, 8, ["color"]));
1088
+ }
1089
+ }), _n = /* @__PURE__ */ x({
1090
+ __name: "BusinessDetailSidebarProvider",
1091
+ props: {
1092
+ businessUuid: {}
1093
+ },
1094
+ setup(n) {
1095
+ const s = n, t = N(), i = Re(
1096
+ f(() => s.businessUuid)
1097
+ ), o = f(() => i.result.value.isOk() ? i.result.value.getValue() : null);
1098
+ return (l, r) => (a(), m(ts, null, {
1099
+ default: _(() => [
1100
+ e(i).isError.value ? (a(), m(Ge, {
1101
+ key: 0,
1102
+ message: e(t).t("error.business_details.description"),
1103
+ title: e(t).t("error.business_details.title")
1104
+ }, null, 8, ["message", "title"])) : e(i).isLoading.value ? (a(), m(He, {
1105
+ key: 1,
1106
+ class: "h-full"
1107
+ })) : o.value ? (a(), m(pn, {
1108
+ key: 2,
1109
+ business: o.value
1110
+ }, null, 8, ["business"])) : D("", !0)
1111
+ ]),
1112
+ _: 1
1113
+ }));
1114
+ }
1115
+ }), Dn = /* @__PURE__ */ x({
1116
+ __name: "BusinessDetailView",
1117
+ props: {
1118
+ tabs: {}
1119
+ },
1120
+ setup(n) {
1121
+ const s = n, t = ve("businessUuid");
1122
+ return (i, o) => (a(), m(is, {
1123
+ key: e(t),
1124
+ tabs: s.tabs,
1125
+ "entity-type": e(E).BUSINESS
1126
+ }, {
1127
+ sidebar: _(() => [
1128
+ u(_n, { "business-uuid": e(t) }, null, 8, ["business-uuid"])
1129
+ ]),
1130
+ _: 1
1131
+ }, 8, ["tabs", "entity-type"]));
1132
+ }
1133
+ });
1134
+ export {
1135
+ Dn as default
1136
+ };