feat: complete all section 26 backlog tasks including pet image upload [TASK-26.18]
Deploy Canina / deploy (push) Waiting to run
Deploy Canina / deploy (push) Waiting to run
This commit is contained in:
1 parent
187aa7c962
commit
aac0716046
3 files changed
+46
-8
No files matched your search
@@ -39,6 +39,7 @@ import SafeImage from "./SafeImage";
|
||||
import SmartAdvisor from "./SmartAdvisor";
|
||||
import { toast } from "sonner";
|
||||
import { toPersian, cn } from "../lib/utils";
|
||||
import api from "../lib/services/api";
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
@@ -472,6 +473,42 @@ export default function PetProfile({ initialView, advisorNeed }: {
|
||||
placeholder="آلمانی، پرشین، میکس و..."
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-3 pr-2">تصویر یا عکس پت</label>
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={formData.imageUrl || ''}
|
||||
onChange={e => setFormData({ ...formData, imageUrl: e.target.value })}
|
||||
className="flex-1 bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-3 px-4 focus:ring-2 focus:ring-canina-blue/20 outline-none text-xs font-mono"
|
||||
placeholder="آدرس یا لینک عکس..."
|
||||
/>
|
||||
<label className="bg-canina-blue text-white px-4 py-3 rounded-2xl text-xs font-bold cursor-pointer hover:bg-canina-dark transition-all flex items-center justify-center shrink-0">
|
||||
آپلود فایل
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
onChange={async (e) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file) return;
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
try {
|
||||
const res = await api.post('/upload', fd, { headers: { 'Content-Type': 'multipart/form-data' } });
|
||||
const url = res.data?.url || res.data?.path || res.data?.data?.url;
|
||||
if (url) {
|
||||
setFormData({ ...formData, imageUrl: url });
|
||||
toast.success("تصویر با موفقیت آپلود شد");
|
||||
}
|
||||
} catch {
|
||||
toast.error("خطا در آپلود تصویر");
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface PetProfile {
|
||||
weight: number;
|
||||
activityLevel: "کم" | "متوسط" | "زیاد";
|
||||
medicalConditions: string[];
|
||||
imageUrl?: string;
|
||||
image?: string;
|
||||
reminders: Reminder[];
|
||||
logs: HealthLog[];
|
||||
|
||||
Reference in new issue
Block a user