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>