You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3, because the PR involves multiple files and components with both frontend and backend changes, including Vue components, API service modifications, and GraphQL queries. The complexity of the changes, especially with the addition of auction functionality, requires careful review to ensure functionality and integration.
🧪 Relevant tests
No
⚡ Possible issues
Possible Bug: The getCurrentBlock method in CreateListing.vue does not handle the case where the GetBlocks query might return an empty array, which would cause an error when trying to access res.data.GetBlocks.edges[0].node.number.
Data Validation Issue: The validation schema in CreateListing.vue might not properly handle cases where enableAuction is false but auctionDataStart and auctionDataEnd fields are still provided by the user, leading to potential inconsistent data submission.
Consider adding error handling for the case where the GetBlocks query returns an empty array to prevent runtime errors. This can be done by checking if res.data.GetBlocks.edges.length > 0 before setting auctionDataStart.value. [important]
Add a validation condition to ensure that auctionDataStart and auctionDataEnd are not provided when enableAuction is false. This can be done by enhancing the conditional validation in the Yup schema to ignore these fields if the auction is not enabled. [important]
Add validation to ensure auction start and end blocks are set in the future
Consider adding a validation check for auctionDataStart and auctionDataEnd to ensure they are not set to past block numbers when enableAuction is true. This will prevent users from accidentally setting an auction with invalid start or end blocks.
auctionDataStart: yup.string().when('enableAuction', {
is: true,
- then: () => numberRequiredSchema.typeError('Auction Start Block must be a number'),+ then: () => numberRequiredSchema.min(currentBlock, 'Auction Start Block must be in the future').typeError('Auction Start Block must be a number'),
otherwise: () => yup.string().notRequired(),
}),
auctionDataEnd: yup.string().when('enableAuction', {
is: true,
- then: () => numberRequiredSchema.typeError('Auction End Block must be a number'),+ then: () => numberRequiredSchema.min(currentBlock, 'Auction End Block must be in the future').typeError('Auction End Block must be a number'),
otherwise: () => yup.string().notRequired(),
}),
Suggestion importance[1-10]: 9
Why: This suggestion addresses a potential issue where users could set auction start and end blocks to past values, which would be invalid. Adding this validation improves the robustness of the application.
9
Modify the watch function to clear auction data fields immediately when the auction is disabled
To improve the user experience and avoid unnecessary API calls, consider disabling the getCurrentBlock function call when the auction is disabled, and clear the auction data fields immediately.
Why: This suggestion improves the user experience by ensuring that auction data fields are cleared immediately when the auction is disabled, preventing any confusion or unnecessary API calls.
7
Possible issue
Improve error handling in the getCurrentBlock function to handle empty or invalid responses
Implement error handling for the getCurrentBlock function to manage cases where the API call fails, preventing the application from crashing and providing feedback to the user.
const getCurrentBlock = async () => {
try {
const res = await MarketplaceApi.getCurrentBlock();
- auctionDataStart.value = res.data?.GetBlocks?.edges[0].node.number;+ if (res.data && res.data.GetBlocks && res.data.GetBlocks.edges.length > 0) {+ auctionDataStart.value = res.data.GetBlocks.edges[0].node.number;+ } else {+ throw new Error('No block data available');+ }
} catch (e) {
snackbar.error({
title: 'Failed to get current block',
- text: 'Please try again.',+ text: 'No block data available. Please try again.',
});
}
};
Suggestion importance[1-10]: 8
Why: This suggestion enhances the error handling of the getCurrentBlock function, ensuring that the application can gracefully handle cases where the API response is empty or invalid, thus improving user experience and reliability.
8
Possible bug
Ensure auction data is only included in the request payload when all required fields are valid
Refactor the createListing function to handle the case where enableAuction is false more gracefully by ensuring that the auction data is not included in the request payload, thus avoiding potential errors on the server side.
Why: This suggestion prevents potential errors on the server side by ensuring that auction data is only included in the request payload when all required fields are valid, thus improving the robustness of the createListing function.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Bug fix
Description
Chip.vue
to fix background color class binding for non-error states.CollapseFilter.vue
to use dynamic theme fromuseAppStore
.--popper-theme-padding
CSS variable inPopover.vue
.CreateListing.vue
by adding auction functionality, removing theaccount
field, and updating validation schema.marketplace.ts
to removeaccount
fromcreateListing
and addedgetCurrentBlock
method.GetBlocks
query toqueries.ts
andGetBlocks.ts
.account
parameter fromCreateListing
mutation.Changes walkthrough 📝
Chip.vue
Update class binding for non-error state background colors
resources/js/components/Chip.vue
bg-light-surface-background
andbg-dark-surface-background
.CollapseFilter.vue
Use dynamic theme from store in Popover component
resources/js/components/CollapseFilter.vue
theme
binding to use value fromuseAppStore
.useAppStore
.Popover.vue
Add popper theme padding variable in light mode
resources/js/components/Popover.vue
--popper-theme-padding
CSS variable with value0
in light mode.CreateListing.vue
Add auction functionality and remove account field in CreateListing
resources/js/components/pages/create/CreateListing.vue
account
field from the form.enableAuction
checkbox and conditional auction fields.getCurrentBlock
method to fetch the current block number.enableAuction
to reset auction fields when toggled.marketplace.ts
Update createListing method and add getCurrentBlock method
resources/js/api/marketplace.ts
account
fromcreateListing
method.getCurrentBlock
method to fetch the current block number.queries.ts
Add GetBlocks query to exports
resources/js/api/queries.ts
GetBlocks
query to the export list.CreateListing.ts
Remove account parameter from CreateListing mutation
resources/js/graphql/mutation/marketplace/CreateListing.ts
account
parameter fromCreateListing
mutation.GetBlocks.ts
Add GetBlocks query to fetch block numbers
resources/js/graphql/query/marketplace/GetBlocks.ts
GetBlocks
to fetch block numbers.