From 2da30d3d3003ce6cb5a53d7b91dec6dc28605954 Mon Sep 17 00:00:00 2001 From: Giorgi Rostomashvili Date: Fri, 19 Sep 2025 17:47:06 +0200 Subject: [PATCH] Revert "Upgrade to use Record Combobox" --- package-lock.json | 8 ++--- package.json | 2 +- .../comboboxes/companies-combobox.tsx | 16 +++++++-- .../comboboxes/companies-options-provider.ts | 33 +++++++++++++++++++ .../log-customer-request-dialog.tsx | 27 ++++++--------- 5 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 src/components/comboboxes/companies-options-provider.ts diff --git a/package-lock.json b/package-lock.json index bf33cda..d832ba9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.1", "dependencies": { "@tanstack/react-query": "^5.83.0", - "attio": "0.0.1-experimental.20250915", + "attio": "0.0.1-experimental.20250829.2", "event-target-polyfill": "^0.0.4", "match-sorter": "8.0.3", "react": "19.0.0", @@ -1285,9 +1285,9 @@ "license": "MIT" }, "node_modules/attio": { - "version": "0.0.1-experimental.20250915", - "resolved": "https://registry.npmjs.org/attio/-/attio-0.0.1-experimental.20250915.tgz", - "integrity": "sha512-4JsriW3ZAdoF6R9UPxC6dIVg2qlbnIBmeeuGoI8cPYJYHuEZQhTctH8ViivPAyvSQhxF6lExPOx+u299FAtC1Q==", + "version": "0.0.1-experimental.20250829.2", + "resolved": "https://registry.npmjs.org/attio/-/attio-0.0.1-experimental.20250829.2.tgz", + "integrity": "sha512-Glb7GSplL8RuPgCxZZptdseUqORoqO6dINsP1wJJ6iFqLqYbGSA+ArQxFEUMLKrx2DtPRCCHgEYwrYApcSXBCQ==", "dependencies": { "@attio/fetchable-npm": "npm:@attio/fetchable@0.0.1-experimental.4", "@babel/code-frame": "^7.27.1", diff --git a/package.json b/package.json index f108b75..86e105f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "dependencies": { "@tanstack/react-query": "^5.83.0", - "attio": "0.0.1-experimental.20250915", + "attio": "0.0.1-experimental.20250829.2", "event-target-polyfill": "^0.0.4", "match-sorter": "8.0.3", "react": "19.0.0", diff --git a/src/components/comboboxes/companies-combobox.tsx b/src/components/comboboxes/companies-combobox.tsx index 009225b..9902c67 100644 --- a/src/components/comboboxes/companies-combobox.tsx +++ b/src/components/comboboxes/companies-combobox.tsx @@ -1,21 +1,31 @@ import type {FormApi} from "attio/client" import type {LogCustomerRequestFormSchema} from "../log-customer-request-dialog" +import {companiesProvider} from "./companies-options-provider" export function CompaniesCombobox({ Combobox, companyId, }: { - Combobox: FormApi["Experimental_RecordCombobox"] + Combobox: FormApi["Combobox"] companyId?: string }) { if (companyId) { - return + return ( + + ) } return ( diff --git a/src/components/comboboxes/companies-options-provider.ts b/src/components/comboboxes/companies-options-provider.ts new file mode 100644 index 0000000..2a9439d --- /dev/null +++ b/src/components/comboboxes/companies-options-provider.ts @@ -0,0 +1,33 @@ +import {type DecoratedComboboxOptionsProvider, runQuery} from "attio/client" +import GetCompanyByCompanyId from "../../graphql/get-company-by-id.graphql" +import SearchCompanies from "../../graphql/search-companies.graphql" + +export const companiesProvider: DecoratedComboboxOptionsProvider = { + async getOption(recordId) { + const result = await runQuery(GetCompanyByCompanyId, {companyId: recordId}) + return result?.company + ? result.company.logo_url + ? { + label: result.company.name || "Unnamed Company", + description: result.company.domains[0], + avatarUrl: result.company.logo_url, + } + : { + label: result.company.name || "Unnamed Company", + description: result.company.domains[0], + icon: "Company" as const, + } + : undefined + }, + + async search(query: string) { + const results = await runQuery(SearchCompanies, {query}) + + return results.experimental_searchCompanies.map((company) => ({ + label: company.name || company.domains[0] || "", + value: company.id, + description: company.domains[0], + ...(company.logo_url ? {avatarUrl: company.logo_url} : {icon: "Company"}), + })) + }, +} diff --git a/src/components/log-customer-request-dialog.tsx b/src/components/log-customer-request-dialog.tsx index 7a2d3bc..51850b1 100644 --- a/src/components/log-customer-request-dialog.tsx +++ b/src/components/log-customer-request-dialog.tsx @@ -33,22 +33,15 @@ export function LogCustomerRequestDialog({ attachmentUrl?: string onDone: () => void }) { - const { - Form, - TextInput, - SubmitButton, - Combobox, - Experimental_RichTextInput, - WithState, - Experimental_RecordCombobox, - } = useForm(formSchema, { - companyRecordId, - description, - addTo: "", - title: "", - team: "", - attachmentUrl, - }) + const {Form, TextInput, SubmitButton, Combobox, Experimental_RichTextInput, WithState} = + useForm(formSchema, { + companyRecordId, + description, + addTo: "", + title: "", + team: "", + attachmentUrl, + }) return (
{ @@ -96,7 +89,7 @@ export function LogCustomerRequestDialog({ } }} > - +