-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from lizaklimova/add-recipe
Add recipe
- Loading branch information
Showing
18 changed files
with
145 additions
and
10 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
src/components/AddRecipe/AddRecipeForm/AddRecipeForm.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import styled from 'styled-components'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import RecipeDescriptionFields from 'components/AddRecipe/RecipeDescriptionFields'; | ||
import RecipeIngredientsFields from 'components/AddRecipe/RecipeIngredientsFields'; | ||
import RecipePreparationFields from 'components/AddRecipe/RecipePreparationFields'; | ||
import { FC, FormEvent } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
//TODO install React-Select | ||
// містить стейт => зберігаються заповнені у формі дані | ||
// всі поля required, валідуються. Інфа якщо значення невалідне | ||
const AddRecipeForm: FC = () => { | ||
const inputValues = 'test'; | ||
const navigate = useNavigate(); | ||
|
||
const handleFormSubmit = (e: FormEvent) => { | ||
e.preventDefault(); | ||
|
||
navigate('/my'); | ||
}; | ||
|
||
return ( | ||
<form onSubmit={handleFormSubmit}> | ||
<RecipeDescriptionFields | ||
value={inputValues} | ||
onSubmit={handleFormSubmit} | ||
/> | ||
<RecipeIngredientsFields /> | ||
<RecipePreparationFields /> | ||
<button type="submit">Add</button> | ||
</form> | ||
); | ||
}; | ||
|
||
export default AddRecipeForm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './AddRecipeForm'; |
1 change: 1 addition & 0 deletions
1
src/components/AddRecipe/RecipeDescriptionFields/RecipeDescriptionFields.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import styled from 'styled-components'; |
28 changes: 28 additions & 0 deletions
28
src/components/AddRecipe/RecipeDescriptionFields/RecipeDescriptionFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FC, FormEvent } from 'react'; | ||
|
||
interface RecipeDescriptionFieldsProps { | ||
value: string; | ||
onSubmit: (e: FormEvent, data: unknown) => void; | ||
} | ||
|
||
// time 5mins-120mins. Interval 5mins | ||
// selects must have visible 6 options, other scroll | ||
const RecipeDescriptionFields: FC<RecipeDescriptionFieldsProps> = ({ | ||
value, | ||
onSubmit, | ||
}) => { | ||
return ( | ||
<div> | ||
<input type="file" name="picture" /> | ||
<div> | ||
<input type="text" name="title" /> | ||
<input type="text" name="about" /> | ||
<select name="category"></select> | ||
<select name="time"></select> | ||
<select name="" /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default RecipeDescriptionFields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './RecipeDescriptionFields'; |
1 change: 1 addition & 0 deletions
1
src/components/AddRecipe/RecipeIngredientsFields/RecipeIngredientsFields.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import styled from 'styled-components'; |
43 changes: 43 additions & 0 deletions
43
src/components/AddRecipe/RecipeIngredientsFields/RecipeIngredientsFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState } from 'react'; | ||
|
||
const RecipeIngredientsFields = () => { | ||
const [count, setCount] = useState<number>(3); | ||
|
||
return ( | ||
<> | ||
<div> | ||
<h3>Ingredients</h3> | ||
<div> | ||
<button | ||
onClick={() => { | ||
setCount(prev => prev + 1); | ||
}} | ||
> | ||
- | ||
</button> | ||
<span>{count}</span> | ||
<button | ||
onClick={() => { | ||
setCount(prev => { | ||
if (prev === 1) return prev; | ||
return prev - 1; | ||
}); | ||
}} | ||
> | ||
+ | ||
</button> | ||
</div> | ||
</div> | ||
<ul> | ||
{/* Create Item component and map in ul */} | ||
<li> | ||
<select name="ingredient"></select> | ||
<select name="weight"></select> | ||
<button>delete</button> | ||
</li> | ||
</ul> | ||
</> | ||
); | ||
}; | ||
|
||
export default RecipeIngredientsFields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './RecipeIngredientsFields'; |
1 change: 1 addition & 0 deletions
1
src/components/AddRecipe/RecipePreparationFields/RecipePreparationFields.styled.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import styled from 'styled-components'; |
10 changes: 10 additions & 0 deletions
10
src/components/AddRecipe/RecipePreparationFields/RecipePreparationFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const RecipePreparationFields = () => { | ||
return ( | ||
<> | ||
<h3>Recipe Preparation</h3> | ||
<textarea name="recipe" placeholder="Enter recipe" required /> | ||
</> | ||
); | ||
}; | ||
|
||
export default RecipePreparationFields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './RecipePreparationFields'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './AddRecipeForm'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { FC } from 'react'; | ||
|
||
interface IMainTitleProps { | ||
title: string; | ||
} | ||
|
||
const MainTitle: FC<IMainTitleProps> = ({ title }) => { | ||
return <h2>{title}</h2>; | ||
}; | ||
|
||
export default MainTitle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,15 @@ | ||
import { FC } from 'react'; | ||
import AddRecipeForm from 'components/AddRecipe'; | ||
import MainTitle from 'components/MainTitle/MainTitle'; | ||
|
||
const AddRecipesPage: FC = () => { | ||
return <div></div>; | ||
const AddRecipesPage = () => { | ||
return ( | ||
<> | ||
<section> | ||
<MainTitle title={'Add recipe'} /> | ||
<AddRecipeForm /> | ||
</section> | ||
</> | ||
); | ||
}; | ||
|
||
export default AddRecipesPage; |