-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[project-base][SSP-2096] order process refactoring #3155
base: 15.0
Are you sure you want to change the base?
Conversation
89a19e3
to
1c0ce36
Compare
363ed66
to
41413e4
Compare
07aeefe
to
9a26c79
Compare
- it now clearly defines the cart object - it now returns isCartFetchingOrUnavailable instead of isFetching, which is also based on auth loading and cart not being undefined
- renamed various variables - simplified PromoCode component in order for the UI to be more isolated from the functionality
- they now allow fo displaying of skeletons even during initial load, as the skeleton manager was included in all 3 order process pages - going back and forth in order process is now only done using callbacks (not links), as we now always start page-loading on navigation
… to fill a new delivery address
…ress if filled for the second time - this ensures better testing, as it checks if the address is correctly modified
9a26c79
to
dc3cb37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, thanks for the refactoring 🙌
) => { | ||
const { t } = useTranslation(); | ||
const updatePortalContent = useSessionStore((s) => s.updatePortalContent); | ||
const promoCodeValidationMessages = useMemo(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why we don't use react-hook-form and yup there.
I understand this seems like overkill here, but if the project wants to extend the validation or something, it wouldn't be really comfortable.
For example, the newsletter form uses yup and also doesn't have many fields
const goToPreviousStepFromCartPage = () => { | ||
updatePageLoadingState({ isPageLoading: true, redirectPageType: 'homepage' }); | ||
router.push('/'); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if redirecting to the homepage is valid solution. Inspiring by projects, usually this button calls history.back()
formMeta: ContactInformationFormMetaType, | ||
) => { | ||
const { t } = useTranslation(); | ||
const [{ fetching }, createOrderMutation] = useCreateOrderMutation(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fetching is too general name, please rename it to a more specific name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name of the file is too general, please rename it to a more specific name.
I will be more comfortable to search this file
currentCart.transport && | ||
currentCart.payment | ||
) { | ||
const query: OrderConfirmationQuery = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query is too general name, please rename it to a more specific name.
Firstly i thought that it's query for graphql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use more specific name for the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a general comment.
I would like to have unit tests for these utils files, it brings a lot of code stability.
I implemented it on breno and it paid off 100%
const { orderUuid, orderPaymentType } = query as OrderConfirmationQuery; | ||
|
||
const gtmStaticPageViewEvent = useGtmStaticPageViewEvent(GtmPageType.order_confirmation); | ||
useGtmPageViewEvent(gtmStaticPageViewEvent); | ||
|
||
const [{ data: orderSentPageContentData, fetching }] = useOrderSentPageContentQuery({ | ||
const [{ data: orderSentPageContentData, fetching: isFetching }] = useOrderSentPageContentQuery({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rename isFetching to a more specific name, it would help to read the code somewhere below
@@ -9,6 +9,9 @@ const CUSTOM_PAGE_TYPES = [ | |||
'orders', | |||
'order', | |||
'productMainVariant', | |||
'order-process', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the projects we will want to have separately skeleton for transport and payment and contact information.
So let's implement that's on platform first
Or what's your opinion on it?
const isWithCart = isUserLoggedIn || !!cartUuid; | ||
|
||
useEffect(() => { | ||
updatePageLoadingState({ isCartHydrated: true }); | ||
}, []); | ||
|
||
const [{ data: fetchedCartData, fetching }, fetchCart] = useCartQuery({ | ||
const [{ data: fetchedCartData, fetching: isFetching }, fetchCart] = useCartQuery({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same there isFetching too general variable for me 🤔
🌐 Live Preview: