remove contact company/country/location across db and ui
This commit is contained in:
@@ -48,7 +48,7 @@ type TabId = "communications" | "documents";
|
|||||||
type CalendarView = "day" | "week" | "month" | "year" | "agenda";
|
type CalendarView = "day" | "week" | "month" | "year" | "agenda";
|
||||||
type SortMode = "name" | "lastContact";
|
type SortMode = "name" | "lastContact";
|
||||||
type PeopleLeftMode = "contacts" | "calendar";
|
type PeopleLeftMode = "contacts" | "calendar";
|
||||||
type PeopleSortMode = "name" | "lastContact" | "company" | "country";
|
type PeopleSortMode = "name" | "lastContact";
|
||||||
type PeopleVisibilityMode = "all" | "hidden";
|
type PeopleVisibilityMode = "all" | "hidden";
|
||||||
type DocumentSortMode = "updatedAt" | "title" | "owner";
|
type DocumentSortMode = "updatedAt" | "title" | "owner";
|
||||||
|
|
||||||
@@ -70,9 +70,6 @@ type Contact = {
|
|||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
avatar: string;
|
avatar: string;
|
||||||
company: string;
|
|
||||||
country: string;
|
|
||||||
location: string;
|
|
||||||
channels: string[];
|
channels: string[];
|
||||||
lastContactAt: string;
|
lastContactAt: string;
|
||||||
description: string;
|
description: string;
|
||||||
@@ -132,7 +129,6 @@ type Deal = {
|
|||||||
id: string;
|
id: string;
|
||||||
contact: string;
|
contact: string;
|
||||||
title: string;
|
title: string;
|
||||||
company: string;
|
|
||||||
stage: string;
|
stage: string;
|
||||||
amount: string;
|
amount: string;
|
||||||
nextStep: string;
|
nextStep: string;
|
||||||
@@ -3051,45 +3047,13 @@ function openYearMonth(monthIndex: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const contactSearch = ref("");
|
const contactSearch = ref("");
|
||||||
const selectedCountry = ref("All");
|
|
||||||
const selectedLocation = ref("All");
|
|
||||||
const selectedCompany = ref("All");
|
|
||||||
const selectedChannel = ref("All");
|
const selectedChannel = ref("All");
|
||||||
const sortMode = ref<SortMode>("name");
|
const sortMode = ref<SortMode>("name");
|
||||||
|
|
||||||
const countries = computed(() => ["All", ...new Set(contacts.value.map((c) => c.country))].sort());
|
|
||||||
|
|
||||||
const locationScopeContacts = computed(() =>
|
|
||||||
selectedCountry.value === "All"
|
|
||||||
? contacts.value
|
|
||||||
: contacts.value.filter((contact) => contact.country === selectedCountry.value),
|
|
||||||
);
|
|
||||||
|
|
||||||
const locations = computed(() => ["All", ...new Set(locationScopeContacts.value.map((c) => c.location))].sort());
|
|
||||||
|
|
||||||
const companyScopeContacts = computed(() =>
|
|
||||||
selectedLocation.value === "All"
|
|
||||||
? locationScopeContacts.value
|
|
||||||
: locationScopeContacts.value.filter((contact) => contact.location === selectedLocation.value),
|
|
||||||
);
|
|
||||||
|
|
||||||
const companies = computed(() => ["All", ...new Set(companyScopeContacts.value.map((c) => c.company))].sort());
|
|
||||||
const channels = computed(() => ["All", ...new Set(contacts.value.flatMap((c) => c.channels))].sort());
|
const channels = computed(() => ["All", ...new Set(contacts.value.flatMap((c) => c.channels))].sort());
|
||||||
|
|
||||||
watch(selectedCountry, () => {
|
|
||||||
selectedLocation.value = "All";
|
|
||||||
selectedCompany.value = "All";
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(selectedLocation, () => {
|
|
||||||
selectedCompany.value = "All";
|
|
||||||
});
|
|
||||||
|
|
||||||
function resetContactFilters() {
|
function resetContactFilters() {
|
||||||
contactSearch.value = "";
|
contactSearch.value = "";
|
||||||
selectedCountry.value = "All";
|
|
||||||
selectedLocation.value = "All";
|
|
||||||
selectedCompany.value = "All";
|
|
||||||
selectedChannel.value = "All";
|
selectedChannel.value = "All";
|
||||||
sortMode.value = "name";
|
sortMode.value = "name";
|
||||||
}
|
}
|
||||||
@@ -3097,12 +3061,9 @@ function resetContactFilters() {
|
|||||||
const filteredContacts = computed(() => {
|
const filteredContacts = computed(() => {
|
||||||
const query = contactSearch.value.trim().toLowerCase();
|
const query = contactSearch.value.trim().toLowerCase();
|
||||||
const data = contacts.value.filter((contact) => {
|
const data = contacts.value.filter((contact) => {
|
||||||
if (selectedCountry.value !== "All" && contact.country !== selectedCountry.value) return false;
|
|
||||||
if (selectedLocation.value !== "All" && contact.location !== selectedLocation.value) return false;
|
|
||||||
if (selectedCompany.value !== "All" && contact.company !== selectedCompany.value) return false;
|
|
||||||
if (selectedChannel.value !== "All" && !contact.channels.includes(selectedChannel.value)) return false;
|
if (selectedChannel.value !== "All" && !contact.channels.includes(selectedChannel.value)) return false;
|
||||||
if (query) {
|
if (query) {
|
||||||
const haystack = [contact.name, contact.company, contact.country, contact.location, contact.description, contact.channels.join(" ")]
|
const haystack = [contact.name, contact.description, contact.channels.join(" ")]
|
||||||
.join(" ")
|
.join(" ")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
if (!haystack.includes(query)) return false;
|
if (!haystack.includes(query)) return false;
|
||||||
@@ -3264,8 +3225,6 @@ const brokenAvatarByContactId = ref<Record<string, boolean>>({});
|
|||||||
const peopleSortOptions: Array<{ value: PeopleSortMode; label: string }> = [
|
const peopleSortOptions: Array<{ value: PeopleSortMode; label: string }> = [
|
||||||
{ value: "lastContact", label: "Last contact" },
|
{ value: "lastContact", label: "Last contact" },
|
||||||
{ value: "name", label: "Name" },
|
{ value: "name", label: "Name" },
|
||||||
{ value: "company", label: "Company" },
|
|
||||||
{ value: "country", label: "Country" },
|
|
||||||
];
|
];
|
||||||
const peopleVisibilityOptions: Array<{ value: PeopleVisibilityMode; label: string }> = [
|
const peopleVisibilityOptions: Array<{ value: PeopleVisibilityMode; label: string }> = [
|
||||||
{ value: "all", label: "All" },
|
{ value: "all", label: "All" },
|
||||||
@@ -3348,9 +3307,6 @@ const commThreads = computed(() => {
|
|||||||
id: contactId,
|
id: contactId,
|
||||||
contact: contactName,
|
contact: contactName,
|
||||||
avatar: contact?.avatar ?? "",
|
avatar: contact?.avatar ?? "",
|
||||||
company: contact?.company ?? "",
|
|
||||||
country: contact?.country ?? "",
|
|
||||||
location: contact?.location ?? "",
|
|
||||||
channels,
|
channels,
|
||||||
lastAt: last?.at ?? contact?.lastContactAt ?? inboxFallbackLast ?? "",
|
lastAt: last?.at ?? contact?.lastContactAt ?? inboxFallbackLast ?? "",
|
||||||
lastText: last?.text ?? "No messages yet",
|
lastText: last?.text ?? "No messages yet",
|
||||||
@@ -3365,7 +3321,7 @@ const peopleContactList = computed(() => {
|
|||||||
const query = peopleSearch.value.trim().toLowerCase();
|
const query = peopleSearch.value.trim().toLowerCase();
|
||||||
const list = commThreads.value.filter((item) => {
|
const list = commThreads.value.filter((item) => {
|
||||||
if (!query) return true;
|
if (!query) return true;
|
||||||
const haystack = [item.contact, item.company, item.country, item.location].join(" ").toLowerCase();
|
const haystack = [item.contact, ...(item.channels ?? [])].join(" ").toLowerCase();
|
||||||
return haystack.includes(query);
|
return haystack.includes(query);
|
||||||
});
|
});
|
||||||
const byVisibility = list.filter((item) => {
|
const byVisibility = list.filter((item) => {
|
||||||
@@ -3375,8 +3331,6 @@ const peopleContactList = computed(() => {
|
|||||||
|
|
||||||
return byVisibility.sort((a, b) => {
|
return byVisibility.sort((a, b) => {
|
||||||
if (peopleSortMode.value === "name") return a.contact.localeCompare(b.contact);
|
if (peopleSortMode.value === "name") return a.contact.localeCompare(b.contact);
|
||||||
if (peopleSortMode.value === "company") return a.company.localeCompare(b.company);
|
|
||||||
if (peopleSortMode.value === "country") return a.country.localeCompare(b.country);
|
|
||||||
return b.lastAt.localeCompare(a.lastAt);
|
return b.lastAt.localeCompare(a.lastAt);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -3385,7 +3339,7 @@ const peopleDealList = computed(() => {
|
|||||||
const query = peopleSearch.value.trim().toLowerCase();
|
const query = peopleSearch.value.trim().toLowerCase();
|
||||||
const list = deals.value.filter((deal) => {
|
const list = deals.value.filter((deal) => {
|
||||||
if (!query) return true;
|
if (!query) return true;
|
||||||
const haystack = [deal.title, deal.company, deal.stage, deal.amount, deal.nextStep, deal.summary, deal.contact]
|
const haystack = [deal.title, deal.stage, deal.amount, deal.nextStep, deal.summary, deal.contact]
|
||||||
.join(" ")
|
.join(" ")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
return haystack.includes(query);
|
return haystack.includes(query);
|
||||||
@@ -4845,9 +4799,6 @@ async function decideFeedCard(card: FeedCard, decision: "accepted" | "rejected")
|
|||||||
<div class="hidden h-12 items-center justify-between gap-2 border-b border-base-300 px-3 md:flex md:col-span-2">
|
<div class="hidden h-12 items-center justify-between gap-2 border-b border-base-300 px-3 md:flex md:col-span-2">
|
||||||
<div v-if="selectedWorkspaceContact">
|
<div v-if="selectedWorkspaceContact">
|
||||||
<p class="font-medium">{{ selectedWorkspaceContact.name }}</p>
|
<p class="font-medium">{{ selectedWorkspaceContact.name }}</p>
|
||||||
<p class="text-xs text-base-content/60">
|
|
||||||
{{ selectedWorkspaceContact.company }} · {{ selectedWorkspaceContact.location }}, {{ selectedWorkspaceContact.country }}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="selectedCommThread">
|
<div v-else-if="selectedCommThread">
|
||||||
<p class="font-medium">{{ selectedCommThread.contact }}</p>
|
<p class="font-medium">{{ selectedCommThread.contact }}</p>
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ function onSearchInput(event: Event) {
|
|||||||
<p class="truncate text-xs font-semibold">{{ deal.title }}</p>
|
<p class="truncate text-xs font-semibold">{{ deal.title }}</p>
|
||||||
<span class="shrink-0 text-[10px] text-base-content/55">{{ deal.amount }}</span>
|
<span class="shrink-0 text-[10px] text-base-content/55">{{ deal.amount }}</span>
|
||||||
</div>
|
</div>
|
||||||
<p class="mt-0.5 truncate text-[11px] text-base-content/75">{{ deal.company }} · {{ deal.stage }}</p>
|
<p class="mt-0.5 truncate text-[11px] text-base-content/75">{{ deal.stage }}</p>
|
||||||
<p class="mt-0.5 truncate text-[11px] text-base-content/60">{{ getDealCurrentStepLabel(deal) }}</p>
|
<p class="mt-0.5 truncate text-[11px] text-base-content/60">{{ getDealCurrentStepLabel(deal) }}</p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ query ContactsQuery {
|
|||||||
id
|
id
|
||||||
name
|
name
|
||||||
avatar
|
avatar
|
||||||
company
|
|
||||||
country
|
|
||||||
location
|
|
||||||
channels
|
channels
|
||||||
lastContactAt
|
lastContactAt
|
||||||
description
|
description
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ query DealsQuery {
|
|||||||
id
|
id
|
||||||
contact
|
contact
|
||||||
title
|
title
|
||||||
company
|
|
||||||
stage
|
stage
|
||||||
amount
|
amount
|
||||||
nextStep
|
nextStep
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Contact" DROP COLUMN "company",
|
||||||
|
DROP COLUMN "country",
|
||||||
|
DROP COLUMN "location";
|
||||||
|
|
||||||
@@ -123,9 +123,6 @@ model Contact {
|
|||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
teamId String
|
teamId String
|
||||||
name String
|
name String
|
||||||
company String?
|
|
||||||
country String?
|
|
||||||
location String?
|
|
||||||
avatarUrl String?
|
avatarUrl String?
|
||||||
email String?
|
email String?
|
||||||
phone String?
|
phone String?
|
||||||
|
|||||||
@@ -58,26 +58,26 @@ function plusMinutes(date, minutes) {
|
|||||||
|
|
||||||
function buildOdooAiContacts(teamId) {
|
function buildOdooAiContacts(teamId) {
|
||||||
const prospects = [
|
const prospects = [
|
||||||
{ name: "Оливия Рид", company: "РитейлНова", country: "США", location: "Нью-Йорк", email: "olivia.reed@retailnova.com", phone: "+1 555 120 0101" },
|
{ name: "Оливия Рид", email: "olivia.reed@retailnova.com", phone: "+1 555 120 0101" },
|
||||||
{ name: "Даниэль Ким", company: "ФорджПик Производство", country: "США", location: "Чикаго", email: "daniel.kim@forgepeak.com", phone: "+1 555 120 0102" },
|
{ name: "Даниэль Ким", email: "daniel.kim@forgepeak.com", phone: "+1 555 120 0102" },
|
||||||
{ name: "Марта Алонсо", company: "Иберия Фудс Групп", country: "Испания", location: "Барселона", email: "marta.alonso@iberiafoods.es", phone: "+34 91 555 0103" },
|
{ name: "Марта Алонсо", email: "marta.alonso@iberiafoods.es", phone: "+34 91 555 0103" },
|
||||||
{ name: "Юсеф Хаддад", company: "ГалфТрейд Дистрибуция", country: "ОАЭ", location: "Дубай", email: "youssef.haddad@gulftrade.ae", phone: "+971 4 555 0104" },
|
{ name: "Юсеф Хаддад", email: "youssef.haddad@gulftrade.ae", phone: "+971 4 555 0104" },
|
||||||
{ name: "Эмма Коллинз", company: "НортБридж Логистика", country: "Великобритания", location: "Лондон", email: "emma.collins@northbridge.co.uk", phone: "+44 20 5550 0105" },
|
{ name: "Эмма Коллинз", email: "emma.collins@northbridge.co.uk", phone: "+44 20 5550 0105" },
|
||||||
{ name: "Ноа Фишер", company: "Бергман Автозапчасти", country: "Германия", location: "Мюнхен", email: "noah.fischer@bergmann-auto.de", phone: "+49 89 5550 0106" },
|
{ name: "Ноа Фишер", email: "noah.fischer@bergmann-auto.de", phone: "+49 89 5550 0106" },
|
||||||
{ name: "Ава Чой", company: "Пасифик МедТех Сапплай", country: "Сингапур", location: "Сингапур", email: "ava.choi@pacificmedtech.sg", phone: "+65 6555 0107" },
|
{ name: "Ава Чой", email: "ava.choi@pacificmedtech.sg", phone: "+65 6555 0107" },
|
||||||
{ name: "Лиам Дюбуа", company: "ГексаКоммерс", country: "Франция", location: "Париж", email: "liam.dubois@hexacommerce.fr", phone: "+33 1 55 50 0108" },
|
{ name: "Лиам Дюбуа", email: "liam.dubois@hexacommerce.fr", phone: "+33 1 55 50 0108" },
|
||||||
{ name: "Майя Шах", company: "Зенит Консьюмер Брендс", country: "Канада", location: "Торонто", email: "maya.shah@zenithbrands.ca", phone: "+1 416 555 0109" },
|
{ name: "Майя Шах", email: "maya.shah@zenithbrands.ca", phone: "+1 416 555 0109" },
|
||||||
{ name: "Арман Петросян", company: "Арарат Электроникс", country: "Армения", location: "Ереван", email: "arman.petrosyan@ararat-electronics.am", phone: "+374 10 555110" },
|
{ name: "Арман Петросян", email: "arman.petrosyan@ararat-electronics.am", phone: "+374 10 555110" },
|
||||||
{ name: "София Мартинес", company: "Санлайн Товары для дома", country: "США", location: "Остин", email: "sophia.martinez@sunlinehg.com", phone: "+1 555 120 0111" },
|
{ name: "София Мартинес", email: "sophia.martinez@sunlinehg.com", phone: "+1 555 120 0111" },
|
||||||
{ name: "Лео Новак", company: "ЦентралБилд Материалы", country: "Германия", location: "Берлин", email: "leo.novak@centralbuild.de", phone: "+49 30 5550 0112" },
|
{ name: "Лео Новак", email: "leo.novak@centralbuild.de", phone: "+49 30 5550 0112" },
|
||||||
{ name: "Айла Грант", company: "БлюХарбор Фарма", country: "Великобритания", location: "Манчестер", email: "isla.grant@blueharbor.co.uk", phone: "+44 161 555 0113" },
|
{ name: "Айла Грант", email: "isla.grant@blueharbor.co.uk", phone: "+44 161 555 0113" },
|
||||||
{ name: "Матео Росси", company: "Милано Фэшн Хаус", country: "Италия", location: "Милан", email: "mateo.rossi@milanofh.it", phone: "+39 02 5550 0114" },
|
{ name: "Матео Росси", email: "mateo.rossi@milanofh.it", phone: "+39 02 5550 0114" },
|
||||||
{ name: "Нина Волкова", company: "Полар АгриТех", country: "Казахстан", location: "Алматы", email: "nina.volkova@polaragri.kz", phone: "+7 727 555 0115" },
|
{ name: "Нина Волкова", email: "nina.volkova@polaragri.kz", phone: "+7 727 555 0115" },
|
||||||
{ name: "Итан Пак", company: "Вертекс Компонентс", country: "Южная Корея", location: "Сеул", email: "ethan.park@vertexcomponents.kr", phone: "+82 2 555 0116" },
|
{ name: "Итан Пак", email: "ethan.park@vertexcomponents.kr", phone: "+82 2 555 0116" },
|
||||||
{ name: "Зара Хан", company: "Кресент Ритейл Чейн", country: "ОАЭ", location: "Абу-Даби", email: "zara.khan@crescentretail.ae", phone: "+971 2 555 0117" },
|
{ name: "Зара Хан", email: "zara.khan@crescentretail.ae", phone: "+971 2 555 0117" },
|
||||||
{ name: "Уго Силва", company: "Лузо Индастриал Системс", country: "Португалия", location: "Лиссабон", email: "hugo.silva@lusois.pt", phone: "+351 21 555 0118" },
|
{ name: "Уго Силва", email: "hugo.silva@lusois.pt", phone: "+351 21 555 0118" },
|
||||||
{ name: "Хлоя Бернар", company: "Сантекс Сеть Клиник", country: "Франция", location: "Лион", email: "chloe.bernard@santex.fr", phone: "+33 4 55 50 0119" },
|
{ name: "Хлоя Бернар", email: "chloe.bernard@santex.fr", phone: "+33 4 55 50 0119" },
|
||||||
{ name: "Джеймс Уокер", company: "Метро Оптовая Группа", country: "США", location: "Лос-Анджелес", email: "james.walker@metrowholesale.com", phone: "+1 555 120 0120" },
|
{ name: "Джеймс Уокер", email: "james.walker@metrowholesale.com", phone: "+1 555 120 0120" },
|
||||||
];
|
];
|
||||||
|
|
||||||
return prospects.map((p, idx) => {
|
return prospects.map((p, idx) => {
|
||||||
@@ -86,9 +86,6 @@ function buildOdooAiContacts(teamId) {
|
|||||||
return {
|
return {
|
||||||
teamId,
|
teamId,
|
||||||
name: p.name,
|
name: p.name,
|
||||||
company: p.company,
|
|
||||||
country: p.country,
|
|
||||||
location: p.location,
|
|
||||||
avatarUrl: `https://randomuser.me/api/portraits/${female ? "women" : "men"}/${picIdx}.jpg`,
|
avatarUrl: `https://randomuser.me/api/portraits/${female ? "women" : "men"}/${picIdx}.jpg`,
|
||||||
email: p.email,
|
email: p.email,
|
||||||
phone: p.phone,
|
phone: p.phone,
|
||||||
@@ -146,7 +143,7 @@ async function main() {
|
|||||||
|
|
||||||
const contacts = await prisma.contact.createManyAndReturn({
|
const contacts = await prisma.contact.createManyAndReturn({
|
||||||
data: buildOdooAiContacts(team.id),
|
data: buildOdooAiContacts(team.id),
|
||||||
select: { id: true, name: true, company: true },
|
select: { id: true, name: true },
|
||||||
});
|
});
|
||||||
|
|
||||||
const integrationModules = [
|
const integrationModules = [
|
||||||
@@ -162,7 +159,7 @@ async function main() {
|
|||||||
data: contacts.map((c, idx) => ({
|
data: contacts.map((c, idx) => ({
|
||||||
contactId: c.id,
|
contactId: c.id,
|
||||||
content:
|
content:
|
||||||
`${c.company ?? c.name} рассматривает внедрение Odoo с AI-расширениями. ` +
|
`${c.name} рассматривает внедрение Odoo с AI-расширениями. ` +
|
||||||
`Основной контур интеграции: ${integrationModules[idx % integrationModules.length]}. ` +
|
`Основной контур интеграции: ${integrationModules[idx % integrationModules.length]}. ` +
|
||||||
`Ключевой драйвер покупки: сократить ручные операции и ускорить цикл принятия решений. ` +
|
`Ключевой драйвер покупки: сократить ручные операции и ускорить цикл принятия решений. ` +
|
||||||
`Следующая веха: провести сессию уточнения, согласовать владельцев данных и утвердить KPI пилота.`,
|
`Следующая веха: провести сессию уточнения, согласовать владельцев данных и утвердить KPI пилота.`,
|
||||||
@@ -180,7 +177,7 @@ async function main() {
|
|||||||
kind: "MESSAGE",
|
kind: "MESSAGE",
|
||||||
direction: "IN",
|
direction: "IN",
|
||||||
channel: channels[i % channels.length],
|
channel: channels[i % channels.length],
|
||||||
content: `Здравствуйте! Мы рассматриваем запуск Odoo + AI для ${contact.company}. Можем согласовать план интеграции на этой неделе?`,
|
content: `Здравствуйте! Мы рассматриваем запуск Odoo + AI для ${contact.name}. Можем согласовать план интеграции на этой неделе?`,
|
||||||
occurredAt: base,
|
occurredAt: base,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -226,7 +223,7 @@ async function main() {
|
|||||||
{
|
{
|
||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
contactId: c.id,
|
contactId: c.id,
|
||||||
title: `Сессия уточнения: Odoo + AI с ${c.company ?? c.name}`,
|
title: `Сессия уточнения: Odoo + AI с ${c.name}`,
|
||||||
startsAt: firstStart,
|
startsAt: firstStart,
|
||||||
endsAt: plusMinutes(firstStart, 30),
|
endsAt: plusMinutes(firstStart, 30),
|
||||||
note: "Подтвердить рамки интеграции, текущий стек и метрики успеха пилота.",
|
note: "Подтвердить рамки интеграции, текущий стек и метрики успеха пилота.",
|
||||||
@@ -234,7 +231,7 @@ async function main() {
|
|||||||
{
|
{
|
||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
contactId: c.id,
|
contactId: c.id,
|
||||||
title: `Архитектурный воркшоп: ${c.company ?? c.name}`,
|
title: `Архитектурный воркшоп: ${c.name}`,
|
||||||
startsAt: secondStart,
|
startsAt: secondStart,
|
||||||
endsAt: plusMinutes(secondStart, 45),
|
endsAt: plusMinutes(secondStart, 45),
|
||||||
note: "Проверить маппинг API, границы ETL и ограничения для AI-ассистента.",
|
note: "Проверить маппинг API, границы ETL и ограничения для AI-ассистента.",
|
||||||
@@ -254,7 +251,7 @@ async function main() {
|
|||||||
data: {
|
data: {
|
||||||
teamId: team.id,
|
teamId: team.id,
|
||||||
contactId: c.id,
|
contactId: c.id,
|
||||||
title: `${c.company ?? "Клиент"}: интеграция Odoo + AI`,
|
title: `${c.name}: интеграция Odoo + AI`,
|
||||||
stage: stages[idx % stages.length],
|
stage: stages[idx % stages.length],
|
||||||
amount: 18000 + (idx % 8) * 7000,
|
amount: 18000 + (idx % 8) * 7000,
|
||||||
nextStep: nextStepText,
|
nextStep: nextStepText,
|
||||||
@@ -327,7 +324,7 @@ async function main() {
|
|||||||
contactId: c.id,
|
contactId: c.id,
|
||||||
happenedAt: atOffset(-(idx % 6), 9 + (idx % 8), (idx * 9) % 60),
|
happenedAt: atOffset(-(idx % 6), 9 + (idx % 8), (idx * 9) % 60),
|
||||||
text:
|
text:
|
||||||
`Я проверил активность по аккаунту ${c.company ?? c.name} в рамках сделки Odoo + AI. ` +
|
`Я проверил активность по аккаунту ${c.name} в рамках сделки Odoo + AI. ` +
|
||||||
"Есть достаточный импульс, чтобы перевести сделку на следующий этап при чётком следующем шаге.",
|
"Есть достаточный импульс, чтобы перевести сделку на следующий этап при чётком следующем шаге.",
|
||||||
proposalJson: {
|
proposalJson: {
|
||||||
title: idx % 2 === 0 ? "Назначить созвон по рамкам пилота" : "Отправить сообщение для разблокировки у владельца бюджета",
|
title: idx % 2 === 0 ? "Назначить созвон по рамкам пилота" : "Отправить сообщение для разблокировки у владельца бюджета",
|
||||||
|
|||||||
@@ -100,9 +100,6 @@ async function main() {
|
|||||||
id: c.id,
|
id: c.id,
|
||||||
teamId: c.teamId,
|
teamId: c.teamId,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
company: c.company ?? null,
|
|
||||||
country: c.country ?? null,
|
|
||||||
location: c.location ?? null,
|
|
||||||
avatarUrl: c.avatarUrl ?? null,
|
avatarUrl: c.avatarUrl ?? null,
|
||||||
email: c.email ?? null,
|
email: c.email ?? null,
|
||||||
phone: c.phone ?? null,
|
phone: c.phone ?? null,
|
||||||
@@ -155,7 +152,6 @@ async function main() {
|
|||||||
contactIndex.push({
|
contactIndex.push({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
company: c.company ?? null,
|
|
||||||
lastMessageAt,
|
lastMessageAt,
|
||||||
nextEventAt,
|
nextEventAt,
|
||||||
updatedAt: c.updatedAt,
|
updatedAt: c.updatedAt,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import type { ChangeSet } from "../utils/changeSet";
|
|||||||
type ContactIndexRow = {
|
type ContactIndexRow = {
|
||||||
id: string;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
company: string | null;
|
|
||||||
lastMessageAt: string | null;
|
lastMessageAt: string | null;
|
||||||
nextEventAt: string | null;
|
nextEventAt: string | null;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
@@ -108,9 +107,8 @@ async function readJsonl(p: string): Promise<any[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatContactLine(c: ContactIndexRow) {
|
function formatContactLine(c: ContactIndexRow) {
|
||||||
const company = c.company ? ` (${c.company})` : "";
|
|
||||||
const lastAt = c.lastMessageAt ? new Date(c.lastMessageAt).toLocaleString("ru-RU") : "нет";
|
const lastAt = c.lastMessageAt ? new Date(c.lastMessageAt).toLocaleString("ru-RU") : "нет";
|
||||||
return `- ${c.name}${company} · последнее: ${lastAt}`;
|
return `- ${c.name} · последнее: ${lastAt}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function runCrmAgent(userText: string): Promise<AgentReply> {
|
export async function runCrmAgent(userText: string): Promise<AgentReply> {
|
||||||
@@ -227,7 +225,7 @@ export async function runCrmAgentFor(
|
|||||||
lines.push("");
|
lines.push("");
|
||||||
lines.push("Фокус дня (если нужно добить прогресс):");
|
lines.push("Фокус дня (если нужно добить прогресс):");
|
||||||
for (const c of followups) {
|
for (const c of followups) {
|
||||||
lines.push(`- Написать follow-up: ${c.name}${c.company ? ` (${c.company})` : ""}`);
|
lines.push(`- Написать follow-up: ${c.name}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
|
|||||||
orderBy: { updatedAt: "desc" },
|
orderBy: { updatedAt: "desc" },
|
||||||
take: 20,
|
take: 20,
|
||||||
include: {
|
include: {
|
||||||
contact: { select: { name: true, company: true } },
|
contact: { select: { name: true } },
|
||||||
steps: { select: { id: true, title: true, status: true, dueAt: true, order: true, completedAt: true }, orderBy: [{ order: "asc" }, { createdAt: "asc" }] },
|
steps: { select: { id: true, title: true, status: true, dueAt: true, order: true, completedAt: true }, orderBy: [{ order: "asc" }, { createdAt: "asc" }] },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
@@ -247,15 +247,11 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
|
|||||||
updatedAt: iso(d.updatedAt),
|
updatedAt: iso(d.updatedAt),
|
||||||
contact: {
|
contact: {
|
||||||
name: d.contact.name,
|
name: d.contact.name,
|
||||||
company: d.contact.company,
|
|
||||||
},
|
},
|
||||||
})),
|
})),
|
||||||
contacts: contacts.map((c) => ({
|
contacts: contacts.map((c) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
company: c.company,
|
|
||||||
country: c.country,
|
|
||||||
location: c.location,
|
|
||||||
email: c.email,
|
email: c.email,
|
||||||
phone: c.phone,
|
phone: c.phone,
|
||||||
avatarUrl: c.avatarUrl,
|
avatarUrl: c.avatarUrl,
|
||||||
@@ -549,7 +545,6 @@ export async function runLangGraphCrmAgentFor(input: {
|
|||||||
? {
|
? {
|
||||||
OR: [
|
OR: [
|
||||||
{ name: { contains: q } },
|
{ name: { contains: q } },
|
||||||
{ company: { contains: q } },
|
|
||||||
{ email: { contains: q } },
|
{ email: { contains: q } },
|
||||||
{ phone: { contains: q } },
|
{ phone: { contains: q } },
|
||||||
],
|
],
|
||||||
@@ -593,9 +588,6 @@ export async function runLangGraphCrmAgentFor(input: {
|
|||||||
items: items.map((c) => ({
|
items: items.map((c) => ({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
company: c.company,
|
|
||||||
country: c.country,
|
|
||||||
location: c.location,
|
|
||||||
email: c.email,
|
email: c.email,
|
||||||
phone: c.phone,
|
phone: c.phone,
|
||||||
summary: c.note?.content ?? null,
|
summary: c.note?.content ?? null,
|
||||||
@@ -711,9 +703,6 @@ export async function runLangGraphCrmAgentFor(input: {
|
|||||||
contact: {
|
contact: {
|
||||||
id: contact.id,
|
id: contact.id,
|
||||||
name: contact.name,
|
name: contact.name,
|
||||||
company: contact.company,
|
|
||||||
country: contact.country,
|
|
||||||
location: contact.location,
|
|
||||||
email: contact.email,
|
email: contact.email,
|
||||||
phone: contact.phone,
|
phone: contact.phone,
|
||||||
updatedAt: contact.updatedAt.toISOString(),
|
updatedAt: contact.updatedAt.toISOString(),
|
||||||
@@ -790,7 +779,7 @@ export async function runLangGraphCrmAgentFor(input: {
|
|||||||
orderBy: { startsAt: "asc" },
|
orderBy: { startsAt: "asc" },
|
||||||
skip: offset,
|
skip: offset,
|
||||||
take: limit,
|
take: limit,
|
||||||
include: { contact: { select: { id: true, name: true, company: true } } },
|
include: { contact: { select: { id: true, name: true } } },
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -817,7 +806,6 @@ export async function runLangGraphCrmAgentFor(input: {
|
|||||||
? {
|
? {
|
||||||
id: e.contact.id,
|
id: e.contact.id,
|
||||||
name: e.contact.name,
|
name: e.contact.name,
|
||||||
company: e.contact.company,
|
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@@ -95,9 +95,6 @@ export async function exportDatasetFromPrismaFor(input: { teamId: string; userId
|
|||||||
id: c.id,
|
id: c.id,
|
||||||
teamId: c.teamId,
|
teamId: c.teamId,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
company: c.company ?? null,
|
|
||||||
country: c.country ?? null,
|
|
||||||
location: c.location ?? null,
|
|
||||||
avatarUrl: c.avatarUrl ?? null,
|
avatarUrl: c.avatarUrl ?? null,
|
||||||
email: c.email ?? null,
|
email: c.email ?? null,
|
||||||
phone: c.phone ?? null,
|
phone: c.phone ?? null,
|
||||||
@@ -144,7 +141,6 @@ export async function exportDatasetFromPrismaFor(input: { teamId: string; userId
|
|||||||
contactIndex.push({
|
contactIndex.push({
|
||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
company: c.company ?? null,
|
|
||||||
lastMessageAt,
|
lastMessageAt,
|
||||||
nextEventAt,
|
nextEventAt,
|
||||||
updatedAt: c.updatedAt,
|
updatedAt: c.updatedAt,
|
||||||
|
|||||||
@@ -509,9 +509,6 @@ async function getContacts(auth: AuthContext | null) {
|
|||||||
id: c.id,
|
id: c.id,
|
||||||
name: c.name,
|
name: c.name,
|
||||||
avatar: c.avatarUrl ?? "",
|
avatar: c.avatarUrl ?? "",
|
||||||
company: c.company ?? "",
|
|
||||||
country: c.country ?? "",
|
|
||||||
location: c.location ?? "",
|
|
||||||
channels: Array.from(channelsByContactId.get(c.id) ?? []),
|
channels: Array.from(channelsByContactId.get(c.id) ?? []),
|
||||||
lastContactAt: c.messages[0]?.occurredAt?.toISOString?.() ?? c.updatedAt.toISOString(),
|
lastContactAt: c.messages[0]?.occurredAt?.toISOString?.() ?? c.updatedAt.toISOString(),
|
||||||
description: c.note?.content ?? "",
|
description: c.note?.content ?? "",
|
||||||
@@ -706,7 +703,7 @@ async function getDeals(auth: AuthContext | null) {
|
|||||||
const dealsRaw = await prisma.deal.findMany({
|
const dealsRaw = await prisma.deal.findMany({
|
||||||
where: { teamId: ctx.teamId },
|
where: { teamId: ctx.teamId },
|
||||||
include: {
|
include: {
|
||||||
contact: { select: { name: true, company: true } },
|
contact: { select: { name: true } },
|
||||||
steps: { orderBy: [{ order: "asc" }, { createdAt: "asc" }] },
|
steps: { orderBy: [{ order: "asc" }, { createdAt: "asc" }] },
|
||||||
},
|
},
|
||||||
orderBy: { updatedAt: "desc" },
|
orderBy: { updatedAt: "desc" },
|
||||||
@@ -717,7 +714,6 @@ async function getDeals(auth: AuthContext | null) {
|
|||||||
id: d.id,
|
id: d.id,
|
||||||
contact: d.contact.name,
|
contact: d.contact.name,
|
||||||
title: d.title,
|
title: d.title,
|
||||||
company: d.contact.company ?? "",
|
|
||||||
stage: d.stage,
|
stage: d.stage,
|
||||||
amount: d.amount ? String(d.amount) : "",
|
amount: d.amount ? String(d.amount) : "",
|
||||||
nextStep: d.nextStep ?? "",
|
nextStep: d.nextStep ?? "",
|
||||||
@@ -1999,9 +1995,6 @@ export const crmGraphqlSchema = buildSchema(`
|
|||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
name: String!
|
||||||
avatar: String!
|
avatar: String!
|
||||||
company: String!
|
|
||||||
country: String!
|
|
||||||
location: String!
|
|
||||||
channels: [String!]!
|
channels: [String!]!
|
||||||
lastContactAt: String!
|
lastContactAt: String!
|
||||||
description: String!
|
description: String!
|
||||||
@@ -2054,7 +2047,6 @@ export const crmGraphqlSchema = buildSchema(`
|
|||||||
id: ID!
|
id: ID!
|
||||||
contact: String!
|
contact: String!
|
||||||
title: String!
|
title: String!
|
||||||
company: String!
|
|
||||||
stage: String!
|
stage: String!
|
||||||
amount: String!
|
amount: String!
|
||||||
nextStep: String!
|
nextStep: String!
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ model Contact {
|
|||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
teamId String
|
teamId String
|
||||||
name String
|
name String
|
||||||
company String?
|
|
||||||
country String?
|
|
||||||
location String?
|
|
||||||
avatarUrl String?
|
avatarUrl String?
|
||||||
email String?
|
email String?
|
||||||
phone String?
|
phone String?
|
||||||
|
|||||||
@@ -226,9 +226,6 @@ async function resolveContact(input: {
|
|||||||
teamId: input.teamId,
|
teamId: input.teamId,
|
||||||
name: input.profile.displayName,
|
name: input.profile.displayName,
|
||||||
avatarUrl: input.profile.avatarUrl,
|
avatarUrl: input.profile.avatarUrl,
|
||||||
company: null,
|
|
||||||
country: null,
|
|
||||||
location: null,
|
|
||||||
},
|
},
|
||||||
select: { id: true },
|
select: { id: true },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -116,9 +116,6 @@ model Contact {
|
|||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
teamId String
|
teamId String
|
||||||
name String
|
name String
|
||||||
company String?
|
|
||||||
country String?
|
|
||||||
location String?
|
|
||||||
avatarUrl String?
|
avatarUrl String?
|
||||||
email String?
|
email String?
|
||||||
phone String?
|
phone String?
|
||||||
|
|||||||
Reference in New Issue
Block a user