feat: core pages and components migrated to Next.js (Home, Shop, Product)
This commit is contained in:
1 parent
72d2a5600a
commit
3de0408e6f
11 files changed
+246
-138
No files matched your search
@@ -16,16 +16,13 @@ import {
|
||||
} from "lucide-react";
|
||||
import { toPersian, cn } from "../lib/utils";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useUserStore } from "../lib/store/userStore";
|
||||
import { useUIStore } from "../lib/store/uiStore";
|
||||
import { usePetStore } from "../lib/store/usePetStore";
|
||||
|
||||
interface SmartAdvisorProps {
|
||||
onComplete: (data: {
|
||||
name: string,
|
||||
type: "سگ" | "گربه",
|
||||
breed: string,
|
||||
age: number,
|
||||
weight: number,
|
||||
activityLevel: "کم" | "متوسط" | "زیاد",
|
||||
medicalConditions: string[]
|
||||
}) => void;
|
||||
onComplete?: (data: any) => void;
|
||||
}
|
||||
|
||||
const MEDICAL_OPTIONS = [
|
||||
@@ -37,7 +34,11 @@ const MEDICAL_OPTIONS = [
|
||||
{ id: "appetite", label: "بیاشتهایی", condition: "بیاشتهایی" },
|
||||
];
|
||||
|
||||
export default function SmartAdvisor({ onComplete }: SmartAdvisorProps) {
|
||||
export default function SmartAdvisor({ onComplete }: SmartAdvisorProps = {}) {
|
||||
const router = useRouter();
|
||||
const { isLoggedIn } = useUserStore();
|
||||
const setLoginModalOpen = useUIStore(state => state.setLoginModalOpen);
|
||||
const { addPet, setActivePet } = usePetStore();
|
||||
const texts = useSettingsStore(state => state.texts);
|
||||
const medicalOptions = React.useMemo(() => {
|
||||
const jsonStr = texts['medical_options'];
|
||||
@@ -70,15 +71,21 @@ export default function SmartAdvisor({ onComplete }: SmartAdvisorProps) {
|
||||
const handleBack = () => setStep(s => s - 1);
|
||||
|
||||
const handleSubmit = () => {
|
||||
onComplete({
|
||||
name,
|
||||
type,
|
||||
breed,
|
||||
age,
|
||||
weight,
|
||||
activityLevel,
|
||||
medicalConditions
|
||||
});
|
||||
const data = {
|
||||
name, type, breed, age, weight, activityLevel, medicalConditions
|
||||
};
|
||||
if (onComplete) {
|
||||
onComplete(data);
|
||||
} else {
|
||||
if (!isLoggedIn) {
|
||||
setLoginModalOpen(true, data);
|
||||
} else {
|
||||
const newPet = { ...data, id: Date.now().toString() };
|
||||
addPet(newPet);
|
||||
setActivePet(newPet.id);
|
||||
router.push('/profile');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user