From 88d62bcff5091cae844e675faa915c203b29324e Mon Sep 17 00:00:00 2001
From: Vyacheslav Tumanov <me@slavatumanov.me>
Date: Fri, 19 May 2023 10:02:43 +0500
Subject: [PATCH] UBER-48: custom fields for organization in leads (#3203)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
---
 .../src/components/CreateOrganization.svelte  | 32 +++++++++----------
 .../src/components/CreateCustomer.svelte      | 13 ++++++--
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/plugins/contact-resources/src/components/CreateOrganization.svelte b/plugins/contact-resources/src/components/CreateOrganization.svelte
index 3de312f32d..85a2a356ab 100644
--- a/plugins/contact-resources/src/components/CreateOrganization.svelte
+++ b/plugins/contact-resources/src/components/CreateOrganization.svelte
@@ -99,24 +99,22 @@
     />
   </div>
   <svelte:fragment slot="pool">
-    <div class="flex-row-center flex-wrap">
-      <ChannelsDropdown
-        bind:value={channels}
-        focusIndex={10}
-        kind={'secondary'}
-        size={'large'}
-        editable
-        highlighted={matchedChannels.map((it) => it.provider)}
-      />
+    <ChannelsDropdown
+      bind:value={channels}
+      focusIndex={10}
+      kind={'secondary'}
+      size={'large'}
+      editable
+      highlighted={matchedChannels.map((it) => it.provider)}
+    />
 
-      <InlineAttributeBar
-        _class={contact.class.Organization}
-        {object}
-        toClass={contact.class.Contact}
-        on:update
-        extraProps={{ showNavigate: false }}
-      />
-    </div>
+    <InlineAttributeBar
+      _class={contact.class.Organization}
+      {object}
+      toClass={contact.class.Contact}
+      on:update
+      extraProps={{ showNavigate: false }}
+    />
   </svelte:fragment>
   <svelte:fragment slot="footer">
     {#if matches.length > 0}
diff --git a/plugins/lead-resources/src/components/CreateCustomer.svelte b/plugins/lead-resources/src/components/CreateCustomer.svelte
index f0f1bbe9ac..df9468b379 100644
--- a/plugins/lead-resources/src/components/CreateCustomer.svelte
+++ b/plugins/lead-resources/src/components/CreateCustomer.svelte
@@ -18,7 +18,7 @@
   import contact from '@hcengineering/contact-resources/src/plugin'
   import { AttachedData, Class, Data, Doc, generateId, MixinData, Ref, WithLookup } from '@hcengineering/core'
   import type { Customer } from '@hcengineering/lead'
-  import { Card, getClient } from '@hcengineering/presentation'
+  import { Card, getClient, InlineAttributeBar } from '@hcengineering/presentation'
   import {
     Button,
     createFocusManager,
@@ -71,7 +71,7 @@
       description: object.description
     }
 
-    const id = await client.createDoc(targetClass._id, contact.space.Contacts, candidate, customerId)
+    const id = await client.createDoc(targetClass._id, contact.space.Contacts, { ...candidate, ...object }, customerId)
     await client.createMixin(
       id as Ref<Contact>,
       targetClass._id,
@@ -234,6 +234,15 @@
       editable
       highlighted={matchedChannels.map((it) => it.provider)}
     />
+    {#if targetClass._id === contact.class.Organization}
+      <InlineAttributeBar
+        _class={contact.class.Organization}
+        {object}
+        toClass={contact.class.Contact}
+        on:update
+        extraProps={{ showNavigate: false }}
+      />
+    {/if}
   </svelte:fragment>
   <svelte:fragment slot="footer">
     {#if matches.length > 0}