Files
danak-website/src/app/dmag/components/Category.tsx
T
hamid zarghami 633e5ea147 blogs to dmag
2025-06-07 09:36:06 +03:30

47 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { clx } from '@/helpers/utils'
import { FC } from 'react'
import { useGetBlogCategories } from '../hooks/useBlogsData'
import Image from 'next/image'
import { useBlogStore } from '../store/BlogStore'
const Category: FC = () => {
const { data } = useGetBlogCategories()
const { selectedCategory, setSelectedCategory } = useBlogStore()
return (
<div className='w-full rounded-4xl bg-white p-4'>
<h4>
دسته بندی مطالب
</h4>
<div className='flex flex-col gap-4 mt-7 text-sm'>
<div className={clx(
'h-10 bg-[#ECEFF6] rounded-xl p-2.5 flex items-center gap-2 ',
selectedCategory === "" ? 'bg-black text-white' : ''
)} onClick={() => setSelectedCategory("")}>
<div className='size-5 bg-white rounded-full'></div>
<h6>همه</h6>
</div>
{
data?.data?.categories?.map((item) => {
return (
<div key={item.id} className={clx(
'h-10 bg-[#ECEFF6] rounded-xl p-2.5 flex items-center gap-2 cursor-pointer',
selectedCategory === item.id ? 'bg-black text-white' : ''
)} onClick={() => setSelectedCategory(item.id)}>
<div className='size-5 rounded-full overflow-hidden'>
<Image src={item.iconUrl} alt={item.title} width={20} height={20} />
</div>
<h6>{item.title}</h6>
</div>
)
})
}
</div>
</div>
)
}
export default Category