Skip to content

Commit

Permalink
feat(#491): show grapes required for wine
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Apr 30, 2024
1 parent 83e2d09 commit 6d35209
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/WineRecipeList/WineRecipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import CardHeader from '@mui/material/CardHeader'
import CardActions from '@mui/material/CardActions'
import Button from '@mui/material/Button'

import { grapeVarietyNameMap } from '../../data/crops/grape'
import {
grapeVarietyNameMap,
grapeVarietyVarietyGrapeMap,
} from '../../data/crops/grape'
import { wineService } from '../../services/wine'
import { grapeVariety } from '../../enums'
import { wines } from '../../img'
Expand All @@ -18,6 +21,7 @@ import { integerString } from '../../utils'
*/
export const WineRecipe = ({ wineVariety }) => {
const wineName = grapeVarietyNameMap[wineVariety]
const grape = grapeVarietyVarietyGrapeMap[wineVariety]

return (
<Card className="WineRecipe">
Expand All @@ -37,8 +41,12 @@ export const WineRecipe = ({ wineVariety }) => {
Days to mature:{' '}
{integerString(wineService.getDaysToMature(wineVariety))}
</p>
<p>
Ingredients:{' '}
{integerString(wineService.getGrapesRequiredForWine(wineVariety))}{' '}
x {grape.name}
</p>
{
// FIXME: Show type and number of grapes required (4x their wineVarietyValueMap value)
// FIXME: Show number of required grapes in inventory
// FIXME: Show amount in cellar
}
Expand Down
16 changes: 16 additions & 0 deletions src/data/crops/grape.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,19 @@ export const grapeNebbiolo = grape({
imageId: 'grape-purple',
variety: grapeVariety.NEBBIOLO,
})

/**
* @type {Record<grapeVariety, farmhand.grape>}
*/
export const grapeVarietyVarietyGrapeMap = {
[grapeVariety.CHARDONNAY]: grapeChardonnay,
[grapeVariety.SAUVIGNON_BLANC]: grapeSauvignonBlanc,
//[grapeVariety.PINOT_BLANC]: grapePinotBlanc,
//[grapeVariety.MUSCAT]: grapeMuscat,
//[grapeVariety.RIESLING]: grapeRiesling,
//[grapeVariety.MERLOT]: grapeMerlot,
[grapeVariety.CABERNET_SAUVIGNON]: grapeCabernetSauvignon,
//[grapeVariety.SYRAH]: grapeSyrah,
[grapeVariety.TEMPRANILLO]: grapeTempranillo,
[grapeVariety.NEBBIOLO]: grapeNebbiolo,
}
12 changes: 12 additions & 0 deletions src/services/wine.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,24 @@ export class WineService {
*/
maturityDayMultiplier = 3

/**
* @private
*/
grapeRequirementMultiplier = 4

/**
* @param {grapeVarietyEnum} grapeVariety
*/
getDaysToMature = grapeVariety => {
return wineVarietyValueMap[grapeVariety] * this.maturityDayMultiplier
}

/**
* @param {grapeVarietyEnum} grapeVariety
*/
getGrapesRequiredForWine = grapeVariety => {
return wineVarietyValueMap[grapeVariety] * this.grapeRequirementMultiplier
}
}

export const wineService = new WineService()

0 comments on commit 6d35209

Please sign in to comment.