Spaces:
Paused
Paused
shanshel6 commited on
Commit ·
f35dfab
1
Parent(s): da31912
feat:consolidate-updates-optimize-gitignore
Browse files- .gitattributes +1 -0
- .gitignore +4 -0
- android/app/build.gradle +2 -2
- package.json +1 -1
- src/components/BottomNav.tsx +27 -122
- src/components/home/SearchBar.tsx +23 -39
- src/components/search/SearchHeader.tsx +10 -12
- src/pages/Cart.tsx +64 -42
- src/pages/Home.tsx +3 -17
- src/pages/SearchResults.tsx +17 -21
.gitattributes
CHANGED
|
@@ -1,2 +1,3 @@
|
|
| 1 |
*.png filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.traineddata filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 1 |
*.png filter=lfs diff=lfs merge=lfs -text
|
| 2 |
*.traineddata filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.aab filter=lfs diff=lfs merge=lfs -text
|
.gitignore
CHANGED
|
@@ -28,6 +28,10 @@ server/*.log
|
|
| 28 |
# Database
|
| 29 |
*.db
|
| 30 |
*.sqlite
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
server/*.db
|
| 32 |
server/prisma/*.db
|
| 33 |
server/prisma/dev.db
|
|
|
|
| 28 |
# Database
|
| 29 |
*.db
|
| 30 |
*.sqlite
|
| 31 |
+
*.mdb
|
| 32 |
+
data.ms/
|
| 33 |
+
meilisearch.exe
|
| 34 |
+
chrome_data_pdd_persistent/
|
| 35 |
server/*.db
|
| 36 |
server/prisma/*.db
|
| 37 |
server/prisma/dev.db
|
android/app/build.gradle
CHANGED
|
@@ -7,8 +7,8 @@ android {
|
|
| 7 |
applicationId "com.chinak.app"
|
| 8 |
minSdkVersion rootProject.ext.minSdkVersion
|
| 9 |
targetSdkVersion rootProject.ext.targetSdkVersion
|
| 10 |
-
versionCode
|
| 11 |
-
versionName "1.0.
|
| 12 |
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
| 13 |
}
|
| 14 |
|
|
|
|
| 7 |
applicationId "com.chinak.app"
|
| 8 |
minSdkVersion rootProject.ext.minSdkVersion
|
| 9 |
targetSdkVersion rootProject.ext.targetSdkVersion
|
| 10 |
+
versionCode 47
|
| 11 |
+
versionName "1.0.37"
|
| 12 |
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
| 13 |
}
|
| 14 |
|
package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"name": "project",
|
| 3 |
"private": true,
|
| 4 |
-
"version": "1.0.
|
| 5 |
"type": "module",
|
| 6 |
"scripts": {
|
| 7 |
"dev": "concurrently \"npm run dev:frontend\" \"npm run dev:backend\"",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "project",
|
| 3 |
"private": true,
|
| 4 |
+
"version": "1.0.37",
|
| 5 |
"type": "module",
|
| 6 |
"scripts": {
|
| 7 |
"dev": "concurrently \"npm run dev:frontend\" \"npm run dev:backend\"",
|
src/components/BottomNav.tsx
CHANGED
|
@@ -15,7 +15,8 @@ const BottomNav: React.FC<BottomNavProps> = ({ className = '' }) => {
|
|
| 15 |
|
| 16 |
const navItems = [
|
| 17 |
{ id: 'home', label: 'الرئيسية', icon: Home, path: '/' },
|
| 18 |
-
{ id: 'orders', label: 'طلباتي', icon: ShoppingBag, path: '/orders' },
|
|
|
|
| 19 |
{ id: 'favorites', label: 'المفضلة', icon: Heart, path: '/favorites' },
|
| 20 |
{ id: 'profile', label: 'حسابي', icon: User, path: '/profile' },
|
| 21 |
];
|
|
@@ -25,146 +26,50 @@ const BottomNav: React.FC<BottomNavProps> = ({ className = '' }) => {
|
|
| 25 |
return location.pathname.startsWith(path);
|
| 26 |
};
|
| 27 |
|
| 28 |
-
const leftItems = navItems.slice(0, 2);
|
| 29 |
-
const rightItems = navItems.slice(2);
|
| 30 |
-
|
| 31 |
return (
|
| 32 |
<nav
|
| 33 |
-
className={`fixed bottom-
|
| 34 |
>
|
| 35 |
-
<div className="mx-auto w-full max-w-md
|
| 36 |
-
|
| 37 |
-
{leftItems.map((item) => {
|
| 38 |
-
const active = isActive(item.path);
|
| 39 |
-
const isDisabled = 'disabled' in item ? (item as any).disabled : false;
|
| 40 |
-
const Icon = item.icon;
|
| 41 |
-
|
| 42 |
-
return (
|
| 43 |
-
<button
|
| 44 |
-
key={item.id}
|
| 45 |
-
onClick={() => !isDisabled && navigate(item.path)}
|
| 46 |
-
disabled={isDisabled}
|
| 47 |
-
className={`group relative flex w-full flex-col items-center justify-end gap-0.5 pb-0.5 transition-all duration-300 ${
|
| 48 |
-
isDisabled ? 'opacity-30 cursor-not-allowed grayscale' : ''
|
| 49 |
-
}`}
|
| 50 |
-
>
|
| 51 |
-
<div className="relative p-1">
|
| 52 |
-
<motion.div
|
| 53 |
-
animate={{
|
| 54 |
-
y: active ? -2 : 0,
|
| 55 |
-
scale: active ? 1.1 : 1,
|
| 56 |
-
}}
|
| 57 |
-
transition={{ type: "spring", stiffness: 300, damping: 20 }}
|
| 58 |
-
className={`relative z-10 ${active ? 'text-primary' : 'text-slate-400 group-hover:text-slate-600 dark:text-slate-500 dark:group-hover:text-slate-300'}`}
|
| 59 |
-
>
|
| 60 |
-
<Icon
|
| 61 |
-
size={24}
|
| 62 |
-
strokeWidth={active ? 2.5 : 2}
|
| 63 |
-
fill={active ? "currentColor" : "none"}
|
| 64 |
-
className="transition-colors duration-300"
|
| 65 |
-
/>
|
| 66 |
-
</motion.div>
|
| 67 |
-
|
| 68 |
-
{active && (
|
| 69 |
-
<motion.div
|
| 70 |
-
layoutId="activeTabIndicator"
|
| 71 |
-
className="absolute inset-0 -z-0 rounded-full bg-primary/10 dark:bg-primary/20"
|
| 72 |
-
initial={{ opacity: 0, scale: 0.8 }}
|
| 73 |
-
animate={{ opacity: 1, scale: 1 }}
|
| 74 |
-
exit={{ opacity: 0, scale: 0.8 }}
|
| 75 |
-
transition={{ type: "spring", stiffness: 300, damping: 25 }}
|
| 76 |
-
/>
|
| 77 |
-
)}
|
| 78 |
-
</div>
|
| 79 |
-
|
| 80 |
-
<span className={`text-[9px] font-medium transition-all duration-300 ${
|
| 81 |
-
active ? 'text-primary font-bold translate-y-0 opacity-100' : 'text-slate-400 translate-y-1 opacity-0 h-0 overflow-hidden'
|
| 82 |
-
}`}>
|
| 83 |
-
{item.label}
|
| 84 |
-
</span>
|
| 85 |
-
</button>
|
| 86 |
-
);
|
| 87 |
-
})}
|
| 88 |
-
<div className="relative flex items-end justify-center h-full">
|
| 89 |
-
<div className="absolute -top-2 left-1/2 -translate-x-1/2 z-50">
|
| 90 |
-
<motion.button
|
| 91 |
-
onClick={() => navigate('/cart')}
|
| 92 |
-
whileHover={{ scale: 1.05 }}
|
| 93 |
-
whileTap={{ scale: 0.9 }}
|
| 94 |
-
className={`flex size-16 items-center justify-center rounded-full shadow-xl ring-[6px] ring-white/90 dark:ring-slate-900/90 backdrop-blur-md border border-slate-200/70 dark:border-slate-700/60 ${
|
| 95 |
-
location.pathname === '/cart'
|
| 96 |
-
? 'bg-primary text-white shadow-primary/40 dark:bg-primary dark:text-white'
|
| 97 |
-
: 'bg-white text-slate-700 shadow-slate-200/60 dark:bg-slate-800 dark:text-white'
|
| 98 |
-
}`}
|
| 99 |
-
>
|
| 100 |
-
<ShoppingCart size={28} strokeWidth={2.5} />
|
| 101 |
-
</motion.button>
|
| 102 |
-
<AnimatePresence>
|
| 103 |
-
{cartItemsCount > 0 && (
|
| 104 |
-
<motion.span
|
| 105 |
-
initial={{ scale: 0 }}
|
| 106 |
-
animate={{ scale: 1 }}
|
| 107 |
-
exit={{ scale: 0 }}
|
| 108 |
-
className="absolute -top-0 -right-0 flex h-5 w-5 items-center justify-center rounded-full bg-red-500 text-[10px] font-bold text-white ring-2 ring-white dark:ring-slate-900 shadow-sm"
|
| 109 |
-
>
|
| 110 |
-
{cartItemsCount > 99 ? '99+' : cartItemsCount}
|
| 111 |
-
</motion.span>
|
| 112 |
-
)}
|
| 113 |
-
</AnimatePresence>
|
| 114 |
-
</div>
|
| 115 |
-
</div>
|
| 116 |
-
{rightItems.map((item) => {
|
| 117 |
const active = isActive(item.path);
|
| 118 |
-
const isDisabled = 'disabled' in item ? (item as any).disabled : false;
|
| 119 |
const Icon = item.icon;
|
| 120 |
|
| 121 |
return (
|
| 122 |
<button
|
| 123 |
key={item.id}
|
| 124 |
-
onClick={() =>
|
| 125 |
-
|
| 126 |
-
className={`group relative flex w-full flex-col items-center justify-end gap-0.5 pb-0.5 transition-all duration-300 ${
|
| 127 |
-
isDisabled ? 'opacity-30 cursor-not-allowed grayscale' : ''
|
| 128 |
-
}`}
|
| 129 |
>
|
| 130 |
-
<div className="relative
|
| 131 |
-
<
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
transition={{ type: "spring", stiffness: 300, damping: 20 }}
|
| 137 |
-
className={`relative z-10 ${active ? 'text-primary' : 'text-slate-400 group-hover:text-slate-600 dark:text-slate-500 dark:group-hover:text-slate-300'}`}
|
| 138 |
-
>
|
| 139 |
-
<Icon
|
| 140 |
-
size={24}
|
| 141 |
-
strokeWidth={active ? 2.5 : 2}
|
| 142 |
-
fill={active ? "currentColor" : "none"}
|
| 143 |
-
className="transition-colors duration-300"
|
| 144 |
-
/>
|
| 145 |
-
</motion.div>
|
| 146 |
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
|
|
|
|
|
|
| 157 |
</div>
|
| 158 |
|
| 159 |
-
<span className={`text-[
|
| 160 |
-
active ? 'text-primary
|
| 161 |
}`}>
|
| 162 |
{item.label}
|
| 163 |
</span>
|
| 164 |
</button>
|
| 165 |
);
|
| 166 |
})}
|
| 167 |
-
</div>
|
| 168 |
</div>
|
| 169 |
</nav>
|
| 170 |
);
|
|
|
|
| 15 |
|
| 16 |
const navItems = [
|
| 17 |
{ id: 'home', label: 'الرئيسية', icon: Home, path: '/' },
|
| 18 |
+
{ id: 'orders', label: 'طلباتي', icon: ShoppingBag, path: '/orders' }, // Using ShoppingBag for Orders
|
| 19 |
+
{ id: 'cart', label: 'السلة', icon: ShoppingCart, path: '/cart', badge: cartItemsCount },
|
| 20 |
{ id: 'favorites', label: 'المفضلة', icon: Heart, path: '/favorites' },
|
| 21 |
{ id: 'profile', label: 'حسابي', icon: User, path: '/profile' },
|
| 22 |
];
|
|
|
|
| 26 |
return location.pathname.startsWith(path);
|
| 27 |
};
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
return (
|
| 30 |
<nav
|
| 31 |
+
className={`fixed bottom-0 left-0 right-0 z-50 bg-white border-t border-slate-100 shadow-[0_-2px_10px_rgba(0,0,0,0.03)] pb-[calc(env(safe-area-inset-bottom))] transition-transform duration-300 dark:bg-slate-900 dark:border-slate-800 ${className}`}
|
| 32 |
>
|
| 33 |
+
<div className="mx-auto w-full max-w-md h-[60px] flex items-center justify-between px-2">
|
| 34 |
+
{navItems.map((item) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
const active = isActive(item.path);
|
|
|
|
| 36 |
const Icon = item.icon;
|
| 37 |
|
| 38 |
return (
|
| 39 |
<button
|
| 40 |
key={item.id}
|
| 41 |
+
onClick={() => navigate(item.path)}
|
| 42 |
+
className="relative flex flex-1 flex-col items-center justify-center gap-1 h-full w-full active:scale-95 transition-transform duration-200"
|
|
|
|
|
|
|
|
|
|
| 43 |
>
|
| 44 |
+
<div className="relative">
|
| 45 |
+
<Icon
|
| 46 |
+
size={24}
|
| 47 |
+
strokeWidth={active ? 2.5 : 2}
|
| 48 |
+
className={`transition-colors duration-200 ${active ? 'text-primary fill-primary/10' : 'text-slate-500 dark:text-slate-400'}`}
|
| 49 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
<AnimatePresence>
|
| 52 |
+
{item.badge && item.badge > 0 && (
|
| 53 |
+
<motion.span
|
| 54 |
+
initial={{ scale: 0 }}
|
| 55 |
+
animate={{ scale: 1 }}
|
| 56 |
+
exit={{ scale: 0 }}
|
| 57 |
+
className="absolute -top-1.5 -right-2 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary px-1 text-[10px] font-bold text-white ring-1 ring-white dark:ring-slate-900"
|
| 58 |
+
>
|
| 59 |
+
{item.badge > 99 ? '99+' : item.badge}
|
| 60 |
+
</motion.span>
|
| 61 |
+
)}
|
| 62 |
+
</AnimatePresence>
|
| 63 |
</div>
|
| 64 |
|
| 65 |
+
<span className={`text-[11px] font-medium transition-colors duration-200 ${
|
| 66 |
+
active ? 'text-primary' : 'text-slate-500 dark:text-slate-400'
|
| 67 |
}`}>
|
| 68 |
{item.label}
|
| 69 |
</span>
|
| 70 |
</button>
|
| 71 |
);
|
| 72 |
})}
|
|
|
|
| 73 |
</div>
|
| 74 |
</nav>
|
| 75 |
);
|
src/components/home/SearchBar.tsx
CHANGED
|
@@ -1,16 +1,14 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { motion, AnimatePresence } from 'framer-motion';
|
| 3 |
import { useTranslation } from 'react-i18next';
|
| 4 |
-
import { Search,
|
| 5 |
|
| 6 |
interface SearchBarProps {
|
| 7 |
onNavigate: (path: string) => void;
|
| 8 |
-
unreadNotificationsCount?: number;
|
| 9 |
}
|
| 10 |
|
| 11 |
const SearchBar: React.FC<SearchBarProps> = ({
|
| 12 |
-
onNavigate
|
| 13 |
-
unreadNotificationsCount = 0
|
| 14 |
}) => {
|
| 15 |
const { t } = useTranslation();
|
| 16 |
const [placeholderIndex, setPlaceholderIndex] = useState(0);
|
|
@@ -31,43 +29,29 @@ const SearchBar: React.FC<SearchBarProps> = ({
|
|
| 31 |
}, [placeholders.length]);
|
| 32 |
|
| 33 |
return (
|
| 34 |
-
<div className="px-
|
| 35 |
-
<div
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
>
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
<
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
>
|
| 55 |
-
{placeholders[placeholderIndex]}
|
| 56 |
-
</motion.span>
|
| 57 |
-
</AnimatePresence>
|
| 58 |
-
</div>
|
| 59 |
-
</div>
|
| 60 |
</div>
|
| 61 |
|
| 62 |
-
<
|
| 63 |
-
onClick={() => onNavigate('/notifications')}
|
| 64 |
-
className="relative flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full bg-white/80 dark:bg-slate-800/80 shadow-sm ring-1 ring-slate-200/70 dark:ring-slate-700/60 text-slate-600 dark:text-slate-300 transition-all hover:text-primary active:scale-95 backdrop-blur-xl"
|
| 65 |
-
>
|
| 66 |
-
<Bell size={20} strokeWidth={2} />
|
| 67 |
-
{unreadNotificationsCount > 0 && (
|
| 68 |
-
<span className="absolute top-2.5 right-2.5 h-3 w-3 rounded-full bg-red-500 ring-2 ring-white dark:ring-slate-800 animate-pulse"></span>
|
| 69 |
-
)}
|
| 70 |
-
</button>
|
| 71 |
</div>
|
| 72 |
</div>
|
| 73 |
);
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
import { motion, AnimatePresence } from 'framer-motion';
|
| 3 |
import { useTranslation } from 'react-i18next';
|
| 4 |
+
import { Search, Camera } from 'lucide-react';
|
| 5 |
|
| 6 |
interface SearchBarProps {
|
| 7 |
onNavigate: (path: string) => void;
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
const SearchBar: React.FC<SearchBarProps> = ({
|
| 11 |
+
onNavigate
|
|
|
|
| 12 |
}) => {
|
| 13 |
const { t } = useTranslation();
|
| 14 |
const [placeholderIndex, setPlaceholderIndex] = useState(0);
|
|
|
|
| 29 |
}, [placeholders.length]);
|
| 30 |
|
| 31 |
return (
|
| 32 |
+
<div className="sticky top-0 z-40 bg-white px-3 py-2 shadow-sm transition-all duration-300 dark:bg-slate-900">
|
| 33 |
+
<div
|
| 34 |
+
onClick={() => onNavigate('/search')}
|
| 35 |
+
className="relative flex h-10 w-full cursor-pointer items-center gap-2 rounded-full bg-slate-100 px-4 transition-all active:scale-[0.99] dark:bg-slate-800"
|
| 36 |
+
>
|
| 37 |
+
<Search size={18} className="text-slate-400" strokeWidth={2.5} />
|
| 38 |
+
|
| 39 |
+
<div className="relative flex flex-1 items-center overflow-hidden h-full">
|
| 40 |
+
<AnimatePresence mode="wait">
|
| 41 |
+
<motion.span
|
| 42 |
+
key={placeholderIndex}
|
| 43 |
+
initial={{ y: 20, opacity: 0 }}
|
| 44 |
+
animate={{ y: 0, opacity: 1 }}
|
| 45 |
+
exit={{ y: -20, opacity: 0 }}
|
| 46 |
+
transition={{ duration: 0.3 }}
|
| 47 |
+
className="absolute w-full truncate text-[13px] font-medium text-slate-400 text-right"
|
| 48 |
+
>
|
| 49 |
+
{placeholders[placeholderIndex]}
|
| 50 |
+
</motion.span>
|
| 51 |
+
</AnimatePresence>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
</div>
|
| 53 |
|
| 54 |
+
<Camera size={20} className="text-slate-400" strokeWidth={2} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
</div>
|
| 56 |
</div>
|
| 57 |
);
|
src/components/search/SearchHeader.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import React, { useEffect, useRef } from 'react';
|
| 2 |
-
import {
|
| 3 |
|
| 4 |
interface SearchHeaderProps {
|
| 5 |
query: string;
|
|
@@ -29,13 +29,13 @@ const SearchHeader: React.FC<SearchHeaderProps> = ({
|
|
| 29 |
}, []);
|
| 30 |
|
| 31 |
return (
|
| 32 |
-
<div className="
|
| 33 |
-
<div className="flex items-center
|
| 34 |
<button
|
| 35 |
onClick={onBack}
|
| 36 |
-
className="
|
| 37 |
>
|
| 38 |
-
<
|
| 39 |
</button>
|
| 40 |
|
| 41 |
<form
|
|
@@ -46,14 +46,12 @@ const SearchHeader: React.FC<SearchHeaderProps> = ({
|
|
| 46 |
}}
|
| 47 |
className="flex-1 relative group"
|
| 48 |
>
|
| 49 |
-
<div className="relative flex items-center
|
| 50 |
-
<
|
| 51 |
-
<Search size={16} strokeWidth={2.5} />
|
| 52 |
-
</div>
|
| 53 |
|
| 54 |
<input
|
| 55 |
ref={inputRef}
|
| 56 |
-
className="flex-1 bg-transparent border-none
|
| 57 |
type="text"
|
| 58 |
value={query}
|
| 59 |
onChange={(e) => onQueryChange(e.target.value)}
|
|
@@ -66,7 +64,7 @@ const SearchHeader: React.FC<SearchHeaderProps> = ({
|
|
| 66 |
<button
|
| 67 |
type="button"
|
| 68 |
onClick={onClear}
|
| 69 |
-
className="
|
| 70 |
>
|
| 71 |
<X size={16} />
|
| 72 |
</button>
|
|
@@ -78,7 +76,7 @@ const SearchHeader: React.FC<SearchHeaderProps> = ({
|
|
| 78 |
onClick={() => {
|
| 79 |
if (onSubmit) onSubmit();
|
| 80 |
}}
|
| 81 |
-
className="px-4
|
| 82 |
>
|
| 83 |
بحث
|
| 84 |
</button>
|
|
|
|
| 1 |
import React, { useEffect, useRef } from 'react';
|
| 2 |
+
import { ArrowRight, Search, X } from 'lucide-react';
|
| 3 |
|
| 4 |
interface SearchHeaderProps {
|
| 5 |
query: string;
|
|
|
|
| 29 |
}, []);
|
| 30 |
|
| 31 |
return (
|
| 32 |
+
<div className="sticky top-0 z-40 bg-white shadow-sm transition-all duration-300 dark:bg-slate-900 px-3 py-2">
|
| 33 |
+
<div className="flex items-center gap-2">
|
| 34 |
<button
|
| 35 |
onClick={onBack}
|
| 36 |
+
className="flex h-10 w-10 items-center justify-center text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white transition-colors"
|
| 37 |
>
|
| 38 |
+
<ArrowRight size={24} />
|
| 39 |
</button>
|
| 40 |
|
| 41 |
<form
|
|
|
|
| 46 |
}}
|
| 47 |
className="flex-1 relative group"
|
| 48 |
>
|
| 49 |
+
<div className="relative flex h-10 w-full items-center gap-2 rounded-full bg-slate-100 px-4 transition-all focus-within:ring-2 focus-within:ring-primary/20 dark:bg-slate-800">
|
| 50 |
+
<Search size={18} className="text-slate-400" strokeWidth={2.5} />
|
|
|
|
|
|
|
| 51 |
|
| 52 |
<input
|
| 53 |
ref={inputRef}
|
| 54 |
+
className="flex-1 bg-transparent border-none p-0 text-[13px] font-medium text-slate-900 dark:text-white placeholder:text-slate-400 focus:ring-0 outline-none transition-all"
|
| 55 |
type="text"
|
| 56 |
value={query}
|
| 57 |
onChange={(e) => onQueryChange(e.target.value)}
|
|
|
|
| 64 |
<button
|
| 65 |
type="button"
|
| 66 |
onClick={onClear}
|
| 67 |
+
className="text-slate-400 hover:text-slate-600 dark:hover:text-slate-200 transition-colors"
|
| 68 |
>
|
| 69 |
<X size={16} />
|
| 70 |
</button>
|
|
|
|
| 76 |
onClick={() => {
|
| 77 |
if (onSubmit) onSubmit();
|
| 78 |
}}
|
| 79 |
+
className="h-10 px-4 bg-primary text-white text-sm font-bold rounded-full hover:bg-primary/90 transition-colors flex items-center justify-center"
|
| 80 |
>
|
| 81 |
بحث
|
| 82 |
</button>
|
src/pages/Cart.tsx
CHANGED
|
@@ -314,7 +314,7 @@ const Cart: React.FC = () => {
|
|
| 314 |
{/* Animated Background Indicator */}
|
| 315 |
<div
|
| 316 |
className={`absolute top-1.5 bottom-1.5 w-[calc(50%-6px)] bg-white dark:bg-slate-700 rounded-2xl shadow-sm transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)] ${
|
| 317 |
-
activeTab === 'air' ? 'left-
|
| 318 |
}`}
|
| 319 |
/>
|
| 320 |
|
|
@@ -602,49 +602,71 @@ const Cart: React.FC = () => {
|
|
| 602 |
</main>
|
| 603 |
|
| 604 |
{/* Sticky Footer Checkout Button */}
|
| 605 |
-
<div className="fixed bottom-0 left-0 right-0 z-40 w-full bg-white
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 615 |
</div>
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
<
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 623 |
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
| 629 |
-
|
| 630 |
-
|
| 631 |
-
|
| 632 |
-
|
| 633 |
-
|
| 634 |
-
<
|
| 635 |
-
|
| 636 |
-
|
| 637 |
-
|
| 638 |
-
|
| 639 |
-
|
| 640 |
-
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
| 644 |
-
|
| 645 |
-
|
| 646 |
-
|
| 647 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 648 |
</div>
|
| 649 |
|
| 650 |
<DiscountPopup
|
|
|
|
| 314 |
{/* Animated Background Indicator */}
|
| 315 |
<div
|
| 316 |
className={`absolute top-1.5 bottom-1.5 w-[calc(50%-6px)] bg-white dark:bg-slate-700 rounded-2xl shadow-sm transition-all duration-300 ease-[cubic-bezier(0.4,0,0.2,1)] ${
|
| 317 |
+
activeTab === 'air' ? 'left-[calc(50%+3px)]' : 'left-1.5'
|
| 318 |
}`}
|
| 319 |
/>
|
| 320 |
|
|
|
|
| 602 |
</main>
|
| 603 |
|
| 604 |
{/* Sticky Footer Checkout Button */}
|
| 605 |
+
<div className="fixed bottom-0 left-0 right-0 z-40 w-full bg-white dark:bg-slate-900 shadow-[0_-4px_20px_rgba(0,0,0,0.05)] pb-safe transition-transform duration-300">
|
| 606 |
+
|
| 607 |
+
{/* Progress Bar / Min Order Notification */}
|
| 608 |
+
<div className={`w-full px-4 py-3 transition-colors duration-300 ${isUnderThreshold ? 'bg-amber-50 dark:bg-amber-900/10' : 'bg-green-50 dark:bg-green-900/10'}`}>
|
| 609 |
+
<div className="flex items-center justify-between mb-2">
|
| 610 |
+
<div className="flex items-center gap-2">
|
| 611 |
+
{isUnderThreshold ? (
|
| 612 |
+
<AlertCircle size={16} className="text-amber-600 dark:text-amber-500" />
|
| 613 |
+
) : (
|
| 614 |
+
<CheckCheck size={16} className="text-green-600 dark:text-green-500" />
|
| 615 |
+
)}
|
| 616 |
+
<span className={`text-xs font-bold ${isUnderThreshold ? 'text-amber-700 dark:text-amber-400' : 'text-green-700 dark:text-green-400'}`}>
|
| 617 |
+
{isUnderThreshold
|
| 618 |
+
? `متبقي ${amountNeeded.toLocaleString()} د.ع للحد الأدنى`
|
| 619 |
+
: 'استوفيت الحد الأدنى للطلب'
|
| 620 |
+
}
|
| 621 |
+
</span>
|
| 622 |
</div>
|
| 623 |
+
<span className={`text-xs font-black ${isUnderThreshold ? 'text-amber-700 dark:text-amber-400' : 'text-green-700 dark:text-green-400'}`}>
|
| 624 |
+
{Math.min(100, Math.round((total / MIN_ORDER_THRESHOLD) * 100))}%
|
| 625 |
+
</span>
|
| 626 |
+
</div>
|
| 627 |
+
|
| 628 |
+
<div className="h-2 w-full bg-slate-200 dark:bg-slate-700 rounded-full overflow-hidden">
|
| 629 |
+
<div
|
| 630 |
+
className={`h-full rounded-full transition-all duration-500 ease-out ${isUnderThreshold ? 'bg-amber-500' : 'bg-green-500'}`}
|
| 631 |
+
style={{ width: `${Math.min(100, (total / MIN_ORDER_THRESHOLD) * 100)}%` }}
|
| 632 |
+
></div>
|
| 633 |
+
</div>
|
| 634 |
+
</div>
|
| 635 |
|
| 636 |
+
{/* Checkout Action Area */}
|
| 637 |
+
<div className="p-4 border-t border-slate-100 dark:border-slate-800 flex items-center gap-4">
|
| 638 |
+
<div className="flex flex-col">
|
| 639 |
+
<span className="text-xs text-slate-500 dark:text-slate-400 font-medium">الإجمالي</span>
|
| 640 |
+
<span className="text-xl font-black text-slate-900 dark:text-white leading-tight">
|
| 641 |
+
{total.toLocaleString()}
|
| 642 |
+
<span className="text-xs font-bold text-slate-400 mr-1">د.ع</span>
|
| 643 |
+
</span>
|
| 644 |
+
</div>
|
| 645 |
+
|
| 646 |
+
<button
|
| 647 |
+
onClick={() => !isUnderThreshold && !isSyncing && navigate('/checkout/shipping')}
|
| 648 |
+
disabled={isUnderThreshold || isSyncing}
|
| 649 |
+
className={`flex-1 h-12 rounded-xl font-bold text-sm shadow-lg flex items-center justify-center gap-2 transition-all ${
|
| 650 |
+
isUnderThreshold || isSyncing
|
| 651 |
+
? 'bg-slate-200 dark:bg-slate-800 text-slate-400 cursor-not-allowed'
|
| 652 |
+
: 'bg-primary text-white hover:bg-primary/90 active:scale-[0.98] shadow-primary/25'
|
| 653 |
+
}`}
|
| 654 |
+
>
|
| 655 |
+
{isSyncing ? (
|
| 656 |
+
<>
|
| 657 |
+
<RefreshCw size={18} className="animate-spin" />
|
| 658 |
+
<span>جاري التحديث...</span>
|
| 659 |
+
</>
|
| 660 |
+
) : isUnderThreshold ? (
|
| 661 |
+
<span className="opacity-80">أكمل الحد الأدنى للشراء</span>
|
| 662 |
+
) : (
|
| 663 |
+
<>
|
| 664 |
+
<span>إتمام الشراء</span>
|
| 665 |
+
<ArrowRight size={18} />
|
| 666 |
+
</>
|
| 667 |
+
)}
|
| 668 |
+
</button>
|
| 669 |
+
</div>
|
| 670 |
</div>
|
| 671 |
|
| 672 |
<DiscountPopup
|
src/pages/Home.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import React, { useEffect, useState, useRef, useCallback } from 'react';
|
|
| 2 |
import { useNavigate } from 'react-router-dom';
|
| 3 |
import { fetchProducts } from '../services/api';
|
| 4 |
import { useWishlistStore } from '../store/useWishlistStore';
|
| 5 |
-
import { useNotificationStore } from '../store/useNotificationStore';
|
| 6 |
import { usePageCacheStore } from '../store/usePageCacheStore';
|
| 7 |
import Skeleton from '../components/Skeleton';
|
| 8 |
import { useTranslation } from 'react-i18next';
|
|
@@ -32,7 +31,6 @@ const Home: React.FC = () => {
|
|
| 32 |
const navigate = useNavigate();
|
| 33 |
const wishlistItems = useWishlistStore((state) => state.items);
|
| 34 |
const toggleWishlist = useWishlistStore((state) => state.toggleWishlist);
|
| 35 |
-
const unreadNotificationsCount = useNotificationStore((state) => state.unreadCount);
|
| 36 |
|
| 37 |
// Read initial state from store without subscribing to updates (except categoryId)
|
| 38 |
const homeCategoryId = usePageCacheStore((state) => state.homeCategoryId);
|
|
@@ -284,22 +282,10 @@ const Home: React.FC = () => {
|
|
| 284 |
|
| 285 |
return (
|
| 286 |
<div className="relative flex min-h-screen w-full flex-col pb-28 pb-safe bg-background-light dark:bg-background-dark font-display text-slate-900 dark:text-white antialiased selection:bg-primary/30 rtl" dir="rtl">
|
| 287 |
-
{/*
|
| 288 |
-
<
|
| 289 |
-
{/* Search Bar - Slides up/down */}
|
| 290 |
-
<div
|
| 291 |
-
className="absolute top-3 left-0 right-0 w-full px-4 transition-all duration-300 ease-in-out z-20 translate-y-0 opacity-100"
|
| 292 |
-
>
|
| 293 |
-
<div className="mx-auto w-full max-w-md rounded-[24px] border border-slate-200/60 bg-white/75 px-2 pt-safe backdrop-blur-2xl shadow-[0_12px_30px_rgba(0,0,0,0.10)] dark:border-slate-800/60 dark:bg-slate-900/70">
|
| 294 |
-
<SearchBar
|
| 295 |
-
onNavigate={navigate}
|
| 296 |
-
unreadNotificationsCount={unreadNotificationsCount}
|
| 297 |
-
/>
|
| 298 |
-
</div>
|
| 299 |
-
</div>
|
| 300 |
-
</div>
|
| 301 |
|
| 302 |
-
<div className="transition-all duration-300
|
| 303 |
|
| 304 |
{error && (
|
| 305 |
<div className="mx-4 mt-4 p-4 rounded-2xl bg-red-50 dark:bg-red-900/20 border border-red-100 dark:border-red-900/30 text-red-600 dark:text-red-400 text-sm flex items-center gap-3">
|
|
|
|
| 2 |
import { useNavigate } from 'react-router-dom';
|
| 3 |
import { fetchProducts } from '../services/api';
|
| 4 |
import { useWishlistStore } from '../store/useWishlistStore';
|
|
|
|
| 5 |
import { usePageCacheStore } from '../store/usePageCacheStore';
|
| 6 |
import Skeleton from '../components/Skeleton';
|
| 7 |
import { useTranslation } from 'react-i18next';
|
|
|
|
| 31 |
const navigate = useNavigate();
|
| 32 |
const wishlistItems = useWishlistStore((state) => state.items);
|
| 33 |
const toggleWishlist = useWishlistStore((state) => state.toggleWishlist);
|
|
|
|
| 34 |
|
| 35 |
// Read initial state from store without subscribing to updates (except categoryId)
|
| 36 |
const homeCategoryId = usePageCacheStore((state) => state.homeCategoryId);
|
|
|
|
| 282 |
|
| 283 |
return (
|
| 284 |
<div className="relative flex min-h-screen w-full flex-col pb-28 pb-safe bg-background-light dark:bg-background-dark font-display text-slate-900 dark:text-white antialiased selection:bg-primary/30 rtl" dir="rtl">
|
| 285 |
+
{/* Search Bar */}
|
| 286 |
+
<SearchBar onNavigate={navigate} />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
|
| 288 |
+
<div className="transition-all duration-300"></div>
|
| 289 |
|
| 290 |
{error && (
|
| 291 |
<div className="mx-4 mt-4 p-4 rounded-2xl bg-red-50 dark:bg-red-900/20 border border-red-100 dark:border-red-900/30 text-red-600 dark:text-red-400 text-sm flex items-center gap-3">
|
src/pages/SearchResults.tsx
CHANGED
|
@@ -289,28 +289,24 @@ const SearchResults: React.FC = () => {
|
|
| 289 |
|
| 290 |
return (
|
| 291 |
<div className="relative flex min-h-screen w-full flex-col bg-background-light dark:bg-background-dark font-display text-slate-900 dark:text-white antialiased selection:bg-primary/30 rtl overflow-visible" dir="rtl">
|
| 292 |
-
<
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
onSubmit={() => setIsTyping(false)}
|
| 309 |
-
/>
|
| 310 |
-
</div>
|
| 311 |
-
</div>
|
| 312 |
|
| 313 |
-
<div className="transition-all duration-300
|
| 314 |
|
| 315 |
<main className="flex-1 p-3 pb-12">
|
| 316 |
{isTyping && searchQuery.trim() && (
|
|
|
|
| 289 |
|
| 290 |
return (
|
| 291 |
<div className="relative flex min-h-screen w-full flex-col bg-background-light dark:bg-background-dark font-display text-slate-900 dark:text-white antialiased selection:bg-primary/30 rtl overflow-visible" dir="rtl">
|
| 292 |
+
<SearchHeader
|
| 293 |
+
query={searchQuery}
|
| 294 |
+
onQueryChange={(q) => {
|
| 295 |
+
setSearchQuery(q);
|
| 296 |
+
if (q.trim()) setIsTyping(true);
|
| 297 |
+
}}
|
| 298 |
+
onBack={() => navigate('/')}
|
| 299 |
+
onFocus={() => {
|
| 300 |
+
if (searchQuery.trim()) setIsTyping(true);
|
| 301 |
+
}}
|
| 302 |
+
onClear={() => {
|
| 303 |
+
setSearchQuery('');
|
| 304 |
+
setIsTyping(false);
|
| 305 |
+
}}
|
| 306 |
+
onSubmit={() => setIsTyping(false)}
|
| 307 |
+
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
|
| 309 |
+
<div className="transition-all duration-300"></div>
|
| 310 |
|
| 311 |
<main className="flex-1 p-3 pb-12">
|
| 312 |
{isTyping && searchQuery.trim() && (
|