Explorar o código

Add add new button to Suggestions. Improve Equivalences typing

Tatiana Inama %!s(int64=7) %!d(string=hai) anos
pai
achega
85aa872560

+ 1 - 0
recipes/src/components/Ingredient/Form/index.tsx

@@ -119,6 +119,7 @@ class IngredientForm extends React.Component<IngredientFormProps, IngredientForm
                 <Suggestions
                   suggestions={ingredient.suggestions}
                   onSelect={(idx) => console.log('selected', idx)}
+                  onNew={()=>{}}
                 />
               </div>
             ))

+ 4 - 2
recipes/src/components/Ingredient/Suggestions/index.tsx

@@ -7,10 +7,11 @@ import './styles.scss';
 
 type SuggestionsProps = {
   suggestions?: Suggestion[],
-  onSelect: (index: number) => void  
+  onSelect: (index: number) => void,
+  onNew: () => void,
 }
 
-const Suggestions = ({ suggestions, onSelect }: SuggestionsProps) => {
+const Suggestions = ({ suggestions, onSelect, onNew }: SuggestionsProps) => {
   return suggestions && suggestions.length > 1 ? (
     <div className='cbk-suggestions'>
       <Icon material icon={'wb_incandescent'} />
@@ -19,6 +20,7 @@ const Suggestions = ({ suggestions, onSelect }: SuggestionsProps) => {
           <Button onClick={() => onSelect(index)} key={index}>{suggestion.name}</Button>
         ))
       }
+      <Button onClick={() => onNew()}>Add new</Button>
     </div>
   ) : null
 };

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

@@ -55,6 +55,7 @@ export const _recipe: Recipe = {
 }
 
 export interface Equivalences {
+  [key:string]: number | undefined,
   cup?: number,
   tbsp?: number,
   tsp?: number,