소스 검색

Rename Recipes types

Tatiana Inama 7 년 전
부모
커밋
9bd4affc5e

+ 2 - 2
recipes/src/components/IngredientForm/index.tsx

@@ -3,12 +3,12 @@ import Input from 'components/Input';
 import Select from 'components/Select';
 import TabBar from 'components/TabBar';
 
-import { ISubRecipe, _recipe, _subRecipe, _ingredient } from 'types/recipes';
+import { SubRecipe, _recipe, _subRecipe, _ingredient } from 'types/recipes';
 
 import './styles.scss';
 
 type IngredientFormProps = {
-  components: ISubRecipe[],
+  components: SubRecipe[],
   updateField: (key: any[]) => (e: any) => void,
   addSubrecipe: () => void,
   updateSubrecipeName: (subrecipe: number, newValue: string) => void,

recipes/src/components/IngredientForm/stories.js → recipes/src/components/Ingredient/Form/stories.js


recipes/src/components/IngredientForm/styles.scss → recipes/src/components/Ingredient/Form/styles.scss


+ 2 - 2
recipes/src/components/IngredientList/index.tsx

@@ -1,10 +1,10 @@
 import React from 'react';
-import { ISubRecipe } from 'src/types/recipes';
+import { SubRecipe } from 'types/recipes';
 
 import './styles.scss';
 
 type ShowIngredientsProps = {
-  ingredients: ISubRecipe[],
+  ingredients: SubRecipe[],
   className?: string,
 };
 

recipes/src/components/IngredientList/styles.scss → recipes/src/components/Ingredient/List/styles.scss


+ 7 - 0
recipes/src/components/Ingredient/index.tsx

@@ -0,0 +1,7 @@
+import IngredientForm from './Form';
+import IngredientList from './List';
+
+export {
+  IngredientForm as Form,
+  IngredientList as List,
+};

+ 3 - 3
recipes/src/components/RecipeCard/index.tsx

@@ -1,10 +1,10 @@
 import React, { Component } from 'react';
-import IRecipe, { ISubRecipe, IIngredient } from '../../types/recipes';
+import Recipe, { SubRecipe, Ingredient } from '../../types/recipes';
 import Card, {
   CardMedia,
 } from "@material/react-card";
 import Icon from 'components/Icon';
-import Ingredients from 'components/IngredientList';
+import { List as Ingredients } from 'components/Ingredient';
 import moment from 'moment';
 
 import sample_img from "components/Card/sample.png";
@@ -15,7 +15,7 @@ import { ReactComponent as Servings } from 'svgs/servings.svg';
 import './styles.scss';
 
 type RecipeCardProps = {
-  recipe: IRecipe,
+  recipe: Recipe,
 }
 
 function CBKRecipeCard(props: RecipeCardProps) {

+ 5 - 5
recipes/src/containers/Recipes/Create.tsx

@@ -6,26 +6,26 @@ import Btn from 'components/Button';
 import Input from 'components/Input';
 import TagInput from 'components/TagInput';
 import Select from 'components/Select';
-import IngredientForm from 'components/IngredientForm';
+import { Form as IngredientForm } from 'components/Ingredient';
 
 import './styles.scss';
 
 import { scrapeRecipe } from './services';
 
 import sample_img from "../../sample.png";
-import IRecipe, { ISubRecipe, IAuthor, IDetails, _recipe, _subRecipe, _ingredient, IIngredient, ISuggestion } from 'types/recipes';
+import Recipe, { SubRecipe, Author, Details, _recipe, _subRecipe, _ingredient, Ingredient, Suggestion } from 'types/recipes';
 
 type CreateRecipeProps = {
 };
 
 type CreateRecipeState = {
-  form: IRecipe,
+  form: Recipe,
   scrapeUrl: string,
 };
 
-type FormKeys = keyof IRecipe | keyof ISubRecipe | keyof IIngredient | keyof IAuthor | keyof IDetails | number;
+type FormKeys = keyof Recipe | keyof SubRecipe | keyof Ingredient | keyof Author | keyof Details | number;
 
-const Suggestions = (suggestions: ISuggestion[] = []) => (
+const Suggestions = (suggestions: Suggestion[] = []) => (
   <div>
     {
       suggestions.map(suggestion => (

+ 6 - 6
recipes/src/containers/Recipes/List.tsx

@@ -9,17 +9,17 @@ import { Grid, Row, Cell } from "@material/react-layout-grid";
 import { Button } from "@material/react-button";
 import Card from 'components/Card';
 import RecipeCard from 'components/RecipeCard';
-import IRecipe from 'types/recipes';
+import Recipe from 'types/recipes';
 import Navbar from 'components/Navbar';
 import { Link } from 'react-router-dom';
 
 type RecipeListProps = {
-  data: IRecipe[],
+  data: Recipe[],
   isFetching: boolean,
   selectedRecipe: any | undefined,
   fetchRecipes: (query: any) => undefined,
-  receiveRecipes: (recipes: IRecipe[]) => undefined,
-  selectRecipe: (recipe: IRecipe) => undefined,
+  receiveRecipes: (recipes: Recipe[]) => undefined,
+  selectRecipe: (recipe: Recipe) => undefined,
 };
 
 class RecipeList extends Component<RecipeListProps> {
@@ -111,10 +111,10 @@ const mapDispatchToProps = (dispatch: any) => {
     fetchRecipes: (query: any) => {
       dispatch(fetch(query))
     },
-    receiveRecipes: (recipes: IRecipe[]) => {
+    receiveRecipes: (recipes: Recipe[]) => {
       dispatch(receive(recipes))
     },
-    selectRecipe: (recipe: IRecipe) => {
+    selectRecipe: (recipe: Recipe) => {
       dispatch(select(recipe))
     }
   }

+ 4 - 4
recipes/src/containers/Recipes/actions.ts

@@ -1,5 +1,5 @@
 import axios from 'axios';
-import IRecipe from 'types/recipes';
+import Recipe from 'types/recipes';
 import { getRecipes } from './services';
 
 export const RECEIVE_RECIPES = 'RECEIVE_RECIPES';
@@ -11,13 +11,13 @@ export const requestRecipes = (query: {}) => ({
   isFetching: true,
 });
 
-export const receiveRecipes = (json: IRecipe[]) => ({
+export const receiveRecipes = (json: Recipe[]) => ({
   type: RECEIVE_RECIPES,
   isFetching: false,
   payload: json,
 });
 
-export const selectRecipe = (recipe: IRecipe) => ({
+export const selectRecipe = (recipe: Recipe) => ({
   type: SELECT_RECIPE,
   payload: recipe,
 });
@@ -33,7 +33,7 @@ export function fetchRecipes(query: any) {
   }
 }
 
-function shouldFetch(recipes: IRecipe[]) {
+function shouldFetch(recipes: Recipe[]) {
   return recipes.length ? false : true;
 }
 

+ 3 - 3
recipes/src/containers/Recipes/services.ts

@@ -1,14 +1,14 @@
 import axios, { AxiosPromise } from 'axios';
-import IRecipe from 'types/recipes';
+import Recipe from 'types/recipes';
 
 //@ts-ignore
 const API: string = process.env.REACT_APP_API_RECIPES;
 
-export const getRecipes = (query: any): Promise<IRecipe[]> => 
+export const getRecipes = (query: any): Promise<Recipe[]> => 
   axios.get(`${API}/all`)
   .then(response => response.data);
 
-export const scrapeRecipe = (url: string): Promise<IRecipe> => 
+export const scrapeRecipe = (url: string): Promise<Recipe> => 
   axios.post(
     `${API}/scrape`,
     { url }

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

@@ -1,41 +1,41 @@
-export interface IIngredient { 
+export interface Ingredient { 
   name: string,
   quantity: number,
   unit: string,
   _original: string,
-  suggestions?: ISuggestion[]
+  suggestions?: Suggestion[]
 }
 
-export interface ISubRecipe {
+export interface SubRecipe {
   name: string,
-  ingredients: IIngredient[]
+  ingredients: Ingredient[]
 }
 
-export interface IAuthor {
+export interface Author {
   name: string,
   website: string,
 }
 
-export interface IDetails {
+export interface Details {
   url?: string,
   preparationTime: string,
   cookingTime: string,
   servings: number
 }
 
-export const _ingredient: IIngredient = {
+export const _ingredient: Ingredient = {
   name: '',
   quantity: 0,
   unit: '',
   _original: ''
 };
 
-export const _subRecipe: ISubRecipe = {
+export const _subRecipe: SubRecipe = {
   name: '',
   ingredients: [_ingredient]
 };
 
-export const _recipe: IRecipe = {
+export const _recipe: Recipe = {
   _id: '',
   author: {
     name: '',
@@ -54,7 +54,7 @@ export const _recipe: IRecipe = {
   tags: []
 }
 
-export interface IEquivalences {
+export interface Equivalences {
   cup?: number,
   tbsp?: number,
   tsp?: number,
@@ -65,13 +65,13 @@ export interface IEquivalences {
   lb?: number,
 }
 
-export interface ISuggestion {
+export interface Suggestion {
   _id?: string,
   name: string,
   variants?: string[],
-  equivalences: IEquivalences,
-  prefferedUnit: keyof IEquivalences,
-  referenceUnit: keyof IEquivalences,
+  equivalences: Equivalences,
+  prefferedUnit: keyof Equivalences,
+  referenceUnit: keyof Equivalences,
   translation?: {
     english?: string,
     dutch?: string,
@@ -79,11 +79,11 @@ export interface ISuggestion {
   }
 }
 
-export default interface IRecipe {
+export default interface Recipe {
   _id: string,
-  author: IAuthor,
-  details: IDetails,
-  ingredients: ISubRecipe[],
+  author: Author,
+  details: Details,
+  ingredients: SubRecipe[],
   instructions: string[],
   name: string,
   summary: string,