back in fixed category

This commit is contained in:
hamid zarghami
2026-01-04 16:38:04 +03:30
parent 6ebefa6a52
commit 86aebd7a9f
4 changed files with 27 additions and 17 deletions
@@ -29,7 +29,7 @@ const variantConfig: Record<
type Props = {
categories: Category[];
selectedCategory: string;
onSelect: (index: number) => void;
onSelect: (categoryId: string) => void;
variant?: Variant;
className?: string;
};
@@ -43,7 +43,7 @@ const CategoryScroll = ({
}: Props) => {
const { renderer: Renderer, imageSize } = variantConfig[variant];
const handleSelect = (index: number) => () => onSelect(index);
const handleSelect = (categoryId: string) => () => onSelect(categoryId);
return (
<HorizontalScrollView
@@ -67,15 +67,14 @@ const CategoryScroll = ({
/>
<span className="text-xs text-foreground">همه</span>
</Renderer> */}
{categories.map((item, index) => {
const categoryIndex = index;
const isSelected = String(categoryIndex) === selectedCategory;
{categories.map((item) => {
const isSelected = item.id === selectedCategory;
return (
<Renderer
key={item.id}
className={clsx(isSelected && "bg-container!")}
onClick={handleSelect(categoryIndex)}
onClick={handleSelect(item.id)}
>
<Image
priority