mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
rows created and orderedby createdAt TS
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { db } from "../firebase";
|
||||
|
||||
import { useEffect, useReducer } from "react";
|
||||
import equals from "ramda/es/equals";
|
||||
import { Cell } from "./useCell";
|
||||
import firebase from "firebase/app";
|
||||
const CAP = 500;
|
||||
|
||||
const tableReducer = (prevState: any, newProps: any) => {
|
||||
@@ -28,6 +30,7 @@ const tableIntialState = {
|
||||
prevLimit: 0,
|
||||
limit: 20,
|
||||
loading: true,
|
||||
sort: { field: "createdAt", direction: "asc" },
|
||||
cap: CAP
|
||||
};
|
||||
|
||||
@@ -144,7 +147,9 @@ const useTable = (intialOverrides: any) => {
|
||||
.update({ [cell.fieldName]: cell.value });
|
||||
};
|
||||
const addRow = () => {
|
||||
db.collection(tableState.path).add({});
|
||||
db.collection(tableState.path).add({
|
||||
createdAt: firebase.firestore.FieldValue.serverTimestamp()
|
||||
});
|
||||
};
|
||||
const tableActions = { deleteRow, setTable, updateCell, addRow };
|
||||
return [tableState, tableActions];
|
||||
|
||||
Reference in New Issue
Block a user