bradtraversy / proshop_mern

Shopping cart built with MERN & Redux
1.99k stars 1.18k forks source link

[SOLVED] 2 bugs Admin Profile, Product Edit #54

Closed kamesdev closed 3 years ago

kamesdev commented 3 years ago

#1 If admin goes to /admin/user/:id/edit, click update and go to own profile /profile, then name and email is filled by other user data e.g Instead of admin name there is John Doe and instead of admin@example.com there's john@example.com

#2 If admin goes to (/admin/product/:id/edit), change some values e.g. name of product, click Update, and again click to edit the same product then there's not updated version of product

kamesdev commented 3 years ago

1 BUG FIXED In order to solve this problem you should add dispatch(getUserDetails('profile')) to submitHandler in UserEditScreen

2 BUG FIXED In order to solve this problem you should add dispatch(listProductDetails(productId)) to submitHandler in ProductEditScreen

basir commented 3 years ago

hello there thanks for finding bugs but it is not a fix. you should not dispatch(getUserDetails('profile')) on submitHandler because in the submitHandler we did not update user or product yet. will fix the issues soon and let you know on this thread.

aorelhas commented 3 years ago

#1 If admin goes to /admin/user/:id/edit, click update and go to own profile /profile, then name and email is filled by other user data e.g Instead of admin name there is John Doe and instead of admin@example.com there's john@example.com

#2 If admin goes to (/admin/product/:id/edit), change some values e.g. name of product, click Update, and again click to edit the same product then there's not updated version of product

For your point one, you should add:

dispatch({ type: USER_DETAILS_RESET })

userActions.js > updateUser > after dispatch dispatch({ type: USER_DETAILS_SUCCESS, payload: data })

aorelhas commented 3 years ago

#1 If admin goes to /admin/user/:id/edit, click update and go to own profile /profile, then name and email is filled by other user data e.g Instead of admin name there is John Doe and instead of admin@example.com there's john@example.com

#2 If admin goes to (/admin/product/:id/edit), change some values e.g. name of product, click Update, and again click to edit the same product then there's not updated version of product

For your point 2, you should add:

dispatch({ type: PRODUCT_DETAILS_SUCCESS, payload: data })

productActions.js > updateProduct > after dispatch dispatch({ type: PRODUCT_UPDATE_SUCCESS, payload: data })

basir commented 3 years ago

Fix 1: https://github.com/bradtraversy/proshop_mern/pull/62/files#diff-a0edea66e0409c53c55788399e0f912434ca3497644c9ce349243ab149286067R43

Fix 2: https://github.com/bradtraversy/proshop_mern/pull/62/files#diff-8bfc6d95272f3175c49db7886c7e0f68e1fd61030ce9a1c59bbb09e6df374e2aR173