diff --git a/README.md b/README.md index 25942ce3..7928d225 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ set environment variables firebase functions:config:set algolia.app=YOUR_APP_ID algolia.key=ADMIN_API_KEY ``` -deploy update and delete algolia records +deploy the following callable cloud functions to update and delete algolia records ``` const functions = require("firebase-functions"); diff --git a/src/components/Table/ColumnEditor/DocInput.tsx b/src/components/Table/ColumnEditor/DocInput.tsx index d8bd17b8..794440cf 100644 --- a/src/components/Table/ColumnEditor/DocInput.tsx +++ b/src/components/Table/ColumnEditor/DocInput.tsx @@ -33,19 +33,6 @@ const useStyles = makeStyles(Theme => }) ); -const names = [ - "Oliver Hansen", - "Van Henry", - "April Tucker", - "Ralph Hubbard", - "Omar Alexander", - "Carlos Abbott", - "Miriam Wagner", - "Bradley Wilkerson", - "Virginia Andrews", - "Kelly Snyder", -]; - const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { @@ -60,24 +47,40 @@ const MenuProps = { export default function DocInput(props: any) { const { collectionPath, setValue } = props; const [tableConfig, tableConfigActions] = useTableConfig(collectionPath); - useEffect(() => { - tableConfigActions.setTable(collectionPath); - }, [collectionPath]); + + const [columns, setColumns] = React.useState<{ key: string; name: string }[]>( + [] + ); const [primaryKeys, setPrimaryKeys] = React.useState([]); const [secondaryKeys, setSecondaryKeys] = React.useState([]); + useEffect(() => { + console.log(tableConfig); + setColumns(tableConfig.columns); + }, [tableConfig.columns]); + const classes = useStyles(); const tables = useContext(TablesContext); const onChange = (e: any, v: any) => { setValue("collectionPath", v.props.value); + setPrimaryKeys([]); + setSecondaryKeys([]); + setColumns([]); + tableConfigActions.setTable(v.props.value); }; - + useEffect(() => { + setValue("resultsConfig", { + primaryKeys, + secondaryKeys, + }); + }, [primaryKeys, secondaryKeys]); if (tables.value) return ( <> ) => { setPrimaryKeys(event.target.value as string[]); }} - input={} + input={} renderValue={selected => (
{(selected as string[]).map(value => ( @@ -112,22 +117,31 @@ export default function DocInput(props: any) { )} MenuProps={MenuProps} > - {names.map(name => ( - - {name} - - ))} + {columns && + columns.length !== 0 && + columns.map(column => ( + + {column.name} + + ))} + - Primary Text + + Secondary Text + } + input={} renderValue={selected => (
{(selected as string[]).map(value => ( @@ -137,11 +151,17 @@ export default function DocInput(props: any) { )} MenuProps={MenuProps} > - {names.map(name => ( - - {name} - - ))} + {columns && + columns.length !== 0 && + columns.map(column => ( + + {column.name} + + ))}