+ const FilterContent = () => (
+ <>
فیلترها
@@ -169,6 +181,22 @@ const Filters: FC = () => {
+ >
+ )
+
+ if (isMobile) {
+ return (
+
{ })} title="فیلترها" isHeader={true}>
+
+
+
+
+ )
+ }
+
+ return (
+
+
)
}
diff --git a/src/app/products/components/Sorts.tsx b/src/app/products/components/Sorts.tsx
index 3195ba1..d9ff742 100644
--- a/src/app/products/components/Sorts.tsx
+++ b/src/app/products/components/Sorts.tsx
@@ -1,39 +1,91 @@
-import { Sort } from 'iconsax-react'
-import { FC } from 'react'
+import { Sort, ArrowDown2 } from 'iconsax-react'
+import { FC, useState, useEffect, useRef } from 'react'
+
+const sortOptions = [
+ { key: 'relevant', label: 'مرتبط ترین' },
+ { key: 'most_visited', label: 'پربازدیدترین' },
+ { key: 'newest', label: 'جدیدترین' },
+ { key: 'best_selling', label: 'پرفروش ترین' },
+ { key: 'cheapest', label: 'ارزانترین' },
+ { key: 'most_expensive', label: 'گرانترین' },
+ { key: 'customer_suggestion', label: 'پیشنهاد خریداران' },
+]
const Sorts: FC = () => {
+ const [selectedSort, setSelectedSort] = useState('newest')
+ const [showDropdown, setShowDropdown] = useState(false)
+ const dropdownRef = useRef
(null)
+
+ const selectedOption = sortOptions.find(option => option.key === selectedSort)
+
+ useEffect(() => {
+ const handleClickOutside = (event: MouseEvent) => {
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
+ setShowDropdown(false)
+ }
+ }
+
+ if (showDropdown) {
+ document.addEventListener('mousedown', handleClickOutside)
+ }
+
+ return () => {
+ document.removeEventListener('mousedown', handleClickOutside)
+ }
+ }, [showDropdown])
+
return (
-
+ {/* Desktop Version */}
+
-
- مرتبط ترین
-
-
- پربازدیدترین
-
-
- جدیدترین
-
-
- پرفروش ترین
-
-
- ارزانترین
-
-
- گرانترین
-
-
- پیشنهاد خریداران
-
+ {sortOptions.map((option) => (
+
setSelectedSort(option.key)}
+ >
+ {option.label}
+
+ ))}
-
+ {/* Mobile Version */}
+
+
+
مرتب سازی:
+
setShowDropdown(!showDropdown)}
+ >
+
{selectedOption?.label}
+
+
+
+ {showDropdown && (
+
+ {sortOptions.map((option) => (
+
{
+ setSelectedSort(option.key)
+ setShowDropdown(false)
+ }}
+ >
+ {option.label}
+
+ ))}
+
+ )}
+
+
+
100 کالا
diff --git a/src/components/Input.tsx b/src/components/Input.tsx
index c4f48b9..294321d 100644
--- a/src/components/Input.tsx
+++ b/src/components/Input.tsx
@@ -33,7 +33,7 @@ const Input: FC
= (props: Props) => {
const [search, setSearch] = useState('')
const inputClass = clx(
- 'w-full h-10 sm:h-12 text-black block px-3 sm:px-4 text-xs sm:text-sm rounded-xl border border-[#D0D0D0]',
+ 'w-full h-10 text-black block px-4 text-xs rounded-xl border border-[#D0D0D0]',
props.readOnly && 'bg-gray-100 border-0 text-description',
props.variant === 'search' && 'bg-[#EEF0F7] border-0 pr-10',
props.className
@@ -80,7 +80,7 @@ const Input: FC = (props: Props) => {
return (
-