diff --git a/www/src/components/Wizards/Cell.tsx b/www/src/components/Wizards/Cell.tsx
index aa022f8a..1d75dccc 100644
--- a/www/src/components/Wizards/Cell.tsx
+++ b/www/src/components/Wizards/Cell.tsx
@@ -3,7 +3,7 @@ import React from "react";
import { makeStyles, createStyles } from "@material-ui/core";
import { FieldType } from "constants/fields";
-//import { getFormatter } from "components/Table/formatters";
+import { getFieldProp } from "components/fields";
import EmptyState from "components/EmptyState";
const useStyles = makeStyles((theme) =>
@@ -68,8 +68,7 @@ export default function Cell({
...props
}: ICellProps) {
const classes = useStyles();
- const formatter = null;
- //const formatter = type ? getFormatter({ type: type }, true) : null;
+ const formatter = type ? getFieldProp("TableCell", type) : null;
return (
@@ -83,6 +82,7 @@ export default function Cell({
key: field,
name,
config: { options: [] },
+ editable: false,
} as any,
row: { [field]: value },
isRowSelected: false,
diff --git a/www/src/components/Wizards/ImportCsvWizard/index.tsx b/www/src/components/Wizards/ImportCsvWizard/index.tsx
index 71140fb6..85cd13c9 100644
--- a/www/src/components/Wizards/ImportCsvWizard/index.tsx
+++ b/www/src/components/Wizards/ImportCsvWizard/index.tsx
@@ -20,6 +20,7 @@ import Step3Preview from "./Step3Preview";
import { ColumnConfig } from "hooks/useFiretable/useTableConfig";
import { useFiretableContext } from "contexts/FiretableContext";
import { FieldType } from "constants/fields";
+import { useSnackContext } from "contexts/SnackContext";
export type CsvConfig = {
pairs: { csvKey: string; columnKey: string }[];
@@ -52,6 +53,7 @@ export default function ImportCsvWizard({
const [open, setOpen] = useState(true);
const { tableState, tableActions } = useFiretableContext();
+ const { open: openSnackbar } = useSnackContext();
const [config, setConfig] = useState({
pairs: [],
@@ -67,14 +69,9 @@ export default function ImportCsvWizard({
const handleFinish = () => {
if (!tableState || !tableActions || !csvData) return;
- // Add any new columns to the end
- config.newColumns.forEach((col) =>
- setTimeout(() => {
- tableActions.column.add(col.name, col.type, col);
- })
- );
- // Add all new rows
- csvData.rows.forEach((row) => {
+ openSnackbar({ message: "Importing data…" });
+ // Add all new rows — synchronous
+ for (const row of csvData.rows) {
const newRow = config.pairs.reduce((a, pair) => {
const matchingColumn =
tableState.columns[pair.columnKey] ??
@@ -87,7 +84,11 @@ export default function ImportCsvWizard({
return { ...a, [pair.columnKey]: value };
}, {});
tableActions.row.add(newRow);
- });
+ }
+ // Add any new columns to the end
+ for (const col of config.newColumns) {
+ tableActions.column.add(col.name, col.type, col);
+ }
// Close wizard
setOpen(false);
setTimeout(handleClose, 300);
diff --git a/www/src/components/fields/LongText/index.tsx b/www/src/components/fields/LongText/index.tsx
index aac3d879..eb712903 100644
--- a/www/src/components/fields/LongText/index.tsx
+++ b/www/src/components/fields/LongText/index.tsx
@@ -18,7 +18,7 @@ const SideDrawerField = lazy(
export const config: IFieldConfig = {
type: FieldType.longText,
- name: "Short Text",
+ name: "Long Text",
dataType: "string",
initialValue: "",
initializable: true,
diff --git a/www/src/hooks/useFiretable/useTable.tsx b/www/src/hooks/useFiretable/useTable.tsx
index 06027607..070897ef 100644
--- a/www/src/hooks/useFiretable/useTable.tsx
+++ b/www/src/hooks/useFiretable/useTable.tsx
@@ -238,8 +238,8 @@ const useTable = (initialOverrides: any) => {
const docData = {
...valuesFromFilter,
- createdAt: serverTimestamp(),
- updatedAt: serverTimestamp(),
+ _ft_createdAt: serverTimestamp(),
+ _ft_updatedAt: serverTimestamp(),
...data,
};
try {
diff --git a/www/src/hooks/useFiretable/useTableConfig.ts b/www/src/hooks/useFiretable/useTableConfig.ts
index 1a618708..a98a801a 100644
--- a/www/src/hooks/useFiretable/useTableConfig.ts
+++ b/www/src/hooks/useFiretable/useTableConfig.ts
@@ -54,10 +54,11 @@ const useTableConfig = (tablePath?: string) => {
const addColumn = (name: string, type: FieldType, data?: any) => {
//TODO: validation
const { columns } = tableConfigState;
- const newIndex = Object.keys(columns).length;
- let updatedColumns = columns;
+ const newIndex = Object.keys(columns).length ?? 0;
+ let updatedColumns = { ...columns };
const key = _camelCase(name);
updatedColumns[key] = { name, key, type, ...data, index: newIndex ?? 0 };
+ console.log(name, type, data, updatedColumns);
documentDispatch({
action: DocActions.update,
data: { columns: updatedColumns },