-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
best deals expansions #492
Conversation
WalkthroughThe changes introduce an Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Form
participant Dropdown
User->>Form: Open Best Deals Form
Form->>Dropdown: Load Options
Dropdown->>Form: Display Options (Current Content)
User->>Form: Select Option
Form->>Dropdown: Update Selection
Dropdown->>Form: Confirm Selection
TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@@ -34,7 +34,8 @@ const defaultFormValues = { | |||
itemSubClass: '-1', | |||
discount: '90', | |||
minPrice: '2000', | |||
salesPerDay: '1.1' | |||
salesPerDay: '1.1', | |||
expansionNumber: '-1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai tell me exactly what files to update and changes that need to be made
it will be similar to this pr #485
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cohenaj194, here are the files that need to be updated to integrate the expansionNumber
parameter into the wow.best-deals._index.tsx
route, similar to the changes made in PR #485:
-
app/routes/wow.best-deals._index.tsx
:- Loader Function: Update the loader function to include
expansionNumber
in thevalues
object and validate it usingparseStringToNumber
. - Action Function: Ensure that the
expansionNumber
is passed to theWoWBestDeals
API request. - Form Handling: Add a new form field for
expansionNumber
in the form component, similar to how it's done inwow.marketshare._index.tsx
.
- Loader Function: Update the loader function to include
-
app/components/form/WoW/WoWScanForm.tsx
:- Form Field: Add a form field for
expansionNumber
if it’s not already present. This will allow users to select the expansion number when searching for best deals.
- Form Field: Add a form field for
-
app/requests/WoW/BestDeals.ts
:- API Request: Ensure that the
expansionNumber
is included in the API request payload, similar to how it’s done inItemStatLookup.ts
.
- API Request: Ensure that the
These changes will ensure that the expansionNumber
parameter is correctly integrated and handled throughout the wow.best-deals._index.tsx
route.
Let me know if you need further assistance!
Analysis chain
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for references to `expansionNumber` in the codebase to identify where it needs to be added or updated.
rg 'expansionNumber'
Length of output: 1299
Learnings added
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#492
File: app/routes/wow.best-deals._index.tsx:38-38
Timestamp: 2024-09-02T01:07:41.642Z
Learning: When adding the `expansionNumber` parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in the `wow.marketshare._index.tsx` route.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Learnings used
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#0
File: :0-0
Timestamp: 2024-06-09T21:34:49.875Z
Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#485
File: app/routes/wow.marketshare._index.tsx:35-35
Timestamp: 2024-08-25T18:00:21.008Z
Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the `expansion_number` parameter is mapped correctly to the expansion names and that the default value is `-1`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok lets start with app/routes/wow.best-deals._index.tsx
can you make me a full updated version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cohenaj194, here is the full updated version of the app/routes/wow.best-deals._index.tsx
file with the necessary changes to integrate the expansionNumber
parameter:
import type { ActionFunction, LoaderFunction } from '@remix-run/cloudflare'
import { json } from '@remix-run/cloudflare'
import { useEffect, useState } from 'react'
import { PageWrapper } from '~/components/Common'
import SmallFormContainer from '~/components/form/SmallFormContainer'
import type { DealItem, WoWDealResponse } from '~/requests/WoW/BestDeals'
import WoWBestDeals from '~/requests/WoW/BestDeals'
import { getUserSessionData } from '~/sessions'
import z from 'zod'
import { useActionData, useLoaderData, useNavigation } from '@remix-run/react'
import { InputWithLabel } from '~/components/form/InputWithLabel'
import Select from '~/components/form/select'
import NoResults from '~/components/Common/NoResults'
import SmallTable from '~/components/WoWResults/FullScan/SmallTable'
import type { ColumnList } from '~/components/types'
import ExternalLink from '~/components/utilities/ExternalLink'
import { ItemClassSelect } from '~/components/form/WoW/WoWScanForm'
import {
parseStringToNumber,
parseZodErrorsToDisplayString
} from '~/utils/zodHelpers'
import {
getActionUrl,
handleCopyButton,
handleSearchParamChange
} from '~/utils/urlSeachParamsHelpers'
import { SubmitButton } from '~/components/form/SubmitButton'
const PAGE_URL = '/wow/best-deals'
const defaultFormValues = {
type: 'df',
itemClass: '-1',
itemSubClass: '-1',
discount: '90',
minPrice: '2000',
salesPerDay: '1.1',
expansionNumber: '-1' // Added expansionNumber to defaultFormValues
}
const inputMap: Record<string, string> = {
type: 'Item Type',
itemClass: 'Item Class',
itemSubClass: 'Item Subclass',
discount: 'Discount Percentage',
minPrice: 'Minimum TSM Average Price',
salesPerDay: 'Sales Per Day',
expansionNumber: 'Expansion Number' // Added expansionNumber to inputMap
}
const validateInput = z.object({
type: z.string(),
itemClass: parseStringToNumber,
itemSubClass: parseStringToNumber,
discount: parseStringToNumber,
minPrice: parseStringToNumber,
salesPerDay: z
.string()
.min(1)
.transform((value) => parseFloat(value)),
expansionNumber: parseStringToNumber // Added validation for expansionNumber
})
// Overwrite default meta in the root.tsx
export const meta: MetaFunction = () => {
return {
charset: 'utf-8',
viewport: 'width=device-width,initial-scale=1',
title: 'Saddlebag Exchange: WoW Auctionhouse Best Deals',
description:
'Find the best deals on every auctionhouse region wide with our WoW Best Deals search!'
}
}
export const links: LinksFunction = () => [
{ rel: 'canonical', href: 'https://saddlebagexchange.com/wow/best-deals' }
]
export const loader: LoaderFunction = async ({ request }) => {
const params = new URL(request.url).searchParams
const values = {
type: params.get('type') || defaultFormValues.type.toString(),
itemClass:
params.get('itemClass') || defaultFormValues.itemClass.toString(),
itemSubClass:
params.get('itemSubClass') || defaultFormValues.itemSubClass.toString(),
discount: params.get('discount') || defaultFormValues.discount.toString(),
minPrice: params.get('minPrice') || defaultFormValues.minPrice.toString(),
salesPerDay:
params.get('salesPerDay') || defaultFormValues.salesPerDay.toString(),
expansionNumber:
params.get('expansionNumber') || defaultFormValues.expansionNumber.toString() // Added expansionNumber to loader values
}
const validParams = validateInput.safeParse(values)
if (!validParams.success) {
return json({
exception: parseZodErrorsToDisplayString(validParams.error, inputMap)
})
}
return json(validParams.data)
}
export const action: ActionFunction = async ({ request }) => {
const session = await getUserSessionData(request)
const region = session.getWoWSessionData().region
const formData = Object.fromEntries(await request.formData())
const validatedFormData = validateInput.safeParse(formData)
if (!validatedFormData.success) {
return json({
exception: parseZodErrorsToDisplayString(
validatedFormData.error,
inputMap
)
})
}
const result = await WoWBestDeals({
region,
...validatedFormData.data
})
// await the result and then return the json
return json({
...(await result.json()),
sortby: 'discount'
})
}
type ActionResponseType =
| {}
| { exception: string }
| (WoWDealResponse & { sortby: string })
const BestDeals = () => {
const loaderData = useLoaderData<typeof defaultFormValues>()
const result = useActionData<ActionResponseType>()
const transistion = useNavigation()
const isSubmitting = transistion.state === 'submitting'
const [searchParams, setSearchParams] = useState<typeof defaultFormValues>({
...loaderData
})
const error = result && 'exception' in result ? result.exception : undefined
if (result && !Object.keys(result).length) {
return <NoResults href={PAGE_URL} />
}
if (result && 'data' in result && !error) {
return <Results {...result} />
}
const handleSubmit = (
event: React.MouseEvent<HTMLButtonElement, MouseEvent>
) => {
if (isSubmitting) {
event.preventDefault()
}
}
const handleFormChange = (
name: keyof typeof defaultFormValues,
value: string
) => {
handleSearchParamChange(name, value)
setSearchParams((prev) => ({ ...prev, [name]: value }))
}
return (
<PageWrapper>
<SmallFormContainer
title="Best Deals"
description="Find the best deals on your server and region wide with our Best Deals search!"
onClick={handleSubmit}
error={error}
loading={isSubmitting}
action={getActionUrl(PAGE_URL, searchParams)}>
<div className="pt-2">
<div className="flex justify-end mb-2">
<SubmitButton
title="Share this search!"
onClick={handleCopyButton}
type="button"
/>
</div>
</div>
<div className="pt-3 flex flex-col">
<Select
title="Item Type"
name="type"
defaultValue={loaderData.type}
options={[
{ label: 'Current Content', value: 'df' },
{ label: 'Pets Only', value: 'pets' },
{ label: 'Legacy Only', value: 'legacy' },
{ label: 'All', value: 'all' }
]}
onChange={(e) => handleFormChange('type', e.target.value)}
/>
<ItemClassSelect
itemClass={parseInt(loaderData.itemClass)}
itemSubClass={parseInt(loaderData.itemSubClass)}
onChange={(itemClassValue, itemSubClassValue) => {
handleFormChange('itemClass', itemClassValue.toString())
handleFormChange('itemSubClass', itemSubClassValue.toString())
}}
/>
<InputWithLabel
labelTitle="Discount Percentage"
name="discount"
type="number"
defaultValue={loaderData.discount}
min={0}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleFormChange('discount', e.currentTarget.value)
}
/>
<InputWithLabel
labelTitle="Minimum TSM Average Price"
name="minPrice"
type="number"
defaultValue={loaderData.minPrice}
min={0}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleFormChange('minPrice', e.currentTarget.value)
}
/>
<InputWithLabel
labelTitle="Sales Per Day"
name="salesPerDay"
type="number"
defaultValue={loaderData.salesPerDay}
step={0.01}
min={0}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleFormChange('salesPerDay', e.currentTarget.value)
}
/>
<InputWithLabel
labelTitle="Expansion Number"
name="expansionNumber"
type="number"
defaultValue={loaderData.expansionNumber}
min={-1}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
handleFormChange('expansionNumber', e.currentTarget.value)
}
/>
</div>
</SmallFormContainer>
</PageWrapper>
)
}
export default BestDeals
const Results = ({ data, sortby }: WoWDealResponse & { sortby: string }) => {
useEffect(() => {
if (window && document) {
window.scroll({ top: 0, behavior: 'smooth' })
}
}, [])
return (
<PageWrapper>
<SmallTable
title="Best Deals"
sortingOrder={[{ desc: true, id: sortby }]}
columnList={columnList}
mobileColumnList={mobileColumnList}
columnSelectOptions={[
'discount',
'salesPerDay',
'minPrice',
'historicPrice'
]}
data={data}
csvOptions={{
filename: 'saddlebag-best-deals.csv',
columns: [
{ title: 'Item ID', value: 'itemID' },
{ title: 'Item Name', value: 'itemName' },
{ title: 'Min Price', value: 'minPrice' },
{ title: 'Historic Price', value: 'historicPrice' },
{ title: 'Min Price', value: 'Sales Per Day' },
{ title: 'Discount', value: 'discount' },
{ title: 'Realm', value: 'realmName' },
{ title: 'Connected Realm ID', value: 'connectedRealmId' }
]
}}
/>
</PageWrapper>
)
}
const columnList: Array<ColumnList<DealItem>> = [
{ columnId: 'itemName', header: 'Item Name' },
{
columnId: 'realmName',
header: 'Realm Name',
accessor: ({ row }) => (
<p className=" px-3 py-2 max-w-[200px] overflow-x-scroll">
{row.realmName}
</p>
)
},
{
columnId: 'exportLink',
header: 'Where to Sell',
accessor: ({ getValue }) => <ExternalLink link={getValue() as string} />
},
{
columnId: 'link',
header: 'Undermine Link',
accessor: ({ getValue }) => <ExternalLink link={getValue() as string} />
},
{ columnId: 'discount', header: 'Discount' },
{ columnId: 'salesPerDay', header: 'Sales Per Day' },
{ columnId: 'minPrice', header: 'Minimum Price' },
{ columnId: 'historicPrice', header: 'Historic Price' }
]
const mobileColumnList: Array<ColumnList<DealItem>> = [
{ columnId: 'discount', header: 'Discount' },
{ columnId: 'itemName', header: 'Item Name' }
]
This updated version includes the necessary changes to integrate the expansionNumber
parameter into the loader and action functions, form components, and API requests, as discussed. Let me know if you need any further adjustments!
Learnings used
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#485
File: app/routes/wow.marketshare._index.tsx:35-35
Timestamp: 2024-08-25T18:00:21.008Z
Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the `expansion_number` parameter is mapped correctly to the expansion names and that the default value is `-1`.
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#492
File: app/routes/wow.best-deals._index.tsx:38-38
Timestamp: 2024-09-02T01:07:41.860Z
Learning: When adding the `expansionNumber` parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in the `wow.marketshare._index.tsx` route.
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#0
File: :0-0
Timestamp: 2024-06-09T21:34:49.875Z
Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai add to your memory that I want to use ExpansionSelect
from ./app/components/form/WoW/WoWScanForm.tsx when adding expansion buttons to web forms
<ExpansionSelect
defaultValue={loaderData.expansionNumber}
onChange={(value) => handleFormChange('expansionNumber', value)}
/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cohenaj194, I've added your preference to use the ExpansionSelect
component from ./app/components/form/WoW/WoWScanForm.tsx
whenever possible to my memory. This will be taken into account in future reviews.
Learnings added
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#492
File: app/routes/wow.best-deals._index.tsx:38-38
Timestamp: 2024-09-02T01:29:36.785Z
Learning: User: cohenaj194 prefers to use the `ExpansionSelect` component from `./app/components/form/WoW/WoWScanForm.tsx` whenever possible. The component should be used as shown in the following code snippet:
```typescript
<ExpansionSelect
defaultValue={loaderData.expansionNumber}
onChange={(value) => handleFormChange('expansionNumber', value)}
/>
> Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings).
</details>
---
<details>
<summary>Learnings used</summary>
Learnt from: cohenaj194
PR: #492
File: app/routes/wow.best-deals._index.tsx:38-38
Timestamp: 2024-09-02T01:07:41.860Z
Learning: When adding the expansionNumber
parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in the wow.marketshare._index.tsx
route.
---
Learnt from: cohenaj194
PR: #485
File: app/routes/wow.marketshare._index.tsx:35-35
Timestamp: 2024-08-25T18:00:21.008Z
Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the expansion_number
parameter is mapped correctly to the expansion names and that the default value is -1
.
---
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#0
File: :0-0
Timestamp: 2024-06-09T21:34:49.875Z
Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
</details>
<!-- This is an auto-generated reply by CodeRabbit -->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/routes/wow.best-deals._index.tsx (2 hunks)
Additional context used
Learnings (2)
Common learnings
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#485 File: app/routes/wow.marketshare._index.tsx:35-35 Timestamp: 2024-08-25T18:00:21.008Z Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the `expansion_number` parameter is mapped correctly to the expansion names and that the default value is `-1`.
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#0 File: :0-0 Timestamp: 2024-06-09T21:34:49.875Z Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
app/routes/wow.best-deals._index.tsx (1)
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#485 File: app/routes/wow.marketshare._index.tsx:35-35 Timestamp: 2024-08-25T18:00:21.008Z Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the `expansion_number` parameter is mapped correctly to the expansion names and that the default value is `-1`.
Additional comments not posted (2)
app/routes/wow.best-deals._index.tsx (2)
37-38
: LGTM! Consider completing the implementation ofexpansionNumber
.The addition of
expansionNumber
with a default value of '-1' is correct and aligns with the previous learnings. However, there are a few points to consider:
- The
expansionNumber
is not used elsewhere in the visible code. Ensure that it's properly implemented in theBestDeals
component.- Update the
validateInput
schema to includeexpansionNumber
. This will ensure proper validation when the form is submitted.To verify the usage of
expansionNumber
, run the following script:
195-195
: LGTM! Consider updating the option value to match the new label.The change from 'Dragonflight Only' to 'Current Content' is a good improvement, making the label more generic and future-proof. However, there are a couple of points to consider:
- The
value
for this option is still 'df', which might be confusing or outdated. Consider updating it to a more generic value, such as 'current'.- Ensure that this change is reflected in any other parts of the application that might be using the 'df' value for filtering or processing.
To verify the impact of this change and find any potential areas that need updating, run the following script:
Deploying saddlebag-with-pockets with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/routes/wow.best-deals.recommended.tsx (6 hunks)
Additional context used
Learnings (2)
Common learnings
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#485 File: app/routes/wow.marketshare._index.tsx:35-35 Timestamp: 2024-08-25T18:00:21.008Z Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the `expansion_number` parameter is mapped correctly to the expansion names and that the default value is `-1`.
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#492 File: app/routes/wow.best-deals._index.tsx:38-38 Timestamp: 2024-09-02T01:07:41.860Z Learning: When adding the `expansionNumber` parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in the `wow.marketshare._index.tsx` route.
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#0 File: :0-0 Timestamp: 2024-06-09T21:34:49.875Z Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.
app/routes/wow.best-deals.recommended.tsx (1)
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#492 File: app/routes/wow.best-deals._index.tsx:38-38 Timestamp: 2024-09-02T01:07:41.860Z Learning: When adding the `expansionNumber` parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in the `wow.marketshare._index.tsx` route.
defaultTWW: | ||
'/wow/best-deals?type=df&itemClass=-1&itemSubClass=-1&discount=50&minPrice=2000&salesPerDay=1.1&expansionNumber=11', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update searchParams
object to reflect new expansion
The searchParams
object has been updated to replace "Dragonflight" references with "TWW" (The War Within). The expansionNumber=11
parameter has been added to the URLs.
However, consider the following suggestions:
- Update the
illusionsAndConsumables
URL to include theexpansionNumber=11
parameter for consistency. - Consider adding a comment explaining what the
expansionNumber
represents for better code readability.
Example:
const searchParams = {
defaultTWW:
'/wow/best-deals?type=df&itemClass=-1&itemSubClass=-1&discount=50&minPrice=2000&salesPerDay=1.1&expansionNumber=11',
// ... other params ...
recipesTWW:
'/wow/best-deals?type=df&itemClass=9&itemSubClass=-1&discount=50&minPrice=10000&salesPerDay=0.1&expansionNumber=11',
// ... other params ...
- illusionsAndConsumables:
- '/wow/best-deals?type=df&itemClass=0&itemSubClass=-1&discount=50&minPrice=100&salesPerDay=0.1',
+ illusionsAndConsumables:
+ '/wow/best-deals?type=df&itemClass=0&itemSubClass=-1&discount=50&minPrice=100&salesPerDay=0.1&expansionNumber=11',
// ... other params ...
}
Also applies to: 37-38
name: 'Default TWW Deals', | ||
description: 'Find deals on current content.', | ||
Icon: DocumentSearchIcon, | ||
href: searchParams.defaultDragonflight | ||
href: searchParams.defaultTWW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update recommendedQueries
to reflect new expansion
The recommendedQueries
array has been updated to replace "Dragonflight" references with "TWW" (The War Within).
However, consider the following suggestions:
- Update the
description
for the "Illusions and Consumables" query to remove the "Dragonflight" reference. - Consider adding a comment explaining what TWW stands for, for better code readability.
Example:
const recommendedQueries = [
// ... other queries ...
{
name: 'Default TWW Deals',
description: 'Find deals on current content.',
Icon: DocumentSearchIcon,
href: searchParams.defaultTWW
},
// ... other queries ...
{
name: 'TWW Recipes',
description: 'Find TWW recipes at a discount for crafting advancements.',
Icon: DocumentSearchIcon,
href: searchParams.recipesTWW
},
// ... other queries ...
{
name: 'Illusions and Consumables',
- description: 'Seek out deals on Weapon Illusions and consumable transmog.',
+ description: 'Seek out deals on TWW Weapon Illusions and consumable transmog.',
Icon: DocumentSearchIcon,
href: searchParams.illusionsAndConsumables
},
// ... other queries ...
]
// Add a comment explaining TWW
// TWW: The War Within (latest World of Warcraft expansion)
Also applies to: 115-118, 129-129
Quality Gate passedIssues Measures |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
app/routes/wow.best-deals._index.tsx (1)
63-64
: Type Safety Concerns withparseNumber
FunctionThe
parseNumber
function currently accepts a parameter of typeany
, which can lead to unsafe type handling. SinceparseStringToNumber
is defined asz.string().min(1).transform(parseNumber)
, the parameter forparseNumber
should be explicitly typed asstring
to ensure type safety and align with the expectations set byz.string()
.
- Consider updating the
parseNumber
function to accept astring
parameter instead ofany
to prevent potential type mismatches and improve type safety.Analysis chain
LGTM: Validation for
expansionNumber
added correctly.The
expansionNumber
has been added to thevalidateInput
schema usingparseStringToNumber
, which is correct.However, there are some type safety concerns flagged by the static analysis tool:
- On line 63, there's a warning about an unsafe argument of type
any
assigned to a parameter of typestring
.- On line 63, there's also a warning about unsafe member access
.transform
on anerror
typed value.- On line 64, there's a warning about unsafe assignment of an error typed value.
These warnings suggest that we might need to add some type assertions or checks to ensure type safety. Could you verify if these warnings are valid in the context of the
zod
library usage? If they are, we might need to add appropriate type guards or assertions.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check the zod library usage and type definitions grep -rn "z.string()" app/ grep -rn "parseStringToNumber" app/utils/zodHelpers.tsLength of output: 2036
Script:
#!/bin/bash # Use ast-grep to find the usage of parseStringToNumber in app/routes/wow.best-deals._index.tsx ast-grep --lang typescript --pattern 'parseStringToNumber' app/routes/wow.best-deals._index.tsx # Check the definition of parseNumber in app/utils/zodHelpers/index.ts grep -A 5 'function parseNumber' app/utils/zodHelpers/index.tsLength of output: 160
Script:
#!/bin/bash # Use rg to find the usage of parseStringToNumber in app/routes/wow.best-deals._index.tsx rg 'parseStringToNumber' app/routes/wow.best-deals._index.tsx -A 5 # Use rg to find the definition of parseNumber in app/utils/zodHelpers/index.ts rg 'parseNumber' app/utils/zodHelpers/index.ts -A 5Length of output: 1035
Tools
GitHub Check: Codacy Static Code Analysis
[failure] 63-63: app/routes/wow.best-deals._index.tsx#L63
Unsafe argument of typeany
assigned to a parameter of typestring
.
[failure] 63-63: app/routes/wow.best-deals._index.tsx#L63
Unsafe member access .transform on anerror
typed value.
[failure] 64-64: app/routes/wow.best-deals._index.tsx#L64
Unsafe assignment of an error typed value.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- app/routes/wow.best-deals._index.tsx (6 hunks)
Additional context used
Learnings (2)
Common learnings
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#485 File: app/routes/wow.marketshare._index.tsx:35-35 Timestamp: 2024-08-25T18:00:21.008Z Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that the `expansion_number` parameter is mapped correctly to the expansion names and that the default value is `-1`.
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#492 File: app/routes/wow.best-deals._index.tsx:38-38 Timestamp: 2024-09-02T01:07:41.860Z Learning: When adding the `expansionNumber` parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in the `wow.marketshare._index.tsx` route.
Learnt from: cohenaj194 PR: ff14-advanced-market-search/saddlebag-with-pockets#492 File: app/routes/wow.best-deals._index.tsx:38-38 Timestamp: 2024-09-02T01:29:37.020Z Learning: User: cohenaj194 prefers to use the `ExpansionSelect` component from `./app/components/form/WoW/WoWScanForm.tsx` whenever possible. The component should be used as shown in the following code snippet: ```typescript <ExpansionSelect defaultValue={loaderData.expansionNumber} onChange={(value) => handleFormChange('expansionNumber', value)} />
Learnt from: cohenaj194
PR: ff14-advanced-market-search/saddlebag-with-pockets#0
File: :0-0
Timestamp: 2024-06-09T21:34:49.875Z
Learning: User: cohenaj194 prefers detailed, actionable responses that directly address the code issues with specific solutions and examples.</blockquote></details> <details> <summary>app/routes/wow.best-deals._index.tsx (3)</summary><blockquote>
Learnt from: cohenaj194
PR: #492
File: app/routes/wow.best-deals._index.tsx:38-38
Timestamp: 2024-09-02T01:29:37.020Z
Learning: User: cohenaj194 prefers to use theExpansionSelect
component from./app/components/form/WoW/WoWScanForm.tsx
whenever possible. The component should be used as shown in the following code snippet:<ExpansionSelect defaultValue={loaderData.expansionNumber} onChange={(value) => handleFormChange('expansionNumber', value)} />
Learnt from: cohenaj194
PR: #485
File: app/routes/wow.marketshare._index.tsx:35-35
Timestamp: 2024-08-25T18:00:21.008Z
Learning: When adding a new menu option for expansions in the WoW Marketshare form, ensure that theexpansion_number
parameter is mapped correctly to the expansion names and that the default value is-1
.
Learnt from: cohenaj194
PR: #492
File: app/routes/wow.best-deals._index.tsx:38-38
Timestamp: 2024-09-02T01:07:41.860Z
Learning: When adding theexpansionNumber
parameter to a new route, ensure that it is integrated into the loader and action functions, form components, and API requests, similar to how it is handled in thewow.marketshare._index.tsx
route.</blockquote></details> </blockquote></details> <details> <summary>GitHub Check: Codacy Static Code Analysis</summary><blockquote> <details> <summary>app/routes/wow.best-deals._index.tsx</summary><blockquote> [failure] 63-63: app/routes/wow.best-deals._index.tsx#L63 Unsafe argument of type `any` assigned to a parameter of type `string`. --- [failure] 63-63: app/routes/wow.best-deals._index.tsx#L63 Unsafe member access .transform on an `error` typed value. --- [failure] 64-64: app/routes/wow.best-deals._index.tsx#L64 Unsafe assignment of an error typed value. </blockquote></details> </blockquote></details> </details> <details> <summary>Additional comments not posted (5)</summary><blockquote> <details> <summary>app/routes/wow.best-deals._index.tsx (5)</summary><blockquote> `17-20`: **LGTM: Import statement updated correctly.** The `ExpansionSelect` component has been added to the import statement, which aligns with the requirement to use this component in the form. --- `40-41`: **LGTM: Default value for `expansionNumber` added correctly.** The `expansionNumber` property has been added to `defaultFormValues` with a default value of '-1', which is correct and follows the best practices for handling expansion numbers. --- `50-51`: **LGTM: Input map updated with `expansionNumber`.** The `expansionNumber` has been added to the `inputMap` with the label 'WoW Expansion', which provides a clear description for the new input field. --- `94-97`: **LGTM: Loader function updated to include `expansionNumber`.** The `expansionNumber` has been correctly added to the `values` object in the loader function. This ensures that the expansion number is properly retrieved from the URL parameters or set to the default value if not present. --- `203-213`: **LGTM: Form component updated with `ExpansionSelect` and revised options.** The following changes have been implemented correctly: 1. The "Item Type" select options have been updated, changing "Dragonflight Only" to "Current Content". 2. The `ExpansionSelect` component has been added to the form, using the correct props as specified in the learning. These changes improve the form's functionality and align with the project's requirements. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Summary by CodeRabbit
These changes improve the user experience by allowing for more nuanced filtering of deals and clearer content categorization, while promoting the latest offerings.