Преглед на файлове

Add Course field for dish courses. Improve typing in Ktchn

Tatiana Inama преди 6 години
родител
ревизия
8f8cf81786
променени са 3 файла, в които са добавени 19 реда и са изтрити 19 реда
  1. 1 9
      ktchn/src/recipes/model.ts
  2. 15 9
      recipes/src/components/RecipeForm/index.tsx
  3. 3 1
      recipes/src/types/recipes.ts

+ 1 - 9
ktchn/src/recipes/model.ts

@@ -61,19 +61,11 @@ export interface Recipe {
   summary?: string;
 }
 
-export interface ScrapedRecipe {
-  name: string;
+export interface ScrapedRecipe extends Recipe {
   ingredients: {
     name: string,
     ingredients: IngredientSuggestion[]
   }[];
-  details?: RecipeDetails;
-  instructions?: string[];
-  author?: Author;
-  website?: string;
-  tags?: string[];
-  course?: string[];
-  summary?: string;
 }
 
 export interface RecipeDB extends Recipe {

+ 15 - 9
recipes/src/components/RecipeForm/index.tsx

@@ -137,8 +137,7 @@ const RecipeForm = <T extends Recipe|DBRecipe>({ initialValues, onSubmit }: Reci
               <Row>
                 <Cell columns={3}>
                   <FormikInput name='details.preparationTime' label='preparation time' />
-                </Cell>
-                <Cell columns={3}>
+                </Cell>                <Cell columns={3}>
                   <FormikInput name='details.cookingTime' label='cooking time' />
                 </Cell>
                 <Cell columns={3}>
@@ -150,13 +149,20 @@ const RecipeForm = <T extends Recipe|DBRecipe>({ initialValues, onSubmit }: Reci
               </Row>
               <Row>
                 <Cell columns={12}>
-                  <div>
-                    <TagInput
-                      tags={values.tags}
-                      label='tags'
-                      onNewTag={(tags) => setFieldValue('tags', tags)}
-                    />
-                  </div>
+                  <TagInput
+                    tags={values.tags}
+                    label='tags'
+                    onNewTag={(tags) => setFieldValue('tags', tags)}
+                  />
+                </Cell>
+              </Row>
+              <Row>
+                <Cell columns={12}>
+                  <TagInput
+                    tags={values.course}
+                    label='dish course'
+                    onNewTag={(dishCourse) => setFieldValue('course', dishCourse)}
+                  />
                 </Cell>
               </Row>
             </section>

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

@@ -50,7 +50,8 @@ export const _recipe: Recipe = {
   instructions: [ '' ],
   name: '',
   summary: '',
-  tags: []
+  tags: [],
+  course: [],
 }
 
 export interface Equivalences {
@@ -114,6 +115,7 @@ export default interface Recipe {
   name: string,
   summary: string,
   tags: string[],
+  course: string[];
 }
 
 export interface DBRecipe extends Recipe {