Skip to content
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

Open
wants to merge 13 commits into
base: 15.0
Choose a base branch
from

Conversation

sebaholesz
Copy link
Contributor

@sebaholesz sebaholesz commented May 7, 2024

Q A
Description, reason for the PR ...
New feature No
BC breaks No
Fixes issues ...
Have you read and signed our License Agreement for contributions? Yes

🌐 Live Preview:

@sebaholesz sebaholesz added the DX & Refactoring Requests for DX improvements and refactorings label May 7, 2024
@sebaholesz sebaholesz self-assigned this May 7, 2024
@sebaholesz sebaholesz force-pushed the sh-ssp-2096-order-process-refactoring branch 11 times, most recently from 89a19e3 to 1c0ce36 Compare May 13, 2024 15:20
@sebaholesz sebaholesz force-pushed the sh-ssp-2096-order-process-refactoring branch 7 times, most recently from 363ed66 to 41413e4 Compare May 20, 2024 15:26
@sebaholesz sebaholesz changed the title [WIP][project-base][SSP-2096] order process refactoring [project-base][SSP-2096] order process refactoring May 20, 2024
@sebaholesz sebaholesz force-pushed the sh-ssp-2096-order-process-refactoring branch from 07aeefe to 9a26c79 Compare May 21, 2024 09:09
- 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
…ress if filled for the second time

- this ensures better testing, as it checks if the address is
correctly modified
@sebaholesz sebaholesz force-pushed the sh-ssp-2096-order-process-refactoring branch from 9a26c79 to dc3cb37 Compare May 22, 2024 09:03
Copy link
Contributor

@VaniaToper VaniaToper left a 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(() => {
Copy link
Contributor

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

Comment on lines +12 to +15
const goToPreviousStepFromCartPage = () => {
updatePageLoadingState({ isPageLoading: true, redirectPageType: 'homepage' });
router.push('/');
};
Copy link
Contributor

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();
Copy link
Contributor

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

Copy link
Contributor

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 = {
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

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({
Copy link
Contributor

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',
Copy link
Contributor

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({
Copy link
Contributor

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX & Refactoring Requests for DX improvements and refactorings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants