Skip to content

Comments

fix: improve delete line from cart functionality#1044

Open
grzegorzpokorski wants to merge 1 commit intosaleor:mainfrom
grzegorzpokorski:improve-delete-line-from-cart-functionality
Open

fix: improve delete line from cart functionality#1044
grzegorzpokorski wants to merge 1 commit intosaleor:mainfrom
grzegorzpokorski:improve-delete-line-from-cart-functionality

Conversation

@grzegorzpokorski
Copy link
Contributor

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

@vercel
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

@grzegorzpokorski grzegorzpokorski Nov 28, 2023

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.

@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.

2 participants