Selaa lähdekoodia

Improve typing in CBK Card

Tati 7 vuotta sitten
vanhempi
commit
b63f18fd2c

+ 2 - 7
recipes/src/components/Card/index.tsx

@@ -2,22 +2,18 @@ import React from 'react';
 import Card, {
   CardActions,
   CardActionButtons,
-  CardActionIcons,
   CardPrimaryContent,
   CardMedia,
 } from "@material/react-card";
 import Button from "@material/react-button";
-
 import '@material/react-card/dist/card.min.css';
 import '@material/react-button/dist/button.min.css';
+
 import './styles.scss';
 import sample_img from "./sample.png";
-import IRecipe from 'types/recipes';
-import { ReactNodeArray } from 'react';
 
 type CBKCardProps = {
   withImg?: boolean,
-  withActions?: boolean,
   title: string,
   summary?: string,
   img?: string,
@@ -25,10 +21,9 @@ type CBKCardProps = {
     label: string,
     handler: (event: React.MouseEvent) => void,
   }[],
-  recipe?: any,
   onClick: (event: React.MouseEvent) => void,
 }
-  
+
 function CBKCard(props: CBKCardProps){
   const {onClick, img, title, summary, actions} = props;
   return(

+ 1 - 3
recipes/src/containers/recipes.tsx

@@ -15,7 +15,7 @@ type RecipesContainerProps = {
   selectedRecipe: any | undefined,
   fetchRecipes: (query: any) => undefined,
   receiveRecipes: (recipes: IRecipe[]) => undefined,
-  selectRecipe: (recipe: any) => undefined,
+  selectRecipe: (recipe: IRecipe) => undefined,
 };
 
 class Recipes extends Component<RecipesContainerProps> {
@@ -30,7 +30,6 @@ class Recipes extends Component<RecipesContainerProps> {
 
   componentDidUpdate(prevProps: any) {
     const { data, receiveRecipes, isFetching } = this.props;
-    console.log('update');
     if (isFetching === false && data.length !== prevProps.data.length) {
       receiveRecipes(data);
     }
@@ -65,7 +64,6 @@ class Recipes extends Component<RecipesContainerProps> {
                     <Cell columns={10}>
                       <Card
                         title={recipe.name}
-                        recipe={recipe}
                         onClick={this.handleRecipeSelection(recipe)}
                         summary={recipe.summary}
                         actions={actions}

+ 1 - 1
recipes/src/types/recipes.ts

@@ -21,4 +21,4 @@ export default interface IRecipe {
   name: string,
   summary: string,
   tags: string[],
-}
+}