Skip to content

Commit

Permalink
Merge branch 'master' into ffxiv-export-url-endings
Browse files Browse the repository at this point in the history
  • Loading branch information
cohenaj194 authored Sep 13, 2024
2 parents a7684b9 + 97eac1f commit eb98ae7
Show file tree
Hide file tree
Showing 11 changed files with 320 additions and 189 deletions.
7 changes: 5 additions & 2 deletions app/requests/WoW/BestDeals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface WoWBestDealsProps {
minPrice: number
itemClass: number
itemSubClass: number
expansionNumber: number
}

export interface DealItem {
Expand All @@ -35,7 +36,8 @@ const WoWBestDeals = async ({
salesPerDay,
minPrice,
itemClass,
itemSubClass
itemSubClass,
expansionNumber
}: WoWBestDealsProps) => {
const floatingSalesPerDay = salesPerDay.toFixed(1)
return fetch(`${address}/api/wow/bestdeals`, {
Expand All @@ -52,7 +54,8 @@ const WoWBestDeals = async ({
minPrice,
salesPerDay: +floatingSalesPerDay,
item_class: itemClass,
item_subclass: itemSubClass
item_subclass: itemSubClass,
expansion_number: expansionNumber
})
})
}
Expand Down
1 change: 1 addition & 0 deletions app/requests/client/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export const address = defaultAddress
// : defaultAddress

export const UserAgent = 'Saddlebag/1.0'
export const defaultMaxAge = 60 * 60 * 24 * 365 // 1 year in seconds
16 changes: 13 additions & 3 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
getWoWRealmDataFromLocalStorage,
setWoWRealmDataInLocalStorage
} from './redux/localStorage/wowRealmHelpers'
import { setCookie } from './utils/cookies'

