style: improve health advisor UX, fix broken thumbnails, add Persian equivalents to product names for SEO, and refine card title alignments
This commit is contained in:
1 parent
711fb414ab
commit
cf705ea121
7 files changed
+56
-18
No files matched your search
@@ -59,6 +59,8 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
const [name, setName] = useState("");
|
||||
const [type, setType] = useState<"سگ" | "گربه">("سگ");
|
||||
const [breed, setBreed] = useState("");
|
||||
const [showError, setShowError] = useState(false);
|
||||
const [shake, setShake] = useState(false);
|
||||
|
||||
// Step 2 Data
|
||||
const [age, setAge] = useState<number>(3);
|
||||
@@ -68,7 +70,17 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
// Step 3 Data
|
||||
const [medicalConditions, setMedicalConditions] = useState<string[]>([]);
|
||||
|
||||
const handleNext = () => setStep(s => s + 1);
|
||||
const handleNext = () => {
|
||||
if (step === 1) {
|
||||
if (!name.trim() || !breed.trim()) {
|
||||
setShowError(true);
|
||||
setShake(true);
|
||||
setTimeout(() => setShake(false), 500);
|
||||
return;
|
||||
}
|
||||
}
|
||||
setStep(s => s + 1);
|
||||
};
|
||||
const handleBack = () => setStep(s => s - 1);
|
||||
|
||||
const handleSubmit = () => {
|
||||
@@ -153,9 +165,17 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
<input
|
||||
type="text"
|
||||
value={name}
|
||||
onChange={e => setName(e.target.value)}
|
||||
onChange={e => {
|
||||
setName(e.target.value);
|
||||
if (e.target.value.trim() && breed.trim()) setShowError(false);
|
||||
}}
|
||||
placeholder={getText('advisor_pet_name_placeholder', "لوسی، تدی...")}
|
||||
className="w-full bg-white border border-medical-gray-300 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canina-blue/30 focus-visible:ring-4 focus-visible:ring-canina-blue/40 outline-none font-black text-lg font-vazir placeholder-medical-gray-500 text-medical-gray-900"
|
||||
className={cn(
|
||||
"w-full bg-white border rounded-2xl py-4 px-6 focus:ring-2 outline-none font-black text-lg font-vazir placeholder-medical-gray-500 text-medical-gray-900 transition-all",
|
||||
showError && !name.trim()
|
||||
? "border-red-500 focus:ring-red-500/30"
|
||||
: "border-medical-gray-300 focus:ring-canina-blue/30 focus-visible:ring-4 focus-visible:ring-canina-blue/40"
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
@@ -163,23 +183,35 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
|
||||
<input
|
||||
type="text"
|
||||
value={breed}
|
||||
onChange={e => setBreed(e.target.value)}
|
||||
onChange={e => {
|
||||
setBreed(e.target.value);
|
||||
if (name.trim() && e.target.value.trim()) setShowError(false);
|
||||
}}
|
||||
placeholder={getText('advisor_pet_breed_placeholder', "ژرمن، پرشین...")}
|
||||
className="w-full bg-white border border-medical-gray-300 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canina-blue/30 focus-visible:ring-4 focus-visible:ring-canina-blue/40 outline-none font-bold font-vazir placeholder-medical-gray-500 text-medical-gray-900"
|
||||
className={cn(
|
||||
"w-full bg-white border rounded-2xl py-4 px-6 focus:ring-2 outline-none font-bold font-vazir placeholder-medical-gray-500 text-medical-gray-900 transition-all",
|
||||
showError && !breed.trim()
|
||||
? "border-red-500 focus:ring-red-500/30"
|
||||
: "border-medical-gray-300 focus:ring-canina-blue/30 focus-visible:ring-4 focus-visible:ring-canina-blue/40"
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
<motion.button
|
||||
onClick={handleNext}
|
||||
disabled={!name || !breed}
|
||||
className="w-full py-6 rounded-3xl font-black text-lg flex items-center justify-center gap-3 font-vazir min-h-[48px] transition-all focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed disabled:shadow-none disabled:border-2 disabled:border-gray-400 bg-medical-gray-900 text-white hover:bg-canina-blue shadow-xl shadow-medical-gray-900/10"
|
||||
animate={shake ? { x: [-10, 10, -10, 10, -5, 5, -2, 2, 0] } : { x: 0 }}
|
||||
transition={{ duration: 0.4 }}
|
||||
className={cn(
|
||||
"w-full py-6 rounded-3xl font-black text-lg flex items-center justify-center gap-3 font-vazir min-h-[48px] transition-all focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none bg-medical-gray-900 text-white hover:bg-canina-blue shadow-xl shadow-medical-gray-900/10",
|
||||
(!name.trim() || !breed.trim()) ? "opacity-60 cursor-pointer" : ""
|
||||
)}
|
||||
>
|
||||
{getText('advisor_submit_btn', "ثبت هویت و ادامه")}
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
</button>
|
||||
{(!name || !breed) && (
|
||||
<p className="text-center text-xs font-black text-amber-600 mt-2 font-vazir animate-pulse">
|
||||
</motion.button>
|
||||
{showError && (!name.trim() || !breed.trim()) && (
|
||||
<p className="text-center text-xs font-black text-red-500 mt-2 font-vazir animate-pulse">
|
||||
{getText('advisor_validation_warning', "⚠️ لطفاً ابتدا نام و نژاد پت را در بالا وارد کنید.")}
|
||||
</p>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user