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

fix: improve delete line from cart functionality #1044

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

grzegorzpokorski
Copy link
Contributor

Allow to function properly even without JavaScript (Progressive enhancement).

Copy link

vercel bot commented Nov 25, 2023

@grzegorzpokorski is attempting to deploy a commit to the Saleor Commerce Team on Vercel.

A member of the Team first needs to authorize it.

@grzegorzpokorski grzegorzpokorski force-pushed the improve-delete-line-from-cart-functionality branch from bac9426 to f77768f Compare November 27, 2023 13:36
Comment on lines 12 to 31
const deleteLineAction = async (lineId: string, checkoutId: string) => {
"use server";

await executeGraphQL(CheckoutDeleteLinesDocument, {
variables: {
checkoutId,
lineIds: [lineId],
},
cache: "no-cache",
});

revalidatePath("/cart");
};
Copy link
Contributor

Choose a reason for hiding this comment

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

There's already a function for that: deleteLineFromCheckout in src/app/[channel]/(main)/cart/actions.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I decided to move that action closer to the component that uses it. Do you think it is the wrong move?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or maybe I should move DeleteLineForm component closer to the /cart/page.tsx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I have introduced changes. Instead of moving components to src/ui/components, I have refactored existing components and server actions in their original places within the project structure.

src/ui/components/DeleteLineForm/DeleteLineForm.tsx Outdated Show resolved Hide resolved
@grzegorzpokorski grzegorzpokorski force-pushed the improve-delete-line-from-cart-functionality branch from 39451a6 to 9e7c463 Compare November 27, 2023 17:08
@grzegorzpokorski grzegorzpokorski marked this pull request as draft November 28, 2023 18:20
@grzegorzpokorski grzegorzpokorski force-pushed the improve-delete-line-from-cart-functionality branch from 9e7c463 to 92625e3 Compare November 28, 2023 19:19
@grzegorzpokorski grzegorzpokorski marked this pull request as ready for review November 28, 2023 20:56
…d move to the components in src/ui directory
@grzegorzpokorski grzegorzpokorski force-pushed the improve-delete-line-from-cart-functionality branch from 92625e3 to eddfbf9 Compare December 28, 2023 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants