mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-28 16:06:41 +01:00
type narrowing/cleanup
This commit is contained in:
@@ -12,7 +12,7 @@ import CircularProgress from "@material-ui/core/CircularProgress";
|
||||
// TODO: multi support
|
||||
|
||||
interface Props {
|
||||
value: any;
|
||||
value: { name: string; downloadURL: string }[];
|
||||
row: { ref: firebase.firestore.DocumentReference; id: string };
|
||||
onSubmit: Function;
|
||||
fieldType: FieldType;
|
||||
|
||||
@@ -5,7 +5,7 @@ import MuiRating from "@material-ui/lab/Rating";
|
||||
|
||||
interface Props {
|
||||
value: number;
|
||||
row: any;
|
||||
row: { id: string };
|
||||
onSubmit: Function;
|
||||
isScrolling: boolean;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { createStyles, makeStyles } from "@material-ui/core/styles";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import ClickAwayListener from "@material-ui/core/ClickAwayListener";
|
||||
|
||||
import algoliasearch from "algoliasearch/lite";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
|
||||
@@ -94,7 +94,6 @@ const SearchBox = (props: Props) => {
|
||||
|
||||
const open = Boolean(collection);
|
||||
const id = open ? "no-transition-popper" : undefined;
|
||||
const onClickAway = (event: any) => {};
|
||||
const Hit = (hit: any) => (
|
||||
<ListItem
|
||||
button
|
||||
@@ -128,7 +127,7 @@ const SearchBox = (props: Props) => {
|
||||
aria-describedby="transition-modal-description"
|
||||
className={classes.modal}
|
||||
open={open}
|
||||
onClose={(event: any, reason: any) => {
|
||||
onClose={() => {
|
||||
clear();
|
||||
}}
|
||||
closeAfterTransition
|
||||
|
||||
@@ -24,7 +24,7 @@ const useTableConfig = (tablePath: string) => {
|
||||
loading: true,
|
||||
});
|
||||
};
|
||||
const add = (name: string, type: FieldType, data?: any) => {
|
||||
const add = (name: string, type: FieldType, data?: unknown) => {
|
||||
//TODO: validation
|
||||
const { columns } = tableConfigState;
|
||||
const key = _camelCase(name);
|
||||
@@ -38,9 +38,10 @@ const useTableConfig = (tablePath: string) => {
|
||||
columns[index].width = width;
|
||||
documentDispatch({ action: DocActions.update, data: { columns } });
|
||||
};
|
||||
const updateColumn = (index: number, updatables: any) => {
|
||||
type updatable = { field: string; value: unknown };
|
||||
const updateColumn = (index: number, updatables: updatable[]) => {
|
||||
const { columns } = tableConfigState;
|
||||
updatables.forEach((updatable: any) => {
|
||||
updatables.forEach((updatable: updatable) => {
|
||||
columns[index][updatable.field] = updatable.value;
|
||||
});
|
||||
documentDispatch({ action: DocActions.update, data: { columns } });
|
||||
@@ -62,7 +63,7 @@ const useTableConfig = (tablePath: string) => {
|
||||
data: { columns: reorderedColumns },
|
||||
});
|
||||
};
|
||||
const updateConfig = (key: string, value: any) => {
|
||||
const updateConfig = (key: string, value: unknown) => {
|
||||
documentDispatch({
|
||||
action: DocActions.update,
|
||||
data: { [key]: value },
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
import { useEffect, useState } from "react";
|
||||
function useKeyCode(keyCode: number) {
|
||||
const [isPressed, setKeyPressed] = useState(false);
|
||||
// Only allow fetching each keypress event once to prevent infinite loops
|
||||
const clear = () => {
|
||||
if (isPressed) {
|
||||
setKeyPressed(false);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
function downHandler(event: any) {
|
||||
if (event.keyCode === keyCode) {
|
||||
setKeyPressed(true);
|
||||
}
|
||||
}
|
||||
window.addEventListener("keydown", downHandler);
|
||||
return () => window.removeEventListener("keydown", downHandler);
|
||||
}, [keyCode]);
|
||||
|
||||
return { isPressed, clear };
|
||||
}
|
||||
export default useKeyCode;
|
||||
Reference in New Issue
Block a user