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

✨(front) add new SaleTunnel 😎 #2355

Merged
merged 20 commits into from May 15, 2024
Merged

Conversation

NathanVss
Copy link
Member

@NathanVss NathanVss commented Apr 5, 2024

Sketches

https://www.figma.com/file/TZi5QztVxCxIaiH2kGDzm8/Untitled?type=design&node-id=63-2&mode=design&t=pO3rMuirTe10eCxP-0

Capture d’écran 2024-04-05 aΜ€ 17 42 27

Help for reviewers

In order to be able to compile and test this PR you need to build your project with the following line in your package.json

"@openfun/cunningham-react": "file:/Users/<UserName>/cunningham/packages/react",

You need to checkout and yarn install your local Cunningham project on this PR: openfun/cunningham#315

320059683-2fcfa982-f0bb-4009-8bc3-9cc4c559949f

V1 Todo List

  • sketches
  • Mocked dev
  • Responsive
  • a11y labels
  • Translations
  • Credit Card Selector
    • Dev
    • Allow to create a new credit card
    • Test
  • Address Selector
    • Dev
    • Test
  • Selecting an existing payment method should use one click payment
  • Order handling
  • Payment box
  • Handle order groups
  • CredentialSaleTunnel
  • CertificateSaleTunnel
  • Implement multiple Sale Tunnels ( modular component )
  • Handle events
  • Handle sponsors
  • Full journey test
  • Delete old Sale Tunnel
  • Migrate PaymentInterface mocks
  • Implement full name field
  • Include email field
  • Fix mono select edit selected item
  • Fix cunningham modal select menu overflow hidden

V2 Todo List

  • Payment Schedule
    • Mocked dev
    • Backend dev
    • Test
  • Contract signing

@NathanVss NathanVss self-assigned this Apr 5, 2024
@NathanVss NathanVss changed the title WIP: One-page SaleTunnel ✨(front) add new SaleTunnel 😎 Apr 22, 2024
@NathanVss NathanVss requested review from jbpenrath and rlecellier and removed request for jbpenrath April 22, 2024 15:36
@jbpenrath
Copy link
Member

I'm not able to close the modal on the validation step.

CleanShot 2024-04-23 at 16 41 31

@jbpenrath
Copy link
Member

I'll add right now the total section with the info banner.

image

@jbpenrath
Copy link
Member

Nice work, reviewable with ease πŸ‘

Copy link
Collaborator

@rlecellier rlecellier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a first look and i'll go back on it tomorow
next commit:
πŸ§‘β€πŸ’»(front) add Cunningham test utils


