Skip to content
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

Feature/menu #19

Merged
merged 6 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/assets/icons/menu/filter_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/pages/AboutUs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const AboutUs = () => {
>
<div
style={{ textShadow: '2px 2px 0 #000' }}
className={`text-accent font-bold text-center mt-auto leading-[30px] ${styleTextDesc}`}
className={`text-accent font-bold text-center mt-auto leading-[30px] ${styleTextDesc}`}
>
{member.name}
</div>
Expand Down
56 changes: 56 additions & 0 deletions src/pages/Menu/components/CategroryFilter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import * as React from 'react'
import { useState } from 'react'
import FormGroup from '@mui/material/FormGroup'
import FormControlLabel from '@mui/material/FormControlLabel'
import Checkbox from '@mui/material/Checkbox'

const Categrories = [
'Đồ uống',
'Thức ăn nhanh',
'Món Á',
'Cơm',
'Trà sữa',
'Món chay',
'Bún phở',
'Ăn vặt',
]

const CategroryFilter = () => {
const [selectedCategories, setSelectedCategories] = useState([])
const handleSelectCategories = (event) => {
const isChecked = event.target.checked
setSelectedCategories((prevSelected) => {
if (isChecked) {
return [...prevSelected, event.target.value]
} else {
return prevSelected.filter((category) => category !== event.target.value)
}
})
}
return (
<div>
<div className='text-[20px] text-primaryText font-bold'>Danh mục món ăn</div>
<FormGroup>
{Categrories.map((category, index) => (
<FormControlLabel
control={
<Checkbox
sx={{
'&.Mui-checked': {
color: '#7D0600',
},
}}
/>
}
onChange={handleSelectCategories}
value={category}
key={category}
label={category}
className='text-primaryText'
/>
))}
</FormGroup>
</div>
)
}
export default CategroryFilter
75 changes: 75 additions & 0 deletions src/pages/Menu/components/DistrictFilter.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import * as React from 'react'
import { useState } from 'react'
import FormGroup from '@mui/material/FormGroup'
import FormControlLabel from '@mui/material/FormControlLabel'
import Checkbox from '@mui/material/Checkbox'
import { Button } from '@mui/material'

const DistrictList = [
'Quận 1',
'Quận 3',
'Quận 4',
'Quận 5',
'Quận 6',
'Quận 7',
'Quận 8',
'Quận 10',
'Quận 11',
'Quận 12',
'Quận Tân Bình',
'Quận Tân Phú',
'Quận Bình Tân',
'Quận Bình Thạnh',
'Quận Gò Vấp',
'Quận Phú Nhuận',
'Thành phố Thủ Đức',
]

const DistrictFilter = () => {
const [selectedDistricts, setSelectedDistricts] = useState([])
const [showIndex, setShowIndex] = useState(5)

const handleSelectDistricts = (event) => {
const isChecked = event.target.checked
const district = event.target.value
setSelectedDistricts((prevSelected) =>
isChecked ? [...prevSelected, district] : prevSelected.filter((d) => d !== district),
)
}
console.log(selectedDistricts)
const handleCollapse = () => {
setShowIndex(showIndex === 5 ? DistrictList.length : 5)
}

return (
<div>
<div className='text-[20px] text-primaryText font-bold'>Lọc theo khu vực</div>
<FormGroup>
{DistrictList.slice(0, showIndex).map((district) => (
<FormControlLabel
control={
<Checkbox
sx={{
'&.Mui-checked': {
color: '#7D0600',
},
}}
onChange={handleSelectDistricts}
value={district}
checked={selectedDistricts.includes(district)}
/>
}
key={district}
label={district}
className='text-primaryText'
/>
))}
</FormGroup>
<Button onClick={handleCollapse}>
<div className='font-bold text-primary'>{showIndex === 5 ? 'Xem thêm...' : 'Thu gọn'}</div>
</Button>
</div>
)
}

export default DistrictFilter
22 changes: 22 additions & 0 deletions src/pages/Menu/components/RestaurantList.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react'
import RestaurantCard from '~/components/ui/RestaurantCard'

const RestaurantList = ({ Restaurants }) => {
return (
<div className=' grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 grid-rows-5 gap-10 '>
{Restaurants.map((restaurant) => (
<div key={restaurant.id}>
<RestaurantCard
image={restaurant.image}
rating={restaurant.rating}
restaurant={restaurant.restaurant}
address={restaurant.address}
id={restaurant.id}
/>
</div>
))}
</div>
)
}

export default RestaurantList
Loading