Skip to content

refactor according to comments on previous prs#12

Merged
bc-alexsaiannyi merged 1 commit intomainfrom
refactor
Jun 12, 2023
Merged

refactor according to comments on previous prs#12
bc-alexsaiannyi merged 1 commit intomainfrom
refactor

Conversation

@bc-alexsaiannyi
Copy link
Copy Markdown
Collaborator

What / Why

This PR adds small improvements on few methods based on previously left comments.

Proof

Tested locally

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 9, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextjs-commerce ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 9, 2023 2:29pm

Comment thread lib/bigcommerce/index.ts

if (lineIds.length === 1) {
cartState = await removeCartItem(lineIds[0]!);
} else if (lineIds.length > 1) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Vercel API suggests that lineIds is string[]. For that reason we use if/else statement at the first place and now we have this check for more than 1 IDs.

As I get it actually we can't remove more than one line at a time, so actually we always get array of one Id and I'm thinking if it's safe to simplify this logic by keeping only cartState = await removeCartItem(lineIds[0]!) or smth similar.

As a safety measure we always can leave it as it is but I don't see cases when else if block will be executed...

@BC-krasnoshapka, what's your thought on this? 🤔

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest we leave it as is now, because core expects it to be array, thus we have to support array.

Comment thread lib/bigcommerce/index.ts
});
const collectionIdList = res.body.data.site.categoryTree.map(({ entityId }) => entityId);

const collections = await Promise.all(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Regarding fetching all categories via single query. In theory, we could use categoryTree query for one request but Vercel Collection requires SEO field that we can get via Category node.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK, I see the problem, let's leave it as is then.

@bc-alexsaiannyi bc-alexsaiannyi marked this pull request as ready for review June 9, 2023 14:50
Comment thread lib/bigcommerce/index.ts

if (lineIds.length === 1) {
cartState = await removeCartItem(lineIds[0]!);
} else if (lineIds.length > 1) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I suggest we leave it as is now, because core expects it to be array, thus we have to support array.

Comment thread lib/bigcommerce/index.ts
});
const collectionIdList = res.body.data.site.categoryTree.map(({ entityId }) => entityId);

const collections = await Promise.all(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OK, I see the problem, let's leave it as is then.

@bc-alexsaiannyi bc-alexsaiannyi merged commit 6665773 into main Jun 12, 2023
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