.c__modal__backdrop {
// Make sure the overlay is above any random 0-1-2 z-indexes in content and 200 z-index to the top bar
z-index:300;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use variable for z-index ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but here it is a special case only because richie uses different z-indexes

src/frontend/js/hooks/useMatchMedia.ts Outdated Show resolved Hide resolved
src/frontend/js/hooks/useMatchMedia.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@rlecellier rlecellier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pretty and yes easy to review.
it's quite big so i'm sure i missed some things tho.

Comment on lines +103 to +109
// This pattern is ugly but I couldn't find a better way to achieve it in a nicer way.
// Without this, when we call onPaymentSuccess() directly from the after polling function,
// it is not the latest version of the function, so the value of `order` inside the context function (defined in GenericSaleTunnel.tsx)
// will be undefined, then calling onFinish(order) with an undefined order.
const onPaymentSuccessRef = useRef(onPaymentSuccess);
onPaymentSuccessRef.current = onPaymentSuccess;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving most part of onPaymentSuccess here ?
We could have this function define here with :

WebAnalyticsAPIHandler()?.sendCourseProductEvent(
          CourseProductEvent.PAYMENT_SUCCEED,
          props.eventKey,
        );
        // Once the user has completed the purchase, we need to refetch the orders
        // to update the ordersQuery cache
        invalidateOrders();
        refetchOmniscientOrders();
        queryClient.invalidateQueries({ queryKey: ['user', 'enrollments'] });
        props.onFinish?.(order!);

GenericSaleTunnel would just keep the step change.

Then you already retrieve the new order in this component(GenericPaymentButton), it could be used for onFinish()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand your point. My approach is to make sure that this button can be generic, in the V2 we will have different buttons based on which type of sale tunnel we're in so I think having this logic inside the generic sale tunnel for know better split the SRPs

@NathanVss NathanVss force-pushed the feat/saletunnel-onepage branch 4 times, most recently from e7cd02d to 97bcb0a Compare May 7, 2024 12:35
@NathanVss NathanVss requested a review from jbpenrath May 7, 2024 12:37
@jbpenrath
Copy link
Member

jbpenrath commented May 7, 2024

Few feedbacks on UI/UX :

1. Email address
IMO it's hard to see the email here as the helper text has the same font size, the same color. Maybe just using a lighter color for the helper text could help to structure information ?
image

2. Address creation
When a user has a registered address, this one is selected by default. As this one is selected, there is a button to edit this address. I'm afraid that the ux of that is weird as to use a new address, I feel most user will click on edit button to change address instead of unselect the address then click on the create button.
image
image

3. Default credit card icon is white
The default credit icon is white so it is not visible.
image

4. Credit card selection
I wonder if the pencil without label to switch credit card cannot be confusing? I'm still wonder if it would be not better to display the list of credit card with a radio button directly ?
image

Comment on lines +105 to +127
export function getAddressLabel(address: Address) {
const part = [
address.first_name,
address.last_name,
address.address,
address.postcode,
address.city,
address.country,
].join(' ');
if (address.title) {
return `${address.title} - ${part}`;
}
return part;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it could be cool on two lines, but I think we will have to use a custom component to use a smaller font-size.

Work
13 quai des anglais, 75000 Paris - FR

Home
11 rue stine, 75000 Paris - FR

src/frontend/js/components/SaleTunnel/_styles.scss Outdated Show resolved Hide resolved
@NathanVss
Copy link
Member Author

@jbpenrath I can't reply to your comment about having address title on top (why?)

Here is the result. We can only render the custom content in the dropdown, inside the field it break the height of the select which has a hard-defined height, so I used the option to display the label instead.

Capture d’écran 2024-05-10 aΜ€ 14 53 37

@NathanVss NathanVss requested a review from jbpenrath May 13, 2024 13:34
Copy link
Member

@jbpenrath jbpenrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I miss that, but you must not use color token directly in sass files. Instead you must create a dedicated scheme for a component then use r-theme-val to set the color in the component sass file.

e.g:

color: r-theme-val(dashboard-credit-cards, empty-color);

dashboard-credit-cards: (
empty-color: r-color(slate-grey),
),

@NathanVss NathanVss requested a review from jbpenrath May 15, 2024 09:31
Copy link
Member

@jbpenrath jbpenrath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And finally it looks good to me. Well done ! πŸš€

src/frontend/scss/colors/_theme.scss Outdated Show resolved Hide resolved
The existing script was not generating all the files.
We will need this color in the PaymentSchedule component.
This in needed in order to be able to use Cunningham components in its
children. We also define the modal parent selector.
This helper is currently needed to change the button fullWidth flags
based on the size of the screen.
This component will be used to display upcoming and paid transactions.
For the address forms used in the sale tunnel we need to be able to reset
its values.
This component is used to select / create or edit addresses.
The credit card logo used in the CreditCardSelector have a different style
than the existing ones.
This component is used to select an existing credit card or to
choose to register a new one during payment.
These components will be used by different sale tunnels to display
informations for each product. There are generic components.
It is mainly used to display target courses of the matching product course.
Those mainly focus on Select test utils that are really handy.
This one will be replaced with the new SaleTunnel, it is not longer needed.
The sale tunnel will be replaced by a new one that is able to handle
numerous new features.
This new SaleTunnel is a one page components providing a versatile
generic component that can be used to create various versions of
sale tunnels. At the moment there are two main variants which are
CertificateSaleTunnel and CredentialSaleTunnel.
We now want to use the new sale tunnel to buy product.
By adding this full name form we extract the responsability to save
the form up to the sale tunnel via submitCallbacks. Under the hood
it stays the same.
Previously we were using an input to render a read only field, which
was not indeal. Here is the new design based on sketches.
It was lacking a11y, giving initials to a title is great, but it's better
to give the full title via aria label.
When the avatar was used standalone the initials positionned with
absolute we not contextualized via their own container, so they were
positionned based on the nearest relative/absolute parent.
Previously the credit card logos were rendered on top of a blue
background, but as it is not the case in the sale tunnel, we got
white logos on top of white background, which was not ideal. Now
the approach is to make sure logos are self-visible on their own.
@NathanVss NathanVss enabled auto-merge (rebase) May 15, 2024 13:56
@NathanVss NathanVss merged commit 890ce08 into master May 15, 2024
20 checks passed
@NathanVss NathanVss deleted the feat/saletunnel-onepage branch May 15, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants