remove contact company/country/location across db and ui

This commit is contained in:
Ruslan Bakiev
2026-02-23 14:52:26 +07:00
parent f6b738352b
commit 60b9bb9fd1
15 changed files with 42 additions and 135 deletions

View File

@@ -48,7 +48,7 @@ type TabId = "communications" | "documents";
type CalendarView = "day" | "week" | "month" | "year" | "agenda";
type SortMode = "name" | "lastContact";
type PeopleLeftMode = "contacts" | "calendar";
type PeopleSortMode = "name" | "lastContact" | "company" | "country";
type PeopleSortMode = "name" | "lastContact";
type PeopleVisibilityMode = "all" | "hidden";
type DocumentSortMode = "updatedAt" | "title" | "owner";
@@ -70,9 +70,6 @@ type Contact = {
id: string;
name: string;
avatar: string;
company: string;
country: string;
location: string;
channels: string[];
lastContactAt: string;
description: string;
@@ -132,7 +129,6 @@ type Deal = {
id: string;
contact: string;
title: string;
company: string;
stage: string;
amount: string;
nextStep: string;
@@ -3051,45 +3047,13 @@ function openYearMonth(monthIndex: number) {
}
const contactSearch = ref("");
const selectedCountry = ref("All");
const selectedLocation = ref("All");
const selectedCompany = ref("All");
const selectedChannel = ref("All");
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());
watch(selectedCountry, () => {
selectedLocation.value = "All";
selectedCompany.value = "All";
});
watch(selectedLocation, () => {
selectedCompany.value = "All";
});
function resetContactFilters() {
contactSearch.value = "";
selectedCountry.value = "All";
selectedLocation.value = "All";
selectedCompany.value = "All";
selectedChannel.value = "All";
sortMode.value = "name";
}
@@ -3097,12 +3061,9 @@ function resetContactFilters() {
const filteredContacts = computed(() => {
const query = contactSearch.value.trim().toLowerCase();
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 (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(" ")
.toLowerCase();
if (!haystack.includes(query)) return false;
@@ -3264,8 +3225,6 @@ const brokenAvatarByContactId = ref<Record<string, boolean>>({});
const peopleSortOptions: Array<{ value: PeopleSortMode; label: string }> = [
{ value: "lastContact", label: "Last contact" },
{ value: "name", label: "Name" },
{ value: "company", label: "Company" },
{ value: "country", label: "Country" },
];
const peopleVisibilityOptions: Array<{ value: PeopleVisibilityMode; label: string }> = [
{ value: "all", label: "All" },
@@ -3348,9 +3307,6 @@ const commThreads = computed(() => {
id: contactId,
contact: contactName,
avatar: contact?.avatar ?? "",
company: contact?.company ?? "",
country: contact?.country ?? "",
location: contact?.location ?? "",
channels,
lastAt: last?.at ?? contact?.lastContactAt ?? inboxFallbackLast ?? "",
lastText: last?.text ?? "No messages yet",
@@ -3365,7 +3321,7 @@ const peopleContactList = computed(() => {
const query = peopleSearch.value.trim().toLowerCase();
const list = commThreads.value.filter((item) => {
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);
});
const byVisibility = list.filter((item) => {
@@ -3375,8 +3331,6 @@ const peopleContactList = computed(() => {
return byVisibility.sort((a, b) => {
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);
});
});
@@ -3385,7 +3339,7 @@ const peopleDealList = computed(() => {
const query = peopleSearch.value.trim().toLowerCase();
const list = deals.value.filter((deal) => {
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(" ")
.toLowerCase();
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 v-if="selectedWorkspaceContact">
<p class="font-medium">{{ selectedWorkspaceContact.name }}</p>
<p class="text-xs text-base-content/60">
{{ selectedWorkspaceContact.company }} · {{ selectedWorkspaceContact.location }}, {{ selectedWorkspaceContact.country }}
</p>
</div>
<div v-else-if="selectedCommThread">
<p class="font-medium">{{ selectedCommThread.contact }}</p>

View File

@@ -167,7 +167,7 @@ function onSearchInput(event: Event) {
<p class="truncate text-xs font-semibold">{{ deal.title }}</p>
<span class="shrink-0 text-[10px] text-base-content/55">{{ deal.amount }}</span>
</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>
</button>

View File

@@ -3,9 +3,6 @@ query ContactsQuery {
id
name
avatar
company
country
location
channels
lastContactAt
description

View File

@@ -3,7 +3,6 @@ query DealsQuery {
id
contact
title
company
stage
amount
nextStep

View File

@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Contact" DROP COLUMN "company",
DROP COLUMN "country",
DROP COLUMN "location";

View File

@@ -123,9 +123,6 @@ model Contact {
id String @id @default(cuid())
teamId String
name String
company String?
country String?
location String?
avatarUrl String?
email String?
phone String?

View File

@@ -58,26 +58,26 @@ function plusMinutes(date, minutes) {
function buildOdooAiContacts(teamId) {
const prospects = [
{ name: "Оливия Рид", company: "РитейлНова", country: "США", location: "Нью-Йорк", 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: "Марта Алонсо", company: "Иберия Фудс Групп", country: "Испания", location: "Барселона", 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: "Эмма Коллинз", company: "НортБридж Логистика", country: "Великобритания", location: "Лондон", 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: "Ава Чой", company: "Пасифик МедТех Сапплай", country: "Сингапур", location: "Сингапур", 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: "Майя Шах", company: "Зенит Консьюмер Брендс", country: "Канада", location: "Торонто", 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: "София Мартинес", company: "Санлайн Товары для дома", country: "США", location: "Остин", 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: "Айла Грант", company: "БлюХарбор Фарма", country: "Великобритания", location: "Манчестер", 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: "Нина Волкова", company: "Полар АгриТех", country: "Казахстан", location: "Алматы", 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: "Зара Хан", company: "Кресент Ритейл Чейн", country: "ОАЭ", location: "Абу-Даби", 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: "Хлоя Бернар", company: "Сантекс Сеть Клиник", country: "Франция", location: "Лион", 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: "olivia.reed@retailnova.com", phone: "+1 555 120 0101" },
{ name: "Даниэль Ким", email: "daniel.kim@forgepeak.com", phone: "+1 555 120 0102" },
{ name: "Марта Алонсо", email: "marta.alonso@iberiafoods.es", phone: "+34 91 555 0103" },
{ name: "Юсеф Хаддад", email: "youssef.haddad@gulftrade.ae", phone: "+971 4 555 0104" },
{ name: "Эмма Коллинз", email: "emma.collins@northbridge.co.uk", phone: "+44 20 5550 0105" },
{ name: "Ноа Фишер", email: "noah.fischer@bergmann-auto.de", phone: "+49 89 5550 0106" },
{ name: "Ава Чой", email: "ava.choi@pacificmedtech.sg", phone: "+65 6555 0107" },
{ name: "Лиам Дюбуа", email: "liam.dubois@hexacommerce.fr", phone: "+33 1 55 50 0108" },
{ name: "Майя Шах", email: "maya.shah@zenithbrands.ca", phone: "+1 416 555 0109" },
{ name: "Арман Петросян", email: "arman.petrosyan@ararat-electronics.am", phone: "+374 10 555110" },
{ name: "София Мартинес", email: "sophia.martinez@sunlinehg.com", phone: "+1 555 120 0111" },
{ name: "Лео Новак", email: "leo.novak@centralbuild.de", phone: "+49 30 5550 0112" },
{ name: "Айла Грант", email: "isla.grant@blueharbor.co.uk", phone: "+44 161 555 0113" },
{ name: "Матео Росси", email: "mateo.rossi@milanofh.it", phone: "+39 02 5550 0114" },
{ name: "Нина Волкова", email: "nina.volkova@polaragri.kz", phone: "+7 727 555 0115" },
{ name: "Итан Пак", email: "ethan.park@vertexcomponents.kr", phone: "+82 2 555 0116" },
{ name: "Зара Хан", email: "zara.khan@crescentretail.ae", phone: "+971 2 555 0117" },
{ name: "Уго Силва", email: "hugo.silva@lusois.pt", phone: "+351 21 555 0118" },
{ name: "Хлоя Бернар", email: "chloe.bernard@santex.fr", phone: "+33 4 55 50 0119" },
{ name: "Джеймс Уокер", email: "james.walker@metrowholesale.com", phone: "+1 555 120 0120" },
];
return prospects.map((p, idx) => {
@@ -86,9 +86,6 @@ function buildOdooAiContacts(teamId) {
return {
teamId,
name: p.name,
company: p.company,
country: p.country,
location: p.location,
avatarUrl: `https://randomuser.me/api/portraits/${female ? "women" : "men"}/${picIdx}.jpg`,
email: p.email,
phone: p.phone,
@@ -146,7 +143,7 @@ async function main() {
const contacts = await prisma.contact.createManyAndReturn({
data: buildOdooAiContacts(team.id),
select: { id: true, name: true, company: true },
select: { id: true, name: true },
});
const integrationModules = [
@@ -162,7 +159,7 @@ async function main() {
data: contacts.map((c, idx) => ({
contactId: c.id,
content:
`${c.company ?? c.name} рассматривает внедрение Odoo с AI-расширениями. ` +
`${c.name} рассматривает внедрение Odoo с AI-расширениями. ` +
`Основной контур интеграции: ${integrationModules[idx % integrationModules.length]}. ` +
`Ключевой драйвер покупки: сократить ручные операции и ускорить цикл принятия решений. ` +
`Следующая веха: провести сессию уточнения, согласовать владельцев данных и утвердить KPI пилота.`,
@@ -180,7 +177,7 @@ async function main() {
kind: "MESSAGE",
direction: "IN",
channel: channels[i % channels.length],
content: `Здравствуйте! Мы рассматриваем запуск Odoo + AI для ${contact.company}. Можем согласовать план интеграции на этой неделе?`,
content: `Здравствуйте! Мы рассматриваем запуск Odoo + AI для ${contact.name}. Можем согласовать план интеграции на этой неделе?`,
occurredAt: base,
});
@@ -226,7 +223,7 @@ async function main() {
{
teamId: team.id,
contactId: c.id,
title: `Сессия уточнения: Odoo + AI с ${c.company ?? c.name}`,
title: `Сессия уточнения: Odoo + AI с ${c.name}`,
startsAt: firstStart,
endsAt: plusMinutes(firstStart, 30),
note: "Подтвердить рамки интеграции, текущий стек и метрики успеха пилота.",
@@ -234,7 +231,7 @@ async function main() {
{
teamId: team.id,
contactId: c.id,
title: `Архитектурный воркшоп: ${c.company ?? c.name}`,
title: `Архитектурный воркшоп: ${c.name}`,
startsAt: secondStart,
endsAt: plusMinutes(secondStart, 45),
note: "Проверить маппинг API, границы ETL и ограничения для AI-ассистента.",
@@ -254,7 +251,7 @@ async function main() {
data: {
teamId: team.id,
contactId: c.id,
title: `${c.company ?? "Клиент"}: интеграция Odoo + AI`,
title: `${c.name}: интеграция Odoo + AI`,
stage: stages[idx % stages.length],
amount: 18000 + (idx % 8) * 7000,
nextStep: nextStepText,
@@ -327,7 +324,7 @@ async function main() {
contactId: c.id,
happenedAt: atOffset(-(idx % 6), 9 + (idx % 8), (idx * 9) % 60),
text:
`Я проверил активность по аккаунту ${c.company ?? c.name} в рамках сделки Odoo + AI. ` +
`Я проверил активность по аккаунту ${c.name} в рамках сделки Odoo + AI. ` +
"Есть достаточный импульс, чтобы перевести сделку на следующий этап при чётком следующем шаге.",
proposalJson: {
title: idx % 2 === 0 ? "Назначить созвон по рамкам пилота" : "Отправить сообщение для разблокировки у владельца бюджета",

View File

@@ -100,9 +100,6 @@ async function main() {
id: c.id,
teamId: c.teamId,
name: c.name,
company: c.company ?? null,
country: c.country ?? null,
location: c.location ?? null,
avatarUrl: c.avatarUrl ?? null,
email: c.email ?? null,
phone: c.phone ?? null,
@@ -155,7 +152,6 @@ async function main() {
contactIndex.push({
id: c.id,
name: c.name,
company: c.company ?? null,
lastMessageAt,
nextEventAt,
updatedAt: c.updatedAt,

View File

@@ -10,7 +10,6 @@ import type { ChangeSet } from "../utils/changeSet";
type ContactIndexRow = {
id: string;
name: string;
company: string | null;
lastMessageAt: string | null;
nextEventAt: string | null;
updatedAt: string;
@@ -108,9 +107,8 @@ async function readJsonl(p: string): Promise<any[]> {
}
function formatContactLine(c: ContactIndexRow) {
const company = c.company ? ` (${c.company})` : "";
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> {
@@ -227,7 +225,7 @@ export async function runCrmAgentFor(
lines.push("");
lines.push("Фокус дня (если нужно добить прогресс):");
for (const c of followups) {
lines.push(`- Написать follow-up: ${c.name}${c.company ? ` (${c.company})` : ""}`);
lines.push(`- Написать follow-up: ${c.name}`);
}
return {

View File

@@ -184,7 +184,7 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
orderBy: { updatedAt: "desc" },
take: 20,
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" }] },
},
}),
@@ -247,15 +247,11 @@ async function buildCrmSnapshot(input: SnapshotOptions) {
updatedAt: iso(d.updatedAt),
contact: {
name: d.contact.name,
company: d.contact.company,
},
})),
contacts: contacts.map((c) => ({
id: c.id,
name: c.name,
company: c.company,
country: c.country,
location: c.location,
email: c.email,
phone: c.phone,
avatarUrl: c.avatarUrl,
@@ -549,7 +545,6 @@ export async function runLangGraphCrmAgentFor(input: {
? {
OR: [
{ name: { contains: q } },
{ company: { contains: q } },
{ email: { contains: q } },
{ phone: { contains: q } },
],
@@ -593,9 +588,6 @@ export async function runLangGraphCrmAgentFor(input: {
items: items.map((c) => ({
id: c.id,
name: c.name,
company: c.company,
country: c.country,
location: c.location,
email: c.email,
phone: c.phone,
summary: c.note?.content ?? null,
@@ -711,9 +703,6 @@ export async function runLangGraphCrmAgentFor(input: {
contact: {
id: contact.id,
name: contact.name,
company: contact.company,
country: contact.country,
location: contact.location,
email: contact.email,
phone: contact.phone,
updatedAt: contact.updatedAt.toISOString(),
@@ -790,7 +779,7 @@ export async function runLangGraphCrmAgentFor(input: {
orderBy: { startsAt: "asc" },
skip: offset,
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,
name: e.contact.name,
company: e.contact.company,
}
: null,
})),

View File

@@ -95,9 +95,6 @@ export async function exportDatasetFromPrismaFor(input: { teamId: string; userId
id: c.id,
teamId: c.teamId,
name: c.name,
company: c.company ?? null,
country: c.country ?? null,
location: c.location ?? null,
avatarUrl: c.avatarUrl ?? null,
email: c.email ?? null,
phone: c.phone ?? null,
@@ -144,7 +141,6 @@ export async function exportDatasetFromPrismaFor(input: { teamId: string; userId
contactIndex.push({
id: c.id,
name: c.name,
company: c.company ?? null,
lastMessageAt,
nextEventAt,
updatedAt: c.updatedAt,

View File

@@ -509,9 +509,6 @@ async function getContacts(auth: AuthContext | null) {
id: c.id,
name: c.name,
avatar: c.avatarUrl ?? "",
company: c.company ?? "",
country: c.country ?? "",
location: c.location ?? "",
channels: Array.from(channelsByContactId.get(c.id) ?? []),
lastContactAt: c.messages[0]?.occurredAt?.toISOString?.() ?? c.updatedAt.toISOString(),
description: c.note?.content ?? "",
@@ -706,7 +703,7 @@ async function getDeals(auth: AuthContext | null) {
const dealsRaw = await prisma.deal.findMany({
where: { teamId: ctx.teamId },
include: {
contact: { select: { name: true, company: true } },
contact: { select: { name: true } },
steps: { orderBy: [{ order: "asc" }, { createdAt: "asc" }] },
},
orderBy: { updatedAt: "desc" },
@@ -717,7 +714,6 @@ async function getDeals(auth: AuthContext | null) {
id: d.id,
contact: d.contact.name,
title: d.title,
company: d.contact.company ?? "",
stage: d.stage,
amount: d.amount ? String(d.amount) : "",
nextStep: d.nextStep ?? "",
@@ -1999,9 +1995,6 @@ export const crmGraphqlSchema = buildSchema(`
id: ID!
name: String!
avatar: String!
company: String!
country: String!
location: String!
channels: [String!]!
lastContactAt: String!
description: String!
@@ -2054,7 +2047,6 @@ export const crmGraphqlSchema = buildSchema(`
id: ID!
contact: String!
title: String!
company: String!
stage: String!
amount: String!
nextStep: String!

View File

@@ -116,9 +116,6 @@ model Contact {
id String @id @default(cuid())
teamId String
name String
company String?
country String?
location String?
avatarUrl String?
email String?
phone String?

View File

@@ -226,9 +226,6 @@ async function resolveContact(input: {
teamId: input.teamId,
name: input.profile.displayName,
avatarUrl: input.profile.avatarUrl,
company: null,
country: null,
location: null,
},
select: { id: true },
});

View File

@@ -116,9 +116,6 @@ model Contact {
id String @id @default(cuid())
teamId String
name String
company String?
country String?
location String?
avatarUrl String?
email String?
phone String?