2
0

feat(editor): ️ Show Google Sheets detail

This commit is contained in:
Baptiste Arnaud
2022-04-11 12:59:00 -05:00
parent 18206866b8
commit 4a2c6627c3
6 changed files with 44 additions and 53 deletions

View File

@ -18,7 +18,7 @@ export const CellWithValueStack = ({
onItemChange({ ...item, value })
}
return (
<Stack p="4" rounded="md" flex="1" borderWidth="1px">
<Stack p="4" rounded="md" flex="1" borderWidth="1px" w="full">
<DropdownList<string>
currentItem={item.column}
onItemSelect={handleColumnSelect}

View File

@ -125,7 +125,7 @@ export const GoogleSheetsSettingsBody = ({
/>
</>
)}
{sheet && 'action' in options && (
{'action' in options && (
<ActionOptions
options={options}
sheet={sheet}
@ -145,7 +145,7 @@ const ActionOptions = ({
| GoogleSheetsGetOptions
| GoogleSheetsInsertRowOptions
| GoogleSheetsUpdateRowOptions
sheet: Sheet
sheet?: Sheet
onOptionsChange: (options: GoogleSheetsOptions) => void
}) => {
const handleInsertColumnsChange = (cellsToInsert: Cell[]) =>
@ -162,14 +162,14 @@ const ActionOptions = ({
const UpdatingCellItem = useMemo(
() => (props: TableListItemProps<Cell>) =>
<CellWithValueStack {...props} columns={sheet.columns} />,
[sheet.columns]
<CellWithValueStack {...props} columns={sheet?.columns ?? []} />,
[sheet?.columns]
)
const ExtractingCellItem = useMemo(
() => (props: TableListItemProps<ExtractingCell>) =>
<CellWithVariableIdStack {...props} columns={sheet.columns} />,
[sheet.columns]
<CellWithVariableIdStack {...props} columns={sheet?.columns ?? []} />,
[sheet?.columns]
)
switch (options.action) {
@ -187,7 +187,7 @@ const ActionOptions = ({
<Stack>
<Text>Row to select</Text>
<CellWithValueStack
columns={sheet.columns}
columns={sheet?.columns ?? []}
item={options.referenceCell ?? { id: 'reference' }}
onItemChange={handleReferenceCellChange}
/>
@ -205,7 +205,7 @@ const ActionOptions = ({
<Stack>
<Text>Row to select</Text>
<CellWithValueStack
columns={sheet.columns}
columns={sheet?.columns ?? []}
item={options.referenceCell ?? { id: 'reference' }}
onItemChange={handleReferenceCellChange}
/>

View File

@ -1,4 +1,4 @@
import { Input, Tooltip, useToast } from '@chakra-ui/react'
import { Input, Tooltip } from '@chakra-ui/react'
import { SearchableDropdown } from 'components/shared/SearchableDropdown'
import { useMemo } from 'react'
import { useSpreadsheets } from 'services/integrations'
@ -14,15 +14,8 @@ export const SpreadsheetsDropdown = ({
spreadsheetId,
onSelectSpreadsheetId,
}: Props) => {
const toast = useToast({
position: 'top-right',
status: 'error',
})
const { spreadsheets, isLoading } = useSpreadsheets({
credentialsId,
onError: (e) =>
!toast.isActive('spreadsheets') &&
toast({ id: 'spreadsheets', title: e.name, description: e.message }),
})
const currentSpreadsheet = useMemo(
() => spreadsheets?.find((s) => s.id === spreadsheetId),