diff --git a/src/components/Fields/DateTime.tsx b/src/components/Fields/DateTime.tsx
deleted file mode 100644
index 487ee1d1..00000000
--- a/src/components/Fields/DateTime.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import React from "react";
-import "date-fns";
-import DateFnsUtils from "@date-io/date-fns";
-import {
- MuiPickersUtilsProvider,
- // KeyboardTimePicker,
- // KeyboardDatePicker,
- DateTimePicker
-} from "@material-ui/pickers";
-import Button from "@material-ui/core/Button";
-
-const DateTime = (props: any) => {
- const {
- isFocusedCell,
- columnData,
- cellData,
- cellActions,
- rowData,
- rowIndex
- } = props;
- function handleDateChange(date: Date | null) {
- if (date) {
- const cell = {
- rowIndex,
- value: date,
- docRef: rowData.ref,
- fieldName: columnData.fieldName
- };
- cellActions.updateFirestore(cell);
- }
- }
- if (!cellData && !isFocusedCell) return ;
- else
- return (
-
-
-
- );
-};
-export default DateTime;
diff --git a/src/components/Fields/Number.tsx b/src/components/Fields/Number.tsx
index 88278fa0..ff693937 100644
--- a/src/components/Fields/Number.tsx
+++ b/src/components/Fields/Number.tsx
@@ -1,18 +1,15 @@
import React from "react";
import TextField from "@material-ui/core/TextField";
const Number = (props: any) => {
- const { isFocusedCell, cellData, cellActions } = props;
- if (isFocusedCell)
- return (
- {
- cellActions.update(e.target.value);
- }}
- />
- );
- else return {cellData}
;
+ const { value, cellActions } = props;
+ return (
+ {}}
+ />
+ );
+ // else return {cellData}
;
};
export default Number;
diff --git a/src/components/OldTable.tsx b/src/components/OldTable.tsx
deleted file mode 100644
index 26793a4e..00000000
--- a/src/components/OldTable.tsx
+++ /dev/null
@@ -1,260 +0,0 @@
-import React, { useEffect } from "react";
-import clsx from "clsx";
-import {
- createStyles,
- Theme,
- withStyles,
- WithStyles
-} from "@material-ui/core/styles";
-import { TableCell as MuiTableCell } from "@material-ui/core";
-import Paper from "@material-ui/core/Paper";
-import {
- AutoSizer,
- Column,
- Table as MuiTable,
- TableCellRenderer,
- TableHeaderProps
-} from "react-virtualized";
-import Button from "@material-ui/core/Button";
-
-import { FieldType, getFieldIcon } from "./Fields";
-import ColumnDrawer from "./ColumnDrawer";
-import TableCell from "../components/TableCell";
-
-import useCell, { Cell } from "../hooks/useFiretable/useCell";
-import useFiretable from "../hooks/useFiretable";
-
-const styles = (theme: Theme) =>
- createStyles({
- flexContainer: {
- display: "flex",
- alignItems: "center",
- boxSizing: "border-box"
- },
- tableRow: {
- cursor: "pointer"
- },
- tableRowHover: {
- "&:hover": {
- backgroundColor: theme.palette.grey[200]
- }
- },
- tableCell: {
- flex: 1
- },
- noClick: {
- cursor: "initial"
- }
- });
-
-interface ColumnData {
- columnData: any;
- dataKey: string;
- label: string;
- numeric?: boolean;
- width: number;
-}
-
-interface Row {
- index: number;
-}
-
-interface MuiVirtualizedTableProps extends WithStyles {
- columns: ColumnData[];
- focusedCell: Cell | null;
- cellActions: any;
- headerHeight?: number;
- onRowClick?: () => void;
- rowCount: number;
- rowGetter: (row: Row) => any;
- rowHeight?: number;
-}
-
-class MuiVirtualizedTable extends React.PureComponent<
- MuiVirtualizedTableProps
-> {
- static defaultProps = {
- headerHeight: 48,
- rowHeight: 40
- };
-
- getRowClassName = ({ index }: Row) => {
- const { classes, onRowClick } = this.props;
-
- return clsx(classes.tableRow, classes.flexContainer, {
- [classes.tableRowHover]: index !== -1 && onRowClick != null
- });
- };
-
- cellRenderer: TableCellRenderer = ({
- cellData,
- columnData,
- columnIndex,
- dataKey,
- isScrolling,
- rowData,
- rowIndex
- }) => {
- const {
- columns,
- classes,
- rowHeight,
- onRowClick,
- cellActions,
- focusedCell
- } = this.props;
- const fieldType = columnData.fieldType;
- return (
-
- );
- };
- headerRenderer = ({
- label,
- columnData,
- dataKey,
- columnIndex
- }: TableHeaderProps & { columnIndex: number }) => {
- const { headerHeight, columns, classes } = this.props;
-
- return (
-
- {dataKey === "add" ? (
-
- ) : (
-
- )}
-
- );
- };
-
- render() {
- const {
- classes,
- columns,
- rowHeight,
- headerHeight,
- ...tableProps
- } = this.props;
- return (
-
- {({ height, width }) => (
- <>
-
- {[
- ...columns.map(({ dataKey, ...other }, index) => {
- return (
-
- this.headerRenderer({
- ...headerProps,
- columnIndex: index
- })
- }
- className={classes.flexContainer}
- cellRenderer={this.cellRenderer}
- dataKey={dataKey}
- {...other}
- />
- );
- })
- ]}
-
- >
- )}
-
- );
- }
-}
-
-const VirtualizedTable = withStyles(styles)(MuiVirtualizedTable);
-
-export default function Table(props: any) {
- const { collection } = props;
- const { tableState, tableActions } = useFiretable(collection);
-
- useEffect(() => {
- tableActions.table.set(collection);
- }, [collection]);
-
- if (tableState.columns)
- return (
- <>
-
- tableState.rows[index]}
- columns={[
- ...tableState.columns.map(
- (column: {
- fieldName: string;
- columnName: string;
- type: FieldType;
- }) => ({
- width: 200,
- label: column.columnName,
- dataKey: column.fieldName,
- columnData: {
- fieldType: column.type,
- fieldName: column.fieldName,
- actions: {}
- }
- })
- ),
- {
- width: 80,
- label: "add",
- dataKey: "add",
- columnData: {
- fieldType: "DELETE",
- actions: {
- addColumn: tableActions.column.add,
- deleteRow: tableActions.row.delete
- }
- }
- }
- ]}
- />
-
-
- >
- );
- else return <>insert loading Skeleton here>;
-}
diff --git a/src/components/TableCell.tsx b/src/components/TableCell.tsx
deleted file mode 100644
index 58250e90..00000000
--- a/src/components/TableCell.tsx
+++ /dev/null
@@ -1,154 +0,0 @@
-import React, { useState } from "react";
-import { TableCell as MuiTableCell, Switch } from "@material-ui/core";
-import clsx from "clsx";
-import { FieldType } from "./Fields";
-
-import IconButton from "@material-ui/core/IconButton";
-import DeleteIcon from "@material-ui/icons/Delete";
-
-import SimpleText from "./Fields/SimpleText";
-import CheckBox from "./Fields/CheckBox";
-
-import Number from "./Fields/Number";
-import Rating from "./Fields/Rating";
-import Date from "./Fields/Date";
-import DateTime from "./Fields/DateTime";
-import Image from "./Fields/Image";
-
-const TableCell = (props: any) => {
- const {
- fieldType,
- rowIndex,
- rowData,
- columnData,
- classes,
- cellActions,
- cellData,
- onRowClick,
- rowHeight,
- columnIndex,
- columns,
- focusedCell
- } = props;
- const isFocusedCell =
- focusedCell &&
- focusedCell.fieldName === columnData.fieldName &&
- focusedCell.rowIndex === rowIndex;
-
- const renderCell = () => {
- switch (fieldType) {
- case FieldType.checkBox:
- return (
-
- );
- case FieldType.rating:
- return (
-
- );
- case FieldType.image:
- return (
-
- );
- case FieldType.date:
- return (
-
- );
- case FieldType.dateTime:
- return (
-
- );
- case FieldType.number:
- return (
-
- );
- default:
- return (
-
- );
- }
- };
- if (fieldType === "DELETE")
- return (
- {
- columnData.actions.deleteRow(rowIndex, rowData.id);
- }}
- >
-
-
- );
-
- return (
- {
- // set focusedCell on click
- cellActions.set({
- rowIndex,
- docRef: rowData.ref,
- fieldName: columnData.fieldName,
- value: cellData
- });
- }}
- style={{ height: rowHeight }}
- align={
- (columnIndex != null && columns[columnIndex].numeric) || false
- ? "right"
- : "left"
- }
- >
- {renderCell()}
-
- );
-};
-export default TableCell;