export const ErrorBoundary = () => {
return (
Expand Down Expand Up @@ -153,10 +154,19 @@ export const action: ActionFunction = async ({ request }) => {
session.set(WOW_REALM_NAME, server.name)
session.set(WOW_REALM_ID, server.id)

const cookies = [
setCookie(DATA_CENTER, data_center),
setCookie(FF14_WORLD, world),
setCookie(WOW_REALM_ID, server.id.toString()),
setCookie(WOW_REALM_NAME, server.name),
setCookie(WOW_REGION, region)
]

return redirect('/', {
headers: {
'Set-Cookie': await commitSession(session)
}
headers: [
['Set-Cookie', await commitSession(session)],
...cookies.map((cookie) => ['Set-Cookie', cookie] as [string, string])
]
})
}

Expand Down
16 changes: 13 additions & 3 deletions app/routes/_public.options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import RegionAndServerSelect from '~/components/form/WoW/RegionAndServerSelect'
import SelectDCandWorld from '~/components/form/select/SelectWorld'
import type { WoWServerData, WoWServerRegion } from '~/requests/WoW/types'
import { PageWrapper } from '~/components/Common'
import { setCookie } from '~/utils/cookies'

// Overwrite default meta in the root.tsx
export const meta: MetaFunction = () => {
Expand Down Expand Up @@ -90,11 +91,20 @@ export const action: ActionFunction = async ({ request }) => {
session.set(WOW_REALM_NAME, server.name)
session.set(WOW_REGION, region)

const cookies = [
setCookie(DATA_CENTER, data_center),
setCookie(FF14_WORLD, world),
setCookie(WOW_REALM_ID, server.id.toString()),
setCookie(WOW_REALM_NAME, server.name),
setCookie(WOW_REGION, region)
]

// Set the new option, yeet back to index (but save against session data within the cookie)
return redirect('/', {
headers: {
'Set-Cookie': await commitSession(session)
}
headers: [
['Set-Cookie', await commitSession(session)],
...cookies.map((cookie) => ['Set-Cookie', cookie] as [string, string])
]
})
}

Expand Down
2 changes: 1 addition & 1 deletion app/routes/ffxiv.craftsim.queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const searchParams = {
foodItems:
'/ffxiv/craftsim?costMetric=material_median_cost&revenueMetric=revenue_home_min_listing&salesPerWeek=750&medianSalePrice=1000&maxMaterialCost=10000&jobs=0&filters=5%2C43%2C44%2C45%2C46&stars=-1&lvlLowerLimit=-1&yields=-1&hideExpertRecipes=true',
foodItemsTrainedEye:
'/ffxiv/craftsim?costMetric=material_median_cost&revenueMetric=revenue_home_min_listing&salesPerWeek=400&medianSalePrice=1000&maxMaterialCost=10000&jobs=0&filters=5%2C43%2C44%2C45%2C46&stars=-1&lvlLowerLimit=-1&lvlUpperLimit=80&yields=-1&hideExpertRecipes=true',
'/ffxiv/craftsim?costMetric=material_median_cost&revenueMetric=revenue_home_min_listing&salesPerWeek=400&medianSalePrice=1000&maxMaterialCost=10000&jobs=0&filters=5%2C43%2C44%2C45%2C46&stars=-1&lvlLowerLimit=-1&lvlUpperLimit=90&yields=-1&hideExpertRecipes=true',
furnitureAndGlamourItems:
'/ffxiv/craftsim?costMetric=material_median_cost&revenueMetric=revenue_home_min_listing&salesPerWeek=400&medianSalePrice=50000&maxMaterialCost=100000&jobs=0&filters=7%2C56%2C57%2C58%2C59%2C60%2C65%2C66%2C67%2C68%2C69%2C70%2C71%2C72%2C74%2C75%2C79%2C80%2C81%2C82%2C90&stars=-1&lvlLowerLimit=-1&yields=-1&hideExpertRecipes=true',
expertCraftItems:
Expand Down
25 changes: 19 additions & 6 deletions app/routes/wow.best-deals._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ 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 {
ItemClassSelect,
ExpansionSelect
} from '~/components/form/WoW/WoWScanForm'
import {
parseStringToNumber,
parseZodErrorsToDisplayString
Expand All @@ -34,7 +37,8 @@ const defaultFormValues = {
itemSubClass: '-1',
discount: '90',
minPrice: '2000',
salesPerDay: '1.1'
salesPerDay: '1.1',
expansionNumber: '-1'
}

const inputMap: Record<string, string> = {
Expand All @@ -43,7 +47,8 @@ const inputMap: Record<string, string> = {
itemSubClass: 'Item Subclass',
discount: 'Discount Percentage',
minPrice: 'Minimum TSM Average Price',
salesPerDay: 'Sales Per Day'
salesPerDay: 'Sales Per Day',
expansionNumber: 'WoW Expansion'
}

const validateInput = z.object({
Expand All @@ -55,7 +60,8 @@ const validateInput = z.object({
salesPerDay: z
.string()
.min(1)
.transform((value) => parseFloat(value))
.transform((value) => parseFloat(value)),
expansionNumber: parseStringToNumber
})

// Overwrite default meta in the root.tsx
Expand Down Expand Up @@ -85,7 +91,10 @@ export const loader: LoaderFunction = async ({ request }) => {
discount: params.get('discount') || defaultFormValues.discount.toString(),
minPrice: params.get('minPrice') || defaultFormValues.minPrice.toString(),
salesPerDay:
params.get('salesPerDay') || defaultFormValues.salesPerDay.toString()
params.get('salesPerDay') || defaultFormValues.salesPerDay.toString(),
expansionNumber:
params.get('expansionNumber') ||
defaultFormValues.expansionNumber.toString()
}
const validParams = validateInput.safeParse(values)
if (!validParams.success) {
Expand Down Expand Up @@ -191,13 +200,17 @@ const BestDeals = () => {
name="type"
defaultValue={loaderData.type}
options={[
{ label: 'Dragonflight Only', value: 'df' },
{ 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)}
/>
<ExpansionSelect
defaultValue={loaderData.expansionNumber}
onChange={(value) => handleFormChange('expansionNumber', value)}
/>
<ItemClassSelect
itemClass={parseInt(loaderData.itemClass)}
itemSubClass={parseInt(loaderData.itemSubClass)}
Expand Down
Loading

0 comments on commit eb98ae7

Please sign in to comment.