Skip to content

Commit

Permalink
Fix/recipe creation refresh (#17)
Browse files Browse the repository at this point in the history
* adding menus

* adding a menu item for menus

* adding react-big-calender

* adding basic redux hooks

* adding a recipe event

* adding modal and datetime picker

* adding more responsive menu

* saving

* adding some basic updates

* fixing reducer to save correctly

* fixing reducer to save correctly

* making creatin/editing and delting easier

* adding react app that handles selects

* adding proper select box

* saving some calander changes

* cleaning up datetime object handling and display

* create a seperate redux call for creating recipes

* fixing agenda style and adding history to the calander

* adding support for all day button

* fixing bug with times

* updating menus

* adding a menu selector

* adding selector for filtering by menu

* Adding Menu management

* doing some clean up and adding translations

* clean up on containers

* update the URL when you create or delete a menu

* fixing bugs

* remvoing fixed todos

* adding ability to copy menus

* fixing issues with dates

* adding a menu list

* commenting out the menu list for now

* adding a basic status bar

* adding comment

* abstracting the modals and adding validation

* adding proper descriptions to the validators

* adding text to the menu status

* cleaning up the menu header

* adding better css for alert messages and fixing small bug with menu item dates

* fixing merge conflicks

* merge conflict fixes

* adding recipe slug to the menu

* fixing lint errors

* putting some finishing touches on the menu composer

* updating tests

* adding menu items to the homepage

* fixing menu item support

* removing unused components

* adding menu items to the home page

* adding complete button to the homepage

* adding simple add menu button to the recipe page

* updating lock file

* fixing tests

* adding proper styling for add to menu button

* bug fixes

* bug fixes
  • Loading branch information
RyanNoelk authored Aug 30, 2018
1 parent 113e91e commit 7c2dc9a
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 32 deletions.
89 changes: 89 additions & 0 deletions modules/list/tests/__snapshots__/Ingredients.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MyLists component test 1`] = `
<div
className="grocery-lists"
>
<ul
className="list-group"
>
<p
className="list-group-item disabled"
>
My Lists
</p>
<a
aria-current={null}
className="list-group-item"
href="/list/1"
onClick={[Function]}
style={undefined}
>
<span
className="badge"
>
3
</span>
The first test
</a>
<a
aria-current={null}
className="list-group-item"
href="/list/sdfsdf"
onClick={[Function]}
style={undefined}
>
<span
className="badge"
>
4
</span>
another test
</a>
<a
aria-current={null}
className="list-group-item"
href="/list/test"
onClick={[Function]}
style={undefined}
>
<span
className="badge"
>
0
</span>
test
</a>
<a
aria-current={null}
className="list-group-item"
href="/list/"
onClick={[Function]}
style={undefined}
>
Create a New List!
</a>
</ul>
</div>
`;

exports[`MyLists component test w/ no lists 1`] = `
<div
className="grocery-lists"
>
<ul
className="list-group"
>
<p
className="list-group-item disabled"
>
My Lists
</p>
<p
className="list-group-item disabled"
>
No Lists to display
</p>
</ul>
</div>
`;
2 changes: 1 addition & 1 deletion modules/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"select_widget.header": "Please select a {label}",
"widget_error.title": "Form error!",
"widget_error.message": "Please confirm that all the data is there.",
"nav.menu": "Menu (Beta)",
"nav.menu": "Menu",
"nav.randomRecipe": "Random",
"list.new-input-placeholder": "What else do you need?",
"list.error.message": "Something went wrong!",
Expand Down
6 changes: 4 additions & 2 deletions modules/recipe_form/actions/RecipeFormActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export const save = (data, event) => {
dispatch({
type: RecipeFormConstants.RECIPE_FORM_SUBMIT,
oldRecipeId: data.id,
newRecipeId: res.body.id
newRecipeId: res.body.id,
slug: res.body.slug
});
dispatch({
type: StatusConstants.RECIPE_FROM_STATUS_DISPLAY,
Expand All @@ -124,7 +125,8 @@ export const save = (data, event) => {
dispatch({
type: RecipeFormConstants.RECIPE_FORM_SUBMIT,
oldRecipeId: data.id,
newRecipeId: res.body.id
newRecipeId: res.body.id,
slug: res.body.slug
});
dispatch({
type: StatusConstants.RECIPE_FROM_STATUS_DISPLAY,
Expand Down
16 changes: 14 additions & 2 deletions modules/recipe_form/reducers/RecipeFormReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ import RecipeFormConstants from '../constants/RecipeFormConstants'
function form(state = [], action) {
switch (action.type) {
case RecipeFormConstants.RECIPE_FORM_INIT:
return [...state, { ...action.data, errors: [] }];
let newRecipe = true;
const recipes = state.map(recipe => {
if (recipe.slug === action.data.slug) {
newRecipe = false;
return { ...recipe, ...action.data, errors: [] };
}
return recipe;
});

if (newRecipe) {
return [...state, { ...action.data, errors: [] }];
}
return [ ...recipes ];
case RecipeFormConstants.RECIPE_FORM_UPDATE:
return state.map(recipe => {
if (recipe.slug === action.recipeSlug) {
Expand All @@ -27,7 +39,7 @@ function form(state = [], action) {
if (action.newRecipeId !== action.oldRecipeId) {
return state.map(recipe => {
if (recipe.id === action.oldRecipeId) {
return {...recipe, id: action.newRecipeId };
return {...recipe, id: action.newRecipeId, slug: action.slug };
}
return recipe;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"react-spinkit": "2.1.2",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"superagent": "^2.3.0",
"superagent": "^3.8.3",
"superagent-defaults": "^0.1.14"
},
"devDependencies": {
Expand Down
50 changes: 24 additions & 26 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ colors@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63"

[email protected], combined-stream@^1.0.5, combined-stream@~1.0.6:
[email protected], combined-stream@~1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818"
dependencies:
Expand Down Expand Up @@ -1756,7 +1756,7 @@ [email protected]:
version "0.3.1"
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"

cookiejar@^2.0.6:
cookiejar@^2.1.0:
version "2.1.2"
resolved "https://registry.yarnpkg.com/cookiejar/-/cookiejar-2.1.2.tgz#dd8a235530752f988f9a0844f3fc589e3111125c"

Expand Down Expand Up @@ -2980,23 +2980,15 @@ forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"

[email protected]:
version "1.0.0-rc4"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-1.0.0-rc4.tgz#05ac6bc22227b43e4461f488161554699d4f8b5e"
dependencies:
async "^1.5.2"
combined-stream "^1.0.5"
mime-types "^2.1.10"

form-data@~2.3.2:
form-data@^2.3.1, form-data@~2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.2.tgz#4970498be604c20c005d4f5c23aecd21d6b49099"
dependencies:
asynckit "^0.4.0"
combined-stream "1.0.6"
mime-types "^2.1.12"

formidable@^1.0.17:
formidable@^1.2.0:
version "1.2.1"
resolved "https://registry.yarnpkg.com/formidable/-/formidable-1.2.1.tgz#70fb7ca0290ee6ff961090415f4b3df3d2082659"

Expand Down Expand Up @@ -4736,7 +4728,13 @@ miller-rabin@^4.0.0:
version "1.36.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.36.0.tgz#5020478db3c7fe93aad7bbcc4dcf869c43363397"

mime-types@^2.1.10, mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.18, mime-types@~2.1.19:
mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.18:
version "2.1.18"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8"
dependencies:
mime-db "~1.33.0"

mime-types@~2.1.19:
version "2.1.20"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.20.tgz#930cb719d571e903738520f8470911548ca2cc19"
dependencies:
Expand All @@ -4746,7 +4744,7 @@ [email protected]:
version "1.4.1"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.4.1.tgz#121f9ebc49e3766f311a76e1fa1c8003c4b03aa6"

mime@^1.3.4, mime@^1.4.1, mime@^1.5.0:
mime@^1.4.1, mime@^1.5.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1"

Expand Down Expand Up @@ -5857,7 +5855,7 @@ [email protected]:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"

qs@^6.1.0, qs@~6.5.2:
qs@^6.5.1, qs@~6.5.2:
version "6.5.2"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"

Expand Down Expand Up @@ -6213,7 +6211,7 @@ [email protected]:
isarray "0.0.1"
string_decoder "~0.10.x"

readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3, readable-stream@^2.3.6:
readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.2.2, readable-stream@^2.2.9, readable-stream@^2.3.3, readable-stream@^2.3.5, readable-stream@^2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
dependencies:
Expand Down Expand Up @@ -7022,20 +7020,20 @@ superagent-defaults@^0.1.14:
dependencies:
emitter-component "~1.0.1"

superagent@^2.3.0:
version "2.3.0"
resolved "http://registry.npmjs.org/superagent/-/superagent-2.3.0.tgz#703529a0714e57e123959ddefbce193b2e50d115"
superagent@^3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/superagent/-/superagent-3.8.3.tgz#460ea0dbdb7d5b11bc4f78deba565f86a178e128"
dependencies:
component-emitter "^1.2.0"
cookiejar "^2.0.6"
debug "^2.2.0"
cookiejar "^2.1.0"
debug "^3.1.0"
extend "^3.0.0"
form-data "1.0.0-rc4"
formidable "^1.0.17"
form-data "^2.3.1"
formidable "^1.2.0"
methods "^1.1.1"
mime "^1.3.4"
qs "^6.1.0"
readable-stream "^2.0.5"
mime "^1.4.1"
qs "^6.5.1"
readable-stream "^2.3.5"

supports-color@^2.0.0:
version "2.0.0"
Expand Down

0 comments on commit 7c2dc9a

Please sign in to comment.