bigcommerce / b2b-buyer-portal

B2B Buyer Portal - BigCommerce B2B Edition
MIT License
25 stars 19 forks source link

refactor: simplify login page (Step 1) #63

Closed icatalina closed 2 months ago

icatalina commented 2 months ago

What/Why?

This commit extracts some of the logic in the login outside of it and simplifies the syntax a bit.

Also simplifies the creation and use of loginInfo, ensuring it is always defined.

Rollout/Rollback

Revert

Testing

Most of the refactor here is automated.

Page still loads fine:

image
deov31 commented 2 months ago

Hey @icatalina overall looks good to me, I just noticed something really weird and I'm still not sure but I think it could related with this part https://github.com/bigcommerce/b2b-buyer-portal/pull/63/files#diff-fd4aa15ef6c953e480fa16141985f695bad80e0aad2b88b01a2163044e23c8d4R159-R160

After clicking Sign In is not displaying that "Loading" so it feels like nothing is happening after clicking the button until of course it is redirected to the account dashboard. image

icatalina commented 2 months ago

Hey @deov31, good catch, the useEffect for init was re-firing due to the endMasquerade function getting recreated on re-render. I fixed it by wrapping it in a useCallback.

https://github.com/bigcommerce/b2b-buyer-portal/assets/4542735/ae5765e1-7336-4ba7-b4eb-54bdab793864