Skip to content

Commit

Permalink
feature(DrawerFields): adding gemOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
xandjiji committed Apr 4, 2024
1 parent 1df3bb8 commit 0115efc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Expand Up @@ -58,6 +58,7 @@ const FilterDrawer = ({ open, onClose, ...props }: FilterDrawerProps) => {
storeOutfitValues,
mountValues,
storeMountValues,
gemOptions,
} = useDrawerFields()
const { filterState, activeFilterCount, mode, dispatch } = useAuctions()

Expand Down
@@ -1,4 +1,5 @@
import { createContext, useContext, useState } from 'react'
import { greaterGems } from 'data-dictionary/dist/dictionaries/gems'
import * as options from './options'
import { buildOption, sortOptions } from './utils'
import { DrawerFieldsContextData, DrawerFieldsProviderProps } from './types'
Expand All @@ -16,11 +17,26 @@ const DEFAULT_STATE: DrawerFieldsContextData = {
storeOutfitValues: [],
mountValues: [],
storeMountValues: [],
gemOptions: {
rook: [],
knight: [],
sorcerer: [],
druid: [],
paladin: [],
},
}

const DrawerFieldsContext =
createContext<DrawerFieldsContextData>(DEFAULT_STATE)

const gemOptions: DrawerFieldsContextData['gemOptions'] = {
rook: [],
knight: Object.keys(greaterGems.knight).map(buildOption),
sorcerer: Object.keys(greaterGems.sorcerer).map(buildOption),
druid: Object.keys(greaterGems.druid).map(buildOption),
paladin: Object.keys(greaterGems.paladin).map(buildOption),
}

export const DrawerFieldsProvider = ({
children,
...serverProps
Expand All @@ -31,7 +47,7 @@ export const DrawerFieldsProvider = ({

return (
<DrawerFieldsContext.Provider
value={{ ...serverProps, ...options, serverOptions }}
value={{ ...serverProps, ...options, serverOptions, gemOptions }}
>
{children}
</DrawerFieldsContext.Provider>
Expand Down
Expand Up @@ -11,6 +11,13 @@ export interface DrawerFieldsContextData {
storeOutfitValues: string[]
mountValues: string[]
storeMountValues: string[]
gemOptions: {
rook: Option[]
knight: Option[]
druid: Option[]
sorcerer: Option[]
paladin: Option[]
}
}

type ServerSideProps = Pick<
Expand Down

0 comments on commit 0115efc

Please sign in to comment.