diff --git a/libs/features/query/src/QueryResults/QueryResultsCopyToClipboard.tsx b/libs/features/query/src/QueryResults/QueryResultsCopyToClipboard.tsx index 00544156..690f4179 100644 --- a/libs/features/query/src/QueryResults/QueryResultsCopyToClipboard.tsx +++ b/libs/features/query/src/QueryResults/QueryResultsCopyToClipboard.tsx @@ -1,6 +1,6 @@ import { ANALYTICS_KEYS } from '@jetstream/shared/constants'; import { copyRecordsToClipboard } from '@jetstream/shared/ui-utils'; -import { Maybe, SalesforceRecord } from '@jetstream/types'; +import { CopyAsDataType, Maybe, SalesforceRecord } from '@jetstream/types'; import { ButtonGroupContainer, DropDown, Icon, Modal, Radio, RadioGroup, Tooltip } from '@jetstream/ui'; import { useAmplitude } from '@jetstream/ui-core'; import classNames from 'classnames'; @@ -29,7 +29,7 @@ export const QueryResultsCopyToClipboard: FunctionComponent { const { trackEvent } = useAmplitude(); const [isModalOpen, setIsModalOpen] = useState(false); - const [format, setFormat] = useState<'excel' | 'json'>('excel'); + const [format, setFormat] = useState('excel'); const [whichRecords, setWhichRecords] = useState('all'); const [hasFilteredRows, setHasFilteredRows] = useState(false); const [hasPartialSelectedRows, setHasPartialSelectedRows] = useState(false); @@ -50,7 +50,7 @@ export const QueryResultsCopyToClipboard: FunctionComponent handleCopyToClipboard(item as 'excel' | 'json')} + items={[ + { id: 'csv', value: 'Copy as CSV' }, + { id: 'json', value: 'Copy as JSON' }, + ]} + onSelected={(item) => handleCopyToClipboard(item as CopyAsDataType)} /> {isModalOpen && ( diff --git a/libs/shared/ui-core/src/record/ViewEditCloneRecord.tsx b/libs/shared/ui-core/src/record/ViewEditCloneRecord.tsx index ed52985f..06ed3c0c 100644 --- a/libs/shared/ui-core/src/record/ViewEditCloneRecord.tsx +++ b/libs/shared/ui-core/src/record/ViewEditCloneRecord.tsx @@ -10,6 +10,7 @@ import { BulkDownloadJob, ChildRelationship, CloneEditView, + CopyAsDataType, ErrorResult, Field, FileExtCsvXLSXJsonGSheet, @@ -371,8 +372,8 @@ export const ViewEditCloneRecord: FunctionComponent = subqueryFields: Object.keys(record) .filter((field) => field !== 'attributes') .reduce((acc, field) => { - if (record[field] && isObject(record[field]) && Array.isArray(record[field]?.records)) { - const firstRecord = record[field]?.records?.[0] || {}; + if (record[field] && isObject(record[field]) && Array.isArray((record[field] as any)?.records)) { + const firstRecord = (record[field] as any)?.records?.[0] || {}; acc[field] = Object.keys(firstRecord) .filter((field) => field !== 'attributes') .map((field) => { @@ -436,7 +437,7 @@ export const ViewEditCloneRecord: FunctionComponent = }); } - function handleCopyToClipboard(format: 'excel' | 'json' = 'excel') { + function handleCopyToClipboard(format: CopyAsDataType = 'excel') { if (!initialRecord) { return; } @@ -602,8 +603,11 @@ export const ViewEditCloneRecord: FunctionComponent = className="slds-button_last" dropDownClassName="slds-dropdown_actions" position="right" - items={[{ id: 'json', value: 'Copy as JSON' }]} - onSelected={(item) => handleCopyToClipboard(item as 'excel' | 'json')} + items={[ + { id: 'csv', value: 'Copy as CSV' }, + { id: 'json', value: 'Copy as JSON' }, + ]} + onSelected={(item) => handleCopyToClipboard(item as CopyAsDataType)} />