From 7f6dc8cef7fe0841793749cc2758dd42a2ffde7e Mon Sep 17 00:00:00 2001 From: shams mosowi Date: Mon, 23 Sep 2019 07:39:06 +1000 Subject: [PATCH] added some prop interfaces --- src/components/Fields/CheckBox.tsx | 10 ++++++++-- src/components/Fields/Date.tsx | 9 ++++++++- src/components/Fields/Image.tsx | 13 ++++++++++++- src/components/Fields/LongText.tsx | 6 ++++++ src/components/Fields/UrlLink.tsx | 7 +++++-- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/components/Fields/CheckBox.tsx b/src/components/Fields/CheckBox.tsx index e26fa6e7..a40919b8 100644 --- a/src/components/Fields/CheckBox.tsx +++ b/src/components/Fields/CheckBox.tsx @@ -3,12 +3,18 @@ import React from "react"; import { Checkbox } from "@material-ui/core"; // TODO: Create an interface for props -const CheckBox = (props: any) => { +interface Props { + value: boolean | null; + row: any; + onSubmit: Function; +} + +const CheckBox = (props: Props) => { const { value, row, onSubmit } = props; return ( { onSubmit(row.ref, !value); }} diff --git a/src/components/Fields/Date.tsx b/src/components/Fields/Date.tsx index 98fff0c6..0815f3a9 100644 --- a/src/components/Fields/Date.tsx +++ b/src/components/Fields/Date.tsx @@ -11,7 +11,14 @@ import { } from "@material-ui/pickers"; // TODO: Create an interface for props -const Date = (props: any) => { +interface Props { + value: firebase.firestore.Timestamp | null; + row: any; + onSubmit: Function; + fieldType: FieldType; +} + +const Date = (props: Props) => { const { value, row, onSubmit, fieldType } = props; function handleDateChange(date: Date | null) { if (date) { diff --git a/src/components/Fields/Image.tsx b/src/components/Fields/Image.tsx index 08dd5c1e..179244d7 100644 --- a/src/components/Fields/Image.tsx +++ b/src/components/Fields/Image.tsx @@ -2,8 +2,19 @@ import React, { useCallback, useState } from "react"; import { useDropzone } from "react-dropzone"; import useUploader from "../../hooks/useFiretable/useUploader"; -// TODO: indecate state completion / error +import { FieldType } from '.'; +// TODO: indicate state completion / error // TODO: Create an interface for props + + +interface Props { + value: any; + row: any; + onSubmit: Function; + fieldType: FieldType; +} + + const Image = (props: any) => { const { columnData, cellData, cellActions, rowData, rowIndex } = props; const [uploaderState, upload] = useUploader(); diff --git a/src/components/Fields/LongText.tsx b/src/components/Fields/LongText.tsx index 4fdd68cd..ab30c21f 100644 --- a/src/components/Fields/LongText.tsx +++ b/src/components/Fields/LongText.tsx @@ -2,6 +2,12 @@ import React from "react"; import ExpandIcon from "@material-ui/icons/AspectRatio"; import IconButton from "@material-ui/core/IconButton"; +interface Props { + value: firebase.firestore.Timestamp | null; + row: any; + onSubmit: Function; +} + const UrlLink = (props: any) => { const { value, cellActions } = props; return value ? ( diff --git a/src/components/Fields/UrlLink.tsx b/src/components/Fields/UrlLink.tsx index 3711ad41..37a519fe 100644 --- a/src/components/Fields/UrlLink.tsx +++ b/src/components/Fields/UrlLink.tsx @@ -2,9 +2,12 @@ import React from "react"; import EditIcon from "@material-ui/icons/Edit"; // TODO: regex validating url // ^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$ +interface Props { + value: string | null; +} -const UrlLink = (props: any) => { - const { value, cellActions } = props; +const UrlLink = (props: Props) => { + const { value } = props; return value ? ( <>