-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
filter menu by diet, make radio buttons extensible
- Loading branch information
Remy
committed
May 13, 2022
1 parent
93b3b74
commit f7c861e
Showing
21 changed files
with
15,872 additions
and
7,059 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const nextJest = require('next/jest'); | ||
|
||
const createJestConfig = nextJest({ | ||
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment | ||
dir: './', | ||
}); | ||
|
||
// Add any custom config to be passed to Jest | ||
const customJestConfig = { | ||
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'], | ||
moduleNameMapper: { | ||
// Handle module aliases (this will be automatically configured for you soon) | ||
'^@/components/(.*)$': '<rootDir>/components/$1', | ||
|
||
'^@/pages/(.*)$': '<rootDir>/pages/$1', | ||
}, | ||
testEnvironment: 'jest-environment-jsdom', | ||
}; | ||
|
||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async | ||
module.exports = createJestConfig(customJestConfig); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Optional: configure or set up a testing framework before each test. | ||
// If you delete this file, remove `setupFilesAfterEnv` from `jest.config.js` | ||
|
||
// Used for __tests__/testing-library.js | ||
// Learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom/extend-expect'; |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import type React from 'react'; | ||
import { IMenuDefaultProps } from '../Interfaces'; | ||
import { IMenuOptionProps } from '../Interfaces'; | ||
import CheckboxList from '../TextList'; | ||
import { afroMenuItems } from './MenuHelpers'; | ||
|
||
export const AfroMenuOptions = ({control, defaultValues}: IMenuDefaultProps) => | ||
<CheckboxList listItems={afroMenuItems} control={control} defaultValues={defaultValues} />; | ||
export const AfroMenuOptions = ({control, diet, defaultValues}: IMenuOptionProps) => | ||
<CheckboxList listItems={afroMenuItems} control={control} defaultValues={defaultValues} diet={diet} />; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type React from 'react'; | ||
import { FormControl, FormControlLabel, RadioGroup, Radio, Box, Typography } from '@mui/material'; | ||
import { Control, Controller } from 'react-hook-form'; | ||
import { CuisineType, GuestDocument } from '../Interfaces'; | ||
|
||
interface ICuisineTypeOptions { | ||
defaultValues: CuisineType | undefined; | ||
control: Control<GuestDocument, object>; | ||
// handleCuisineChange: (cuisine: CuisineType) => void; | ||
} | ||
|
||
export const CuisineTypeOptions = ({defaultValues = 'euro', control /*, handleCuisineChange*/}: ICuisineTypeOptions) => | ||
<Box> | ||
<Typography variant="h3" sx={{ fontSize: '2.5rem'}}>What cuisine type would you like?</Typography> | ||
<FormControl> | ||
<Controller | ||
control={control} | ||
defaultValue={defaultValues} | ||
name="cuisine" | ||
render={({field}) => | ||
<RadioGroup {...field}> | ||
<FormControlLabel | ||
value={'euro'} | ||
control={<Radio />} | ||
label="European" | ||
// onClick={() => handleCuisineChange('euro')} | ||
/> | ||
<FormControlLabel | ||
value={'afro'} | ||
control={<Radio />} | ||
label="West African 🇳🇬" | ||
// onClick={() => handleCuisineChange('afro')} | ||
/> | ||
</RadioGroup>} | ||
/> | ||
</FormControl> | ||
</Box>; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import type React from 'react'; | ||
import { FormControlLabel, Radio, RadioGroup, Typography } from '@mui/material'; | ||
import { Controller } from 'react-hook-form'; | ||
import { IMenuDefaultProps } from '../Interfaces'; | ||
import { dessertItems } from './MenuHelpers'; | ||
import { IMenuOptionProps } from '../Interfaces'; | ||
import { dessertItems, shouldShowBasedOnDietChoice } from './MenuHelpers'; | ||
|
||
export const DessertOptions = ({control, defaultValues }: IMenuDefaultProps) => | ||
export const DessertOptions = ({control, defaultValues, diet }: IMenuOptionProps) => | ||
<> | ||
<Typography variant="h4" sx={{ my: '1rem', fontSize: '2rem'}}>Dessert</Typography> | ||
<Controller | ||
name='menu.euroDessert' | ||
control={control} | ||
defaultValue={defaultValues?.euroDessert ?? ''} | ||
defaultValue={defaultValues?.euroDessert} | ||
render={({field}) => | ||
<RadioGroup {...field}> | ||
{dessertItems.map(x => <FormControlLabel key={x.key} value={x.key} control={<Radio />} label={x.primary} />)} | ||
{dessertItems.map(x => shouldShowBasedOnDietChoice(diet, x.diet) && <FormControlLabel key={x.key} value={x.key} control={<Radio />} label={x.primary} />)} | ||
</ RadioGroup>} | ||
/> | ||
</>; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,31 @@ | ||
import type React from 'react'; | ||
import { FormControl, FormControlLabel, Radio, RadioGroup, Typography } from '@mui/material'; | ||
import { Controller } from 'react-hook-form'; | ||
import type { IMenuDefaultProps } from '../Interfaces'; | ||
import { euroMainItems, euroStarterItems } from './MenuHelpers'; | ||
import type { IMenuOptionProps } from '../Interfaces'; | ||
import { euroMainItems, euroStarterItems, shouldShowBasedOnDietChoice } from './MenuHelpers'; | ||
import { useMemo } from 'react'; | ||
|
||
export const EuroMenuOptions = ({ control, defaultValues }: IMenuDefaultProps) => | ||
export const EuroMenuOptions = ({ control, defaultValues, diet }: IMenuOptionProps) => | ||
{ | ||
return (<FormControl> | ||
<Typography variant="h4" sx={{ my: '1rem', fontSize: '2rem'}}>Starters</Typography> | ||
<Controller | ||
name='menu.euroStarter' | ||
control={control} | ||
defaultValue={defaultValues?.euroStarter ?? ''} | ||
render={({field}) => | ||
<RadioGroup {...field} value={field.value || undefined}> | ||
{euroStarterItems.map(x => <FormControlLabel key={x.key} value={x.key} control={<Radio />} label={x.primary} />)} | ||
</RadioGroup> | ||
} | ||
/> | ||
<Typography variant="h4" sx={{ my: '1rem', fontSize: '2rem'}}>Mains - all are served with Seasonal Vegetables and Potatoes</Typography> | ||
<Controller | ||
name='menu.euroMain' | ||
control={control} | ||
defaultValue={defaultValues?.euroMain} | ||
render={({field}) => | ||
<RadioGroup {...field} value={field.value || undefined}> | ||
{euroMainItems.map(x => <FormControlLabel key={x.key} value={x.key} control={<Radio />} label={x.primary} />)} | ||
</RadioGroup> | ||
} | ||
/> | ||
</FormControl>); | ||
return ( | ||
<FormControl> | ||
<Typography variant="h4" sx={{ my: '1rem', fontSize: '2rem'}}>Starters</Typography> | ||
<Controller | ||
name='menu.euroStarter' | ||
control={control} | ||
defaultValue={defaultValues?.euroStarter} | ||
render={({field}) =><RadioGroup {...field} value={field.value}> | ||
{euroStarterItems.map(x => shouldShowBasedOnDietChoice(diet, x.diet) && <FormControlLabel key={x.key} value={x.key} control={<Radio />} label={x.primary} />)} | ||
</RadioGroup>} | ||
/> | ||
<Typography variant="h4" sx={{ my: '1rem', fontSize: '2rem'}}>Mains - all are served with Seasonal Vegetables and Potatoes</Typography> | ||
<Controller | ||
name='menu.euroMain' | ||
control={control} | ||
defaultValue={defaultValues?.euroMain} | ||
render={({field}) => <RadioGroup {...field} value={field.value}> | ||
{euroMainItems.map(x => shouldShowBasedOnDietChoice(diet, x.diet) && <FormControlLabel key={x.key} value={x.key} control={<Radio />} label={x.primary} />)} | ||
</RadioGroup>} | ||
/> | ||
</FormControl>); | ||
}; |
Oops, something went wrong.
f7c861e
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.
Successfully deployed to the following URLs:
nupito – ./
nupito-git-main-remy90.vercel.app
nupito-remy90.vercel.app
shaunandcharlotte.co.uk