feat(doctors): add doctors management, image optimization, testimonials section and clean fallbacks
Deploy Canina / deploy (push) Has been cancelled

This commit is contained in:
parsa aghaei committed 2026-08-17 16:25:20 +03:30
1 parent 308338ec47
commit 813c96742d
17 files changed
+1135 -170

No files matched your search

+25 -10
View File
@@ -174,17 +174,7 @@ model Product {
@@map("products")
}
model Doctor {
id String @id @default(uuid()) @db.Uuid
name String @db.VarChar(150)
title String @db.VarChar(150)
avatarUrl String? @map("avatar_url") @db.Text
bio String? @db.Text
clinic String? @db.VarChar(200)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
@@map("doctors")
}
model ProductIngredient {
productId String @map("product_id") @db.Uuid
@@ -463,10 +453,32 @@ model SmartAdvisorRule {
@@map("smart_advisor_rules")
}
model Doctor {
id String @id @default(uuid()) @db.Uuid
name String @db.VarChar(150)
title String? @db.VarChar(150)
clinicName String? @map("clinic_name") @db.VarChar(200)
avatarUrl String? @map("avatar_url") @db.Text
bio String? @db.Text
cv String? @db.Text
phone String? @db.VarChar(50)
email String? @db.VarChar(150)
instagram String? @db.VarChar(100)
isActive Boolean @default(true) @map("is_active")
order Int @default(0)
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz()
videos Video[]
@@map("doctors")
}
model Video {
id String @id @default(uuid()) @db.Uuid
title String @db.VarChar(200)
doctor String @db.VarChar(150)
doctorId String? @map("doctor_id") @db.Uuid
duration String @default("02:00") @db.VarChar(20)
thumbnail String? @db.Text
videoUrl String @map("video_url") @db.Text
@@ -476,6 +488,9 @@ model Video {
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz()
updatedAt DateTime @updatedAt @map("updated_at") @db.Timestamptz()
doctorRef Doctor? @relation(fields: [doctorId], references: [id], onDelete: SetNull)
@@index([doctorId])
@@map("videos")
}
+2
View File
@@ -30,6 +30,7 @@ import { B2BModule } from './b2b/b2b.module';
import { PaymentModule } from './payment/payment.module';
import { TicketsModule } from './tickets/tickets.module';
import { ReviewsModule } from './reviews/reviews.module';
import { DoctorsModule } from './doctors/doctors.module';
import { Request, Response, NextFunction } from 'express';
@@ -48,6 +49,7 @@ import { Request, Response, NextFunction } from 'express';
PaymentModule,
TicketsModule,
ReviewsModule,
DoctorsModule,
ThrottlerModule.forRoot([
{
ttl: 60000,
+60
View File
@@ -0,0 +1,60 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Body,
Param,
Query,
UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { DoctorsService, DoctorQuery } from './doctors.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { Prisma } from '@prisma/client';
@ApiTags('Doctors')
@Controller('doctors')
export class DoctorsController {
constructor(private readonly doctorsService: DoctorsService) {}
@Get()
@ApiOperation({ summary: 'Get list of all doctors / specialists' })
findAll(@Query() query: DoctorQuery) {
return this.doctorsService.findAll(query);
}
@Get(':id')
@ApiOperation({ summary: 'Get doctor by ID with their videos and CV' })
findOne(@Param('id') id: string) {
return this.doctorsService.findOne(id);
}
@Post()
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Create new doctor' })
create(@Body() createDoctorDto: Prisma.DoctorCreateInput) {
return this.doctorsService.create(createDoctorDto);
}
@Put(':id')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Update doctor' })
update(
@Param('id') id: string,
@Body() updateDoctorDto: Prisma.DoctorUpdateInput,
) {
return this.doctorsService.update(id, updateDoctorDto);
}
@Delete(':id')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Delete doctor' })
remove(@Param('id') id: string) {
return this.doctorsService.remove(id);
}
}
+12
View File
@@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { DoctorsService } from './doctors.service';
import { DoctorsController } from './doctors.controller';
import { PrismaModule } from '../prisma/prisma.module';
@Module({
imports: [PrismaModule],
controllers: [DoctorsController],
providers: [DoctorsService],
exports: [DoctorsService],
})
export class DoctorsModule {}
+102
View File
@@ -0,0 +1,102 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { Prisma } from '@prisma/client';
import { PrismaService } from '../prisma/prisma.service';
export class DoctorQuery {
page?: number | string;
limit?: number | string;
search?: string;
activeOnly?: boolean | string;
}
@Injectable()
export class DoctorsService {
constructor(private readonly prisma: PrismaService) {}
async findAll(query: DoctorQuery = {}) {
const page = Number(query.page) || 1;
const limit = Number(query.limit) || 50;
const skip = (page - 1) * limit;
const where: Prisma.DoctorWhereInput = {};
if (query.activeOnly === 'true' || query.activeOnly === true) {
where.isActive = true;
}
if (query.search) {
where.OR = [
{ name: { contains: query.search, mode: 'insensitive' } },
{ title: { contains: query.search, mode: 'insensitive' } },
{ clinicName: { contains: query.search, mode: 'insensitive' } },
{ bio: { contains: query.search, mode: 'insensitive' } },
{ cv: { contains: query.search, mode: 'insensitive' } },
];
}
const [doctors, total] = await Promise.all([
this.prisma.doctor.findMany({
where,
skip,
take: limit,
orderBy: [{ order: 'asc' }, { createdAt: 'desc' }],
include: {
_count: {
select: { videos: true },
},
},
}),
this.prisma.doctor.count({ where }),
]);
return {
doctors,
meta: {
total,
page,
limit,
totalPages: Math.ceil(total / limit),
},
};
}
async findOne(id: string) {
const doctor = await this.prisma.doctor.findUnique({
where: { id },
include: {
videos: {
orderBy: { createdAt: 'desc' },
},
},
});
if (!doctor) {
throw new NotFoundException(`پزشک با شناسه ${id} یافت نشد`);
}
return doctor;
}
async create(data: Prisma.DoctorCreateInput) {
return this.prisma.doctor.create({
data,
});
}
async update(id: string, data: Prisma.DoctorUpdateInput) {
await this.findOne(id);
return this.prisma.doctor.update({
where: { id },
data,
});
}
async remove(id: string) {
await this.findOne(id);
return this.prisma.doctor.delete({
where: { id },
});
}
}
@@ -18,6 +18,13 @@ export class CreateVideoDto {
@IsNotEmpty()
doctor: string;
@ApiPropertyOptional({
description: 'شناسه پزشک مرتبط در سیستم',
})
@IsString()
@IsOptional()
doctorId?: string;
@ApiPropertyOptional({ description: 'مدت زمان ویدئو', example: '۰۲:۳۰' })
@IsString()
@IsOptional()
+13
View File
@@ -39,6 +39,9 @@ export class VideosService {
skip,
take: limit,
orderBy: { createdAt: 'desc' },
include: {
doctorRef: true,
},
}),
this.prisma.video.count({ where }),
]);
@@ -57,6 +60,9 @@ export class VideosService {
async findOne(id: string) {
const video = await this.prisma.video.findUnique({
where: { id },
include: {
doctorRef: true,
},
});
if (!video) {
@@ -71,12 +77,16 @@ export class VideosService {
data: {
title: createVideoDto.title,
doctor: createVideoDto.doctor,
doctorId: createVideoDto.doctorId || null,
duration: createVideoDto.duration || '00:00',
videoUrl: createVideoDto.videoUrl,
thumbnail: createVideoDto.thumbnail || '',
description: createVideoDto.description || null,
isFeatured: createVideoDto.isFeatured || false,
},
include: {
doctorRef: true,
},
});
}
@@ -86,6 +96,9 @@ export class VideosService {
return this.prisma.video.update({
where: { id },
data: updateVideoDto,
include: {
doctorRef: true,
},
});
}
@@ -23,6 +23,7 @@ import {
Settings,
ShieldCheck,
Languages,
UserCheck,
DollarSign,
Sliders,
Globe,
@@ -138,6 +139,7 @@ export default function Sidebar({ isOpen, setIsOpen }: SidebarProps) {
{ icon: FileText, label: 'وبلاگ و مقالات', path: '/blogs' },
{ icon: FlaskConical, label: 'دانشنامه ترکیبات', path: '/ingredients' },
{ icon: BookOpen, label: 'دانشنامه عمومی و علمی', path: '/wiki' },
{ icon: UserCheck, label: 'پزشکان و کادر علمی', path: '/doctors' },
{ icon: MessageSquareQuote, label: 'نظرات و گواهی متخصصان', path: '/testimonials' },
{ icon: Video, label: 'ویدئوها و آموزش‌ها', path: '/videos' },
{ icon: Image, label: 'کتابخانه رسانه', path: '/media' },
@@ -0,0 +1,538 @@
import React, { useState, useEffect, useCallback } from 'react';
import { Plus, Search, Edit2, Trash2, UserCheck, Star, X, ImageIcon, Phone, Mail, FileText, CheckCircle2, ShieldCheck, Globe } from 'lucide-react';
import { toast } from 'react-hot-toast';
import api, { BASE_DOMAIN } from '../services/api';
import ConfirmModal from '../components/ui/ConfirmModal';
import MediaSelector from '../components/ui/MediaSelector';
import Spinner from '../components/ui/Spinner';
export interface Doctor {
id: string;
name: string;
title?: string;
clinicName?: string;
avatarUrl?: string;
bio?: string;
cv?: string;
phone?: string;
email?: string;
instagram?: string;
isActive: boolean;
order: number;
_count?: {
videos: number;
};
createdAt: string;
}
export default function DoctorsManager() {
const [doctors, setDoctors] = useState<Doctor[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [searchTerm, setSearchTerm] = useState('');
const [isModalOpen, setIsModalOpen] = useState(false);
const [editingDoctor, setEditingDoctor] = useState<Doctor | null>(null);
const [deleteTargetId, setDeleteTargetId] = useState<string | null>(null);
const [isAvatarMediaOpen, setIsAvatarMediaOpen] = useState(false);
const [isCvDetailsOpen, setIsCvDetailsOpen] = useState<Doctor | null>(null);
const [formData, setFormData] = useState({
name: '',
title: '',
clinicName: '',
avatarUrl: '',
bio: '',
cv: '',
phone: '',
email: '',
instagram: '',
isActive: true,
order: 0,
});
const fetchDoctors = useCallback(async () => {
try {
setIsLoading(true);
const res = await api.get('/doctors', {
params: { search: searchTerm, limit: 100 },
});
const raw = res.data;
const list = Array.isArray(raw?.doctors)
? raw.doctors
: Array.isArray(raw?.data?.doctors)
? raw.data.doctors
: Array.isArray(raw?.data)
? raw.data
: Array.isArray(raw)
? raw
: [];
setDoctors(list);
} catch (err) {
console.error('Failed to fetch doctors:', err);
toast.error('خطا در دریافت لیست پزشکان');
setDoctors([]);
} finally {
setIsLoading(false);
}
}, [searchTerm]);
useEffect(() => {
fetchDoctors();
}, [fetchDoctors]);
const handleOpenModal = (doc?: Doctor) => {
if (doc) {
setEditingDoctor(doc);
setFormData({
name: doc.name || '',
title: doc.title || '',
clinicName: doc.clinicName || '',
avatarUrl: doc.avatarUrl || '',
bio: doc.bio || '',
cv: doc.cv || '',
phone: doc.phone || '',
email: doc.email || '',
instagram: doc.instagram || '',
isActive: doc.isActive !== false,
order: doc.order || 0,
});
} else {
setEditingDoctor(null);
setFormData({
name: '',
title: 'دامپزشک و متخصص تغذیه',
clinicName: '',
avatarUrl: '',
bio: '',
cv: '',
phone: '',
email: '',
instagram: '',
isActive: true,
order: doctors.length + 1,
});
}
setIsModalOpen(true);
};
const handleSave = async (e: React.FormEvent) => {
e.preventDefault();
if (!formData.name.trim()) {
toast.error('لطفاً نام پزشک را وارد کنید');
return;
}
try {
if (editingDoctor) {
await api.put(`/doctors/${editingDoctor.id}`, formData);
toast.success('اطلاعات پزشک با موفقیت بروزرسانی شد');
} else {
await api.post('/doctors', formData);
toast.success('پزشک جدید با موفقیت افزوده شد');
}
setIsModalOpen(false);
await fetchDoctors();
} catch (err) {
console.error('Save failed:', err);
toast.error('خطا در ذخیره‌سازی اطلاعات پزشک');
}
};
const handleDelete = async () => {
if (!deleteTargetId) return;
try {
await api.delete(`/doctors/${deleteTargetId}`);
toast.success('پزشک با موفقیت حذف شد');
setDeleteTargetId(null);
await fetchDoctors();
} catch (err) {
console.error('Delete failed:', err);
toast.error('خطا در حذف پزشک');
}
};
return (
<div className="p-6 space-y-6 font-vazir">
{/* Header */}
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 bg-white p-6 rounded-3xl border border-gray-100 shadow-xs">
<div>
<div className="flex items-center gap-3 mb-1">
<div className="w-10 h-10 rounded-2xl bg-purple-100 text-purple-600 flex items-center justify-center shadow-xs">
<UserCheck className="w-5 h-5" />
</div>
<h1 className="text-2xl font-black text-gray-900">مدیریت پزشکان و کادر علمی</h1>
</div>
<p className="text-sm text-gray-500 mr-13 font-medium">
ثبت اطلاعات و رزومه (CV) دامپزشکان جهت انتساب به ویدئوها، مشاوره‌ها و معرفی کادر تخصصی
</p>
</div>
<button
onClick={() => handleOpenModal()}
className="flex items-center justify-center gap-2 bg-purple-600 hover:bg-purple-700 text-white px-5 py-3 rounded-2xl font-bold transition-all shadow-md shadow-purple-200 cursor-pointer text-sm"
>
<Plus className="w-5 h-5" />
<span>افزودن پزشک جدید</span>
</button>
</div>
{/* Filter / Search */}
<div className="bg-white p-4 rounded-2xl border border-gray-100 shadow-xs flex items-center justify-between gap-4">
<div className="relative flex-1 max-w-md">
<Search className="w-5 h-5 absolute right-3.5 top-1/2 -translate-y-1/2 text-gray-400" />
<input
type="text"
placeholder="جستجو بر اساس نام، تخصص، کلینیک، رزومه..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-full pl-4 pr-11 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600 transition-colors"
/>
</div>
<div className="text-xs text-gray-400 font-bold">
مجموع: {doctors.length} نفر
</div>
</div>
{/* Grid List */}
{isLoading ? (
<div className="flex justify-center items-center py-20">
<Spinner size="lg" className="text-purple-600" />
</div>
) : doctors.length === 0 ? (
<div className="bg-white rounded-3xl p-16 text-center border border-dashed border-gray-200">
<div className="w-16 h-16 bg-gray-50 text-gray-400 rounded-2xl flex items-center justify-center mx-auto mb-4">
<UserCheck className="w-8 h-8" />
</div>
<h3 className="text-lg font-bold text-gray-800 mb-1">پزشکی یافت نشد</h3>
<p className="text-sm text-gray-400 mb-6">اولین پزشک یا متخصص کادر علمی را به سامانه اضافه کنید.</p>
<button
onClick={() => handleOpenModal()}
className="inline-flex items-center gap-2 bg-purple-600 hover:bg-purple-700 text-white px-5 py-2.5 rounded-xl font-bold text-sm shadow-sm"
>
<Plus className="w-4 h-4" />
افزودن اولین پزشک
</button>
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{doctors.map((doc) => (
<div
key={doc.id}
className="bg-white rounded-3xl p-6 border border-gray-100 shadow-xs hover:shadow-md transition-all relative flex flex-col justify-between group"
>
<div>
{/* Status Badge */}
<div className="flex justify-between items-start mb-4">
<span className={`px-3 py-1 rounded-full text-xs font-bold ${doc.isActive ? 'bg-green-100 text-green-700' : 'bg-gray-100 text-gray-500'}`}>
{doc.isActive ? 'فعال' : 'غیرفعال'}
</span>
<div className="flex items-center gap-1.5 opacity-80 group-hover:opacity-100 transition-opacity">
<button
onClick={() => handleOpenModal(doc)}
className="p-2 text-gray-500 hover:text-purple-600 hover:bg-purple-50 rounded-xl transition-colors cursor-pointer"
title="ویرایش"
>
<Edit2 className="w-4 h-4" />
</button>
<button
onClick={() => setDeleteTargetId(doc.id)}
className="p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded-xl transition-colors cursor-pointer"
title="حذف"
>
<Trash2 className="w-4 h-4" />
</button>
</div>
</div>
{/* Profile Header */}
<div className="flex items-center gap-4 mb-4">
<div className="w-16 h-16 rounded-2xl bg-purple-50 border border-purple-100 flex items-center justify-center overflow-hidden flex-shrink-0 relative">
{doc.avatarUrl ? (
<img
src={doc.avatarUrl.startsWith('http') ? doc.avatarUrl : `${BASE_DOMAIN}${doc.avatarUrl}`}
alt={doc.name}
className="w-full h-full object-cover"
/>
) : (
<UserCheck className="w-7 h-7 text-purple-400" />
)}
</div>
<div>
<h3 className="font-extrabold text-gray-900 text-base leading-tight mb-1">{doc.name}</h3>
<p className="text-xs text-purple-700 font-bold">{doc.title || 'دامپزشک'}</p>
{doc.clinicName && (
<p className="text-xs text-gray-400 font-medium mt-0.5">{doc.clinicName}</p>
)}
</div>
</div>
{/* Bio snippet */}
{doc.bio && (
<p className="text-xs text-gray-500 leading-relaxed line-clamp-2 mb-4 bg-gray-50/70 p-3 rounded-2xl border border-gray-100">
{doc.bio}
</p>
)}
{/* CV Button */}
{doc.cv && (
<button
onClick={() => setIsCvDetailsOpen(doc)}
className="w-full mb-4 py-2 px-3 bg-purple-50 hover:bg-purple-100 text-purple-700 rounded-xl text-xs font-extrabold flex items-center justify-center gap-1.5 transition-colors cursor-pointer"
>
<FileText className="w-3.5 h-3.5" />
<span>مشاهده رزومه و سوابق علمی (CV)</span>
</button>
)}
</div>
{/* Footer info */}
<div className="pt-4 border-t border-gray-100 flex items-center justify-between text-xs text-gray-400 font-medium">
<span>{doc._count?.videos || 0} ویدئوی آموزشی</span>
{doc.phone && <span className="font-mono">{doc.phone}</span>}
</div>
</div>
))}
</div>
)}
{/* Create / Edit Modal */}
{isModalOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs">
<div className="bg-white rounded-3xl max-w-2xl w-full max-h-[90vh] flex flex-col shadow-2xl overflow-hidden border border-gray-100 animate-in fade-in zoom-in-95 duration-200">
{/* Modal Header */}
<div className="px-6 py-4 border-b border-gray-100 flex items-center justify-between bg-gray-50/50">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-xl bg-purple-100 text-purple-600 flex items-center justify-center">
<UserCheck className="w-5 h-5" />
</div>
<div>
<h3 className="text-lg font-bold text-gray-900">
{editingDoctor ? 'ویرایش اطلاعات پزشک' : 'افزودن پزشک جدید'}
</h3>
<p className="text-xs text-gray-500 font-medium">مشخصات هویتی، آواتار و رزومه علمی پزشک</p>
</div>
</div>
<button
onClick={() => setIsModalOpen(false)}
className="p-2 text-gray-400 hover:text-red-500 hover:bg-red-50 rounded-xl transition-colors cursor-pointer"
>
<X className="w-5 h-5" />
</button>
</div>
{/* Form */}
<form onSubmit={handleSave} className="p-6 overflow-y-auto flex-1 space-y-4">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{/* Name */}
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">
نام و نام خانوادگی پزشک <span className="text-red-500">*</span>
</label>
<input
type="text"
required
placeholder="مثال: دکتر کلاوس هنینگ"
value={formData.name}
onChange={(e) => setFormData({ ...formData, name: e.target.value })}
className="w-full px-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600"
/>
</div>
{/* Title */}
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">تخصص یا عنوان علمی</label>
<input
type="text"
placeholder="مثال: متخصص ارتوپدی و تغذیه دامپزشکی"
value={formData.title}
onChange={(e) => setFormData({ ...formData, title: e.target.value })}
className="w-full px-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600"
/>
</div>
</div>
{/* Clinic Name */}
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">نام بیمارستان / کلینیک یا دانشگاه</label>
<input
type="text"
placeholder="مثال: کلینیک تخصصی دامپزشکی برلین"
value={formData.clinicName}
onChange={(e) => setFormData({ ...formData, clinicName: e.target.value })}
className="w-full px-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600"
/>
</div>
{/* Avatar Selector */}
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">تصویر پرتره / آواتار</label>
<div className="flex items-center gap-3">
<input
type="text"
placeholder="https://..."
value={formData.avatarUrl}
onChange={(e) => setFormData({ ...formData, avatarUrl: e.target.value })}
className="flex-1 px-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600"
/>
<button
type="button"
onClick={() => setIsAvatarMediaOpen(true)}
className="px-4 py-2.5 bg-purple-100 hover:bg-purple-200 text-purple-700 rounded-xl text-xs font-bold flex items-center gap-1.5 transition-colors cursor-pointer flex-shrink-0"
>
<ImageIcon className="w-4 h-4" />
<span>انتخاب از رسانه‌ها</span>
</button>
</div>
{formData.avatarUrl && (
<div className="mt-2 w-16 h-16 rounded-xl border border-gray-200 overflow-hidden bg-gray-50">
<img
src={formData.avatarUrl.startsWith('http') ? formData.avatarUrl : `${BASE_DOMAIN}${formData.avatarUrl}`}
alt="Preview"
className="w-full h-full object-cover"
/>
</div>
)}
</div>
{/* Bio */}
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">بیوگرافی کوتاه (معرفی سریع)</label>
<textarea
rows={2}
placeholder="معرفی کوتاه پزشک و فعالیت‌ها..."
value={formData.bio}
onChange={(e) => setFormData({ ...formData, bio: e.target.value })}
className="w-full px-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600"
/>
</div>
{/* CV */}
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">
رزومه، سوابق تحصیلی و مقالات علمی (CV)
</label>
<textarea
rows={4}
placeholder="سوابق تحصیلی، دوره‌های تخصصی، مقالات منتشر شده، تخصص‌های درمانی و..."
value={formData.cv}
onChange={(e) => setFormData({ ...formData, cv: e.target.value })}
className="w-full px-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm focus:outline-none focus:border-purple-600 leading-relaxed"
/>
</div>
{/* Contacts */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">تلفن تماس / واتساپ</label>
<input
type="text"
placeholder="۰۹۱۲..."
value={formData.phone}
onChange={(e) => setFormData({ ...formData, phone: e.target.value })}
className="w-full px-4 py-2 bg-gray-50 border border-gray-200 rounded-xl text-xs"
/>
</div>
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">ایمیل</label>
<input
type="email"
placeholder="doctor@example.com"
value={formData.email}
onChange={(e) => setFormData({ ...formData, email: e.target.value })}
className="w-full px-4 py-2 bg-gray-50 border border-gray-200 rounded-xl text-xs"
/>
</div>
<div>
<label className="block text-xs font-bold text-gray-700 mb-1">اینستاگرام</label>
<input
type="text"
placeholder="@dr_..."
value={formData.instagram}
onChange={(e) => setFormData({ ...formData, instagram: e.target.value })}
className="w-full px-4 py-2 bg-gray-50 border border-gray-200 rounded-xl text-xs font-mono"
/>
</div>
</div>
{/* Status & Order */}
<div className="flex items-center justify-between pt-2 border-t border-gray-100">
<label className="flex items-center gap-2 cursor-pointer">
<input
type="checkbox"
checked={formData.isActive}
onChange={(e) => setFormData({ ...formData, isActive: e.target.checked })}
className="w-4 h-4 text-purple-600 rounded-md"
/>
<span className="text-xs font-bold text-gray-700">پزشک فعال است و در لیست نمایش داده شود</span>
</label>
</div>
{/* Actions */}
<div className="flex justify-end gap-3 pt-4 border-t border-gray-100">
<button
type="button"
onClick={() => setIsModalOpen(false)}
className="px-5 py-2.5 text-gray-600 bg-gray-100 hover:bg-gray-200 rounded-xl text-xs font-bold transition-colors cursor-pointer"
>
انصراف
</button>
<button
type="submit"
className="px-6 py-2.5 bg-purple-600 hover:bg-purple-700 text-white rounded-xl text-xs font-bold shadow-md shadow-purple-200 transition-colors cursor-pointer"
>
{editingDoctor ? 'ذخیره تغییرات' : 'افزودن پزشک'}
</button>
</div>
</form>
</div>
</div>
)}
{/* CV Detail Modal */}
{isCvDetailsOpen && (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-xs">
<div className="bg-white rounded-3xl max-w-xl w-full p-6 shadow-2xl border border-gray-100 animate-in fade-in zoom-in-95">
<div className="flex items-center justify-between border-b border-gray-100 pb-4 mb-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-xl bg-purple-100 text-purple-600 flex items-center justify-center">
<FileText className="w-5 h-5" />
</div>
<div>
<h3 className="font-extrabold text-gray-900 text-base">{isCvDetailsOpen.name}</h3>
<p className="text-xs text-purple-600 font-bold">{isCvDetailsOpen.title}</p>
</div>
</div>
<button
onClick={() => setIsCvDetailsOpen(null)}
className="p-2 text-gray-400 hover:text-red-500 rounded-xl transition-colors cursor-pointer"
>
<X className="w-5 h-5" />
</button>
</div>
<div className="bg-gray-50 p-4 rounded-2xl max-h-96 overflow-y-auto whitespace-pre-wrap text-xs text-gray-700 leading-relaxed font-sans">
{isCvDetailsOpen.cv}
</div>
</div>
</div>
)}
{/* Media Selector Modal for Avatar */}
<MediaSelector
isOpen={isAvatarMediaOpen}
onClose={() => setIsAvatarMediaOpen(false)}
onSelect={(url) => {
setFormData(prev => ({ ...prev, avatarUrl: url }));
setIsAvatarMediaOpen(false);
}}
selectedUrl={formData.avatarUrl}
/>
{/* Confirm Delete Modal */}
<ConfirmModal
isOpen={!!deleteTargetId}
onClose={() => setDeleteTargetId(null)}
onConfirm={handleDelete}
title="حذف پزشک"
message="آیا از حذف این پزشک از سامانه مطمئن هستید؟ ویدئوهای مرتبط با این پزشک بدون تغییر باقی خواهند ماند."
/>
</div>
);
}
+61 -4
View File
@@ -9,6 +9,7 @@ interface Video {
id: string;
title: string;
doctor: string;
doctorId?: string;
duration: string;
thumbnail: string;
videoUrl: string;
@@ -16,10 +17,23 @@ interface Video {
viewsCount: number;
isFeatured: boolean;
createdAt: string;
doctorRef?: {
id: string;
name: string;
title?: string;
avatarUrl?: string;
};
}
interface DoctorOption {
id: string;
name: string;
title?: string;
}
export default function Videos() {
const [videos, setVideos] = useState<Video[]>([]);
const [doctorsList, setDoctorsList] = useState<DoctorOption[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [searchTerm, setSearchTerm] = useState('');
const [isModalOpen, setIsModalOpen] = useState(false);
@@ -32,6 +46,7 @@ export default function Videos() {
const [formData, setFormData] = useState({
title: '',
doctor: '',
doctorId: '',
duration: '۰۲:۰۰',
thumbnail: '',
videoUrl: '',
@@ -64,9 +79,27 @@ export default function Videos() {
}
}, [searchTerm]);
const fetchDoctors = useCallback(async () => {
try {
const res = await api.get('/doctors', { params: { limit: 100 } });
const raw = res.data;
const list = Array.isArray(raw?.doctors)
? raw.doctors
: Array.isArray(raw?.data?.doctors)
? raw.data.doctors
: Array.isArray(raw)
? raw
: [];
setDoctorsList(list);
} catch (e) {
console.error('Failed to fetch doctors list:', e);
}
}, []);
useEffect(() => {
fetchVideos();
}, [fetchVideos]);
fetchDoctors();
}, [fetchVideos, fetchDoctors]);
const handleOpenModal = (video?: Video) => {
if (video) {
@@ -74,6 +107,7 @@ export default function Videos() {
setFormData({
title: video.title,
doctor: video.doctor,
doctorId: video.doctorId || '',
duration: video.duration || '۰۲:۰۰',
thumbnail: video.thumbnail || '',
videoUrl: video.videoUrl,
@@ -85,6 +119,7 @@ export default function Videos() {
setFormData({
title: '',
doctor: '',
doctorId: '',
duration: '۰۲:۰۰',
thumbnail: '',
videoUrl: '',
@@ -305,13 +340,35 @@ export default function Videos() {
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div className="space-y-1.5">
<label className="text-xs font-black text-gray-700 block">نام مدرس / پزشک ارائه‌دهنده</label>
<label className="text-xs font-black text-gray-700 block">انتخاب یا نام پزشک / مدرس ارائه‌دهنده</label>
{doctorsList.length > 0 && (
<select
value={formData.doctorId}
onChange={(e) => {
const selectedDocId = e.target.value;
const docObj = doctorsList.find(d => d.id === selectedDocId);
setFormData(prev => ({
...prev,
doctorId: selectedDocId,
doctor: docObj ? docObj.name : prev.doctor,
}));
}}
className="w-full bg-gray-50 border border-gray-200 rounded-xl py-2.5 px-3 text-xs mb-2 focus:outline-none focus:ring-2 focus:ring-purple-500/20 font-bold"
>
<option value="">-- انتخاب از پزشکان ثبت‌شده در سیستم --</option>
{doctorsList.map((doc) => (
<option key={doc.id} value={doc.id}>
{doc.name} {doc.title ? `(${doc.title})` : ''}
</option>
))}
</select>
)}
<input
type="text"
value={formData.doctor}
onChange={(e) => setFormData({ ...formData, doctor: e.target.value })}
placeholder="دکتر کلاوس هنینگ"
className="w-full bg-gray-50 border border-gray-200 rounded-xl py-3 px-4 text-sm focus:outline-none focus:ring-2 focus:ring-purple-500/20 font-bold"
placeholder="نام نمایشی پزشک (مثلاً: دکتر کلاوس هنینگ)"
className="w-full bg-gray-50 border border-gray-200 rounded-xl py-2.5 px-4 text-xs focus:outline-none focus:ring-2 focus:ring-purple-500/20 font-bold"
/>
</div>
@@ -35,9 +35,9 @@ const FinancialSettingsPage = lazy(() => import('../pages/FinancialSettingsPage'
const SystemSettingsPage = lazy(() => import('../pages/SystemSettingsPage'));
const SmsSettingsPage = lazy(() => import('../pages/SmsSettingsPage'));
const SslSettingsPage = lazy(() => import('../pages/SslSettingsPage'));
const Transactions = lazy(() => import('../pages/Transactions'));
const Tickets = lazy(() => import('../pages/Tickets'));
const Reviews = lazy(() => import('../pages/Reviews'));
const DoctorsManager = lazy(() => import('../pages/DoctorsManager'));
export interface AdminRouteConfig {
path: string;
@@ -74,6 +74,7 @@ export const router = createBrowserRouter([
{ path: 'blogs/*', element: <Blogs /> },
{ path: 'wiki/*', element: <Wiki /> },
{ path: 'videos/*', element: <Videos /> },
{ path: 'doctors/*', element: <DoctorsManager /> },
{ path: 'pets/*', element: <Pets /> },
{ path: 'ui-texts/*', element: <UITexts /> },
{ path: 'media/*', element: <Media /> },
+2
View File
@@ -5,6 +5,7 @@ import Hero from "../components/Hero";
import SmartAdvisor from "../components/SmartAdvisor";
import FeaturedProducts from "../components/FeaturedProducts";
import VetGallery from "../components/VetGallery";
import TestimonialsSection from "../components/TestimonialsSection";
import BannerPlacement from "../components/BannerPlacement";
import Link from 'next/link';
import { toPersian } from "../lib/utils";
@@ -62,6 +63,7 @@ export default function HomeClient({ initialData }: HomeClientProps) {
<BannerPlacement banners={banners} position="home_middle" />
<FeaturedProducts />
<VetGallery testimonials={testimonials} />
<TestimonialsSection />
{/* Navigation to Sections */}
<section className="py-12 bg-medical-gray-50 border-y border-medical-gray-100 font-sans">
@@ -55,7 +55,7 @@ export default function SafeImage({
alt={alt}
width={500}
height={500}
unoptimized
loading="lazy"
className={cn(
"transition-all duration-700 w-full h-full",
imgClassName,
@@ -0,0 +1,151 @@
"use client";
import React, { useEffect, useState } from "react";
import { Star, MessageSquareQuote, ShieldCheck, UserCheck } from "lucide-react";
import { motion } from "motion/react";
import SafeImage from "./SafeImage";
import { useSettingsStore } from "../lib/store/settingsStore";
import api, { BASE_DOMAIN } from "../lib/services/api";
export interface Testimonial {
id: string;
authorName: string;
roleTitle?: string;
avatarUrl?: string;
content: string;
rating: number;
isFeatured: boolean;
isActive: boolean;
}
export default function TestimonialsSection() {
const getText = useSettingsStore(state => state.getText);
const [testimonials, setTestimonials] = useState<Testimonial[]>([]);
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
async function loadTestimonials() {
try {
setIsLoading(true);
const res = await api.get('/cms/testimonials');
const raw = res.data;
const list = Array.isArray(raw?.testimonials)
? raw.testimonials
: Array.isArray(raw?.data?.testimonials)
? raw.data.testimonials
: Array.isArray(raw?.data)
? raw.data
: Array.isArray(raw)
? raw
: [];
setTestimonials(list.filter((t: Testimonial) => t.isActive !== false));
} catch (err) {
console.error('Failed to load testimonials:', err);
setTestimonials([]);
} finally {
setIsLoading(false);
}
}
loadTestimonials();
}, []);
if (!isLoading && testimonials.length === 0) {
return null; // Gracefully hide section if no testimonials exist in backend
}
return (
<section className="py-20 bg-medical-gray-50/50 border-t border-medical-gray-100 font-vazir" dir="rtl">
<div className="max-w-7xl mx-auto px-4">
{/* Section Header */}
<div className="text-center max-w-2xl mx-auto mb-16">
<div className="inline-flex items-center gap-2 px-3 py-1 bg-amber-500/10 text-amber-600 rounded-full text-xs font-black uppercase tracking-widest mb-4">
<MessageSquareQuote className="w-4 h-4" />
<span>{getText('testimonials_badge', "گواهی کیفیت و اصالت")}</span>
</div>
<h2 className="text-3xl md:text-4xl font-black text-medical-gray-900 font-lalezar leading-tight">
{getText('testimonials_title', "دیدگاه دامپزشکان و همراهان")} <span className="text-canina-blue">{getText('testimonials_title_highlight', "کنینا")}</span>
</h2>
<p className="text-base text-medical-gray-500 font-medium mt-4">
{getText('testimonials_subtitle', "تجربه متخصصان، کلینیک‌های همکار و سرپرستان حیوانات خانگی از نتایج مکمل‌های آلمانی کنینا")}
</p>
</div>
{/* Testimonials Grid */}
{isLoading ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{[1, 2, 3].map((i) => (
<div key={i} className="bg-white rounded-3xl p-6 border border-medical-gray-100 shadow-xs animate-pulse space-y-4">
<div className="flex items-center gap-3">
<div className="w-12 h-12 rounded-2xl bg-medical-gray-100" />
<div className="space-y-2 flex-1">
<div className="h-4 bg-medical-gray-100 rounded-md w-1/2" />
<div className="h-3 bg-medical-gray-100 rounded-md w-1/3" />
</div>
</div>
<div className="h-16 bg-medical-gray-100 rounded-xl" />
</div>
))}
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{testimonials.map((item, index) => {
const avatar = item.avatarUrl?.startsWith('http')
? item.avatarUrl
: (item.avatarUrl ? `${BASE_DOMAIN}${item.avatarUrl}` : '');
return (
<motion.div
key={item.id || index}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ delay: index * 0.1 }}
className="bg-white rounded-3xl p-6 border border-medical-gray-100 shadow-sm hover:shadow-md transition-all flex flex-col justify-between"
>
<div>
{/* Rating stars */}
<div className="flex items-center gap-1 text-amber-400 mb-4">
{Array.from({ length: item.rating || 5 }).map((_, r) => (
<Star key={r} className="w-4 h-4 fill-amber-400" />
))}
</div>
{/* Content Quote */}
<p className="text-sm text-medical-gray-700 leading-relaxed font-medium mb-6 relative">
«{item.content}»
</p>
</div>
{/* Author footer */}
<div className="flex items-center gap-3 pt-4 border-t border-medical-gray-100">
<div className="w-12 h-12 rounded-2xl bg-medical-gray-50 border border-medical-gray-100 flex items-center justify-center overflow-hidden flex-shrink-0">
{avatar ? (
<SafeImage
src={avatar}
alt={item.authorName}
className="w-full h-full"
imgClassName="object-cover"
/>
) : (
<UserCheck className="w-6 h-6 text-canina-blue/40" />
)}
</div>
<div>
<h4 className="font-extrabold text-sm text-medical-gray-900 leading-tight">
{item.authorName}
</h4>
{item.roleTitle && (
<p className="text-xs text-canina-blue font-bold mt-0.5">
{item.roleTitle}
</p>
)}
</div>
</div>
</motion.div>
);
})}
</div>
)}
</div>
</section>
);
}
+67 -54
View File
@@ -71,31 +71,29 @@ interface DisplayVideoItem {
export default function VetGallery({ testimonials = [] }: { testimonials?: TestimonialItem[] }) {
const getText = useSettingsStore(state => state.getText);
const [apiVideos, setApiVideos] = useState<Video[]>([]);
const [selectedVideo, setSelectedVideo] = useState<DisplayVideoItem | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [selectedVideo, setSelectedVideo] = useState<Video | null>(null);
React.useEffect(() => {
videoService.getVideos({ featured: true, limit: 3 }).then((data) => {
if (data && data.length > 0) {
setApiVideos(data);
}
});
setIsLoading(true);
videoService.getVideos({ featured: true, limit: 3 })
.then((data) => {
if (data && Array.isArray(data)) {
setApiVideos(data);
}
})
.catch((err) => {
console.error('Failed to load featured videos:', err);
setApiVideos([]);
})
.finally(() => {
setIsLoading(false);
});
}, []);
const activeTestimonials = testimonials.filter(t => t.isActive !== false);
const displayItems: DisplayVideoItem[] = apiVideos.length > 0
? apiVideos
: (activeTestimonials.length > 0
? activeTestimonials.map((t, idx) => ({
id: t.id || `t-${idx}`,
title: (t.authorName || t.vetName || '') + (t.roleTitle ? ` — ${t.roleTitle}` : (t.clinicName ? ` — ${t.clinicName}` : '')),
doctor: (t.authorName || t.vetName || '') + (t.roleTitle ? ` (${t.roleTitle})` : ''),
duration: "۰۲:۰۰",
thumbnail: t.avatarUrl || t.imageUrl || "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=400",
videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4",
description: t.content || t.quote || '',
quote: t.content || t.quote || ''
}))
: FALLBACK_VIDEOS);
if (!isLoading && apiVideos.length === 0) {
return null; // Don't render video section if no videos are configured
}
return (
<section className="py-24 bg-white font-vazir" dir="rtl">
@@ -122,42 +120,57 @@ export default function VetGallery({ testimonials = [] }: { testimonials?: Testi
</Link>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{displayItems.map((video, index) => (
<motion.button
key={video.id}
whileHover={{ y: -8 }}
onClick={() => setSelectedVideo(video)}
className="w-full text-right block group cursor-pointer focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none rounded-[2rem] p-2"
>
<div className="relative aspect-video rounded-[2rem] overflow-hidden mb-4 shadow-xl">
<div className="absolute inset-0 bg-medical-gray-900/20 group-hover:bg-transparent transition-colors z-10" />
<SafeImage
src={video.thumbnail || video.imageUrl || '/images/vets/vet1.webp'}
alt={video.title || video.vetName || 'ویدیو دامپزشک'}
className="w-full h-full"
imgClassName="object-cover grayscale-[30%] group-hover:grayscale-0 transition-all duration-700"
/>
<div className="absolute inset-0 flex items-center justify-center z-20">
<div className="w-16 h-16 bg-white/90 backdrop-blur-sm rounded-full flex items-center justify-center text-canina-blue scale-90 group-hover:scale-100 group-hover:bg-white transition-all shadow-xl">
<Play className="w-6 h-6 ml-1" />
{/* Video Grid or Skeleton */}
{isLoading ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{[1, 2, 3].map((i) => (
<div key={i} className="rounded-[2rem] p-2 space-y-4 animate-pulse">
<div className="aspect-video bg-medical-gray-100 rounded-[2rem]" />
<div className="h-6 bg-medical-gray-100 rounded-lg w-3/4" />
<div className="h-4 bg-medical-gray-100 rounded-lg w-1/2" />
</div>
))}
</div>
) : (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{apiVideos.map((video, index) => (
<motion.button
key={video.id}
whileHover={{ y: -8 }}
onClick={() => setSelectedVideo(video)}
className="w-full text-right block group cursor-pointer focus-visible:ring-4 focus-visible:ring-canina-blue/30 focus-visible:outline-none rounded-[2rem] p-2"
>
<div className="relative aspect-video rounded-[2rem] overflow-hidden mb-4 shadow-xl bg-medical-gray-900">
<div className="absolute inset-0 bg-medical-gray-900/20 group-hover:bg-transparent transition-colors z-10" />
<SafeImage
src={video.thumbnail || ''}
alt={video.title || 'ویدیو دامپزشک'}
className="w-full h-full"
imgClassName="object-cover grayscale-[30%] group-hover:grayscale-0 transition-all duration-700"
/>
<div className="absolute inset-0 flex items-center justify-center z-20">
<div className="w-16 h-16 bg-white/90 backdrop-blur-sm rounded-full flex items-center justify-center text-canina-blue scale-90 group-hover:scale-100 group-hover:bg-white transition-all shadow-xl">
<Play className="w-6 h-6 ml-1" />
</div>
</div>
{video.duration && (
<div className="absolute bottom-4 right-4 bg-black/60 backdrop-blur-md text-white px-2 py-1 rounded-lg text-xs font-black z-20 font-vazir flex items-center gap-1 shadow-lg">
<span>⏱️</span>
<span>{video.duration}</span>
</div>
)}
</div>
<div className="absolute bottom-4 right-4 bg-black/60 backdrop-blur-md text-white px-2 py-1 rounded-lg text-xs font-black z-20 font-vazir flex items-center gap-1 shadow-lg">
<span>⏱️</span>
<span>{video.duration || (index === 0 ? '۱:۴۵' : index === 1 ? '۲:۲۰' : '۳:۱۰')}</span>
<h4 className="text-lg font-black text-medical-gray-900 mb-2 group-hover:text-canina-blue transition-colors leading-tight font-vazir">
{video.title}
</h4>
<div className="flex items-center gap-2 text-medical-gray-500 font-bold text-sm font-vazir">
<ShieldCheck className="w-4 h-4 text-canina-blue" />
{video.doctor || 'کادر علمی کنینا'}
</div>
</div>
<h4 className="text-lg font-black text-medical-gray-900 mb-2 group-hover:text-canina-blue transition-colors leading-tight font-vazir">
{video.title || (video.quote ? video.quote.substring(0, 40) + '...' : '')}
</h4>
<div className="flex items-center gap-2 text-medical-gray-500 font-bold text-sm font-vazir">
<ShieldCheck className="w-4 h-4 text-canina-blue" />
{video.doctor || video.vetName}
</div>
</motion.button>
))}
</div>
</motion.button>
))}
</div>
)}
</div>
{/* Custom Feature-Rich Video Player Modal */}
+82 -100
View File
@@ -9,54 +9,6 @@ import { videoService, Video } from "../lib/services/videoService";
import { useRouter } from 'next/navigation';
import VideoModalPlayer from "./VideoModalPlayer";
const FALLBACK_VIDEOS: Video[] = [
{
id: "v1",
title: "نحوه آماده‌سازی کانی‌هیدروکس GAG",
doctor: "دکتر کلاوس هنینگ",
duration: "۰۱:۴۵",
thumbnail: "https://images.unsplash.com/photo-1576091160550-217359f42f8c?auto=format&fit=crop&q=80&w=600",
videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4",
description: "آموزش گام به گام آماده‌سازی پودر Canhydrox GAG برای جذب حداکثری در دستگاه گوارش."
},
{
id: "v2",
title: "اهمیت صدف لب‌سبز برای بازسازی غضروف",
doctor: "دکتر النا اشمیت",
duration: "۰۲:۲۰",
thumbnail: "https://images.unsplash.com/photo-1599443015574-be5fe8a05783?auto=format&fit=crop&q=80&w=600",
videoUrl: "https://www.w3schools.com/html/movie.mp4",
description: "چرا صدف لب‌سبز نیوزیلندی نایاب‌ترین و موثرترین ماده برای بازسازی مفصل است؟"
},
{
id: "v3",
title: "تغذیه هوشمند توله‌سگ‌های نژاد بزرگ",
doctor: "دکتر هلگا فیشر",
duration: "۰۳:۱۰",
thumbnail: "/assets/images/regenerated_image_1779109861747.png",
videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4",
description: "دوز مصرفی مکمل‌های کلسیم در نژادهای بزرگ برای جلوگیری از بدشکلی‌های استخوانی."
},
{
id: "v4",
title: "تاثیر امگا ۳ بر ریزش مو فصلی",
doctor: "دکتر ماری کونیگ",
duration: "۰۵:۱۵",
thumbnail: "https://images.unsplash.com/photo-1516734212186-a967f81ad0d7?auto=format&fit=crop&q=80&w=600",
videoUrl: "https://www.w3schools.com/html/movie.mp4",
description: "چربی‌های ضروری چگونه لایه محافظ پوست را بازسازی می‌کنند."
},
{
id: "v5",
title: "سم‌زدایی گوارشی با اسید هومیک",
doctor: "دکتر ریکاردو کوخ",
duration: "۰۴:۰۰",
thumbnail: "https://images.unsplash.com/photo-1581594693702-fbdc51b2763b?auto=format&fit=crop&q=80&w=600",
videoUrl: "https://www.w3schools.com/html/mov_bbb.mp4",
description: "مکانیزم عمل Moor-Tranke در جذب توکسین‌های روده‌ای."
}
];
export default function VideosPage() {
const router = useRouter();
const [videos, setVideos] = useState<Video[]>([]);
@@ -66,21 +18,27 @@ export default function VideosPage() {
React.useEffect(() => {
setIsLoading(true);
videoService.getVideos({ limit: 100 }).then((data) => {
if (data && data.length > 0) {
setVideos(data);
} else {
setVideos(FALLBACK_VIDEOS);
}
}).catch(() => {
setVideos(FALLBACK_VIDEOS);
}).finally(() => {
setIsLoading(false);
});
videoService.getVideos({ limit: 100 })
.then((data) => {
if (data && Array.isArray(data)) {
setVideos(data);
} else {
setVideos([]);
}
})
.catch((err) => {
console.error('Failed to load videos:', err);
setVideos([]);
})
.finally(() => {
setIsLoading(false);
});
}, []);
const filteredVideos = videos.filter(v =>
v.title.includes(search) || v.doctor.includes(search)
(v.title || '').toLowerCase().includes(search.toLowerCase()) ||
(v.doctor || '').toLowerCase().includes(search.toLowerCase()) ||
(v.description || '').toLowerCase().includes(search.toLowerCase())
);
return (
@@ -118,52 +76,76 @@ export default function VideosPage() {
/>
</div>
{/* Video Grid */}
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
{filteredVideos.map((video, idx) => (
<motion.div
key={video.id}
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: idx * 0.1 }}
className="group cursor-pointer"
onClick={() => {
setSelectedVideo(video);
videoService.incrementViews(video.id);
}}
>
<div className="relative aspect-video rounded-[2.5rem] overflow-hidden mb-6 shadow-2xl border border-white/5">
<SafeImage
src={video.thumbnail}
alt={video.title}
className="w-full h-full"
imgClassName="object-cover group-hover:scale-110 transition-transform duration-700 opacity-60 group-hover:opacity-100"
/>
<div className="absolute inset-0 flex items-center justify-center">
<div className="w-16 h-16 bg-canina-blue rounded-full flex items-center justify-center text-white shadow-2xl group-hover:scale-110 transition-transform">
<PlayCircle className="w-10 h-10" />
</div>
</div>
<div className="absolute bottom-4 right-4 bg-black/60 backdrop-blur-md text-white px-3 py-1 rounded-lg text-[10px] font-black">
{/* Video Grid or Skeleton */}
{isLoading ? (
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
{[1, 2, 3, 4, 5, 6].map((i) => (
<div key={i} className="animate-pulse space-y-4">
<div className="aspect-video bg-white/5 rounded-[2.5rem] border border-white/5" />
<div className="h-6 bg-white/5 rounded-xl w-3/4" />
<div className="h-4 bg-white/5 rounded-xl w-1/2" />
</div>
))}
</div>
) : filteredVideos.length === 0 ? (
<div className="bg-white/5 border border-white/10 rounded-[3rem] p-16 text-center text-white/50">
<PlayCircle className="w-16 h-16 mx-auto mb-4 opacity-30 text-canina-blue" />
<h3 className="text-xl font-bold text-white mb-2">ویدئویی یافت نشد</h3>
<p className="text-sm font-medium">هیچ ویدئویی مطابق با جستجوی شما در آکادمی وجود ندارد.</p>
</div>
) : (
<div className="grid md:grid-cols-2 lg:grid-cols-3 gap-8">
{filteredVideos.map((video, idx) => (
<motion.div
key={video.id}
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: idx * 0.1 }}
className="group cursor-pointer"
onClick={() => {
setSelectedVideo(video);
videoService.incrementViews(video.id);
}}
>
<div className="relative aspect-video rounded-[2.5rem] overflow-hidden mb-6 shadow-2xl border border-white/5 bg-black/40">
<SafeImage
src={video.thumbnail}
alt={video.title}
className="w-full h-full"
imgClassName="object-cover group-hover:scale-110 transition-transform duration-700 opacity-60 group-hover:opacity-100"
/>
<div className="absolute inset-0 flex items-center justify-center">
<div className="w-16 h-16 bg-canina-blue rounded-full flex items-center justify-center text-white shadow-2xl group-hover:scale-110 transition-transform">
<PlayCircle className="w-10 h-10" />
</div>
</div>
{video.duration && (
<div className="absolute bottom-4 right-4 bg-black/60 backdrop-blur-md text-white px-3 py-1 rounded-lg text-[10px] font-black">
{video.duration}
</div>
</div>
)}
</div>
<div className="px-4">
<h3 className="text-xl font-black text-white group-hover:text-canina-blue transition-colors mb-2">{video.title}</h3>
<div className="flex items-center gap-4 text-xs font-bold text-white/40">
<h3 className="text-xl font-black text-white group-hover:text-canina-blue transition-colors mb-2 leading-tight">
{video.title}
</h3>
<div className="flex items-center gap-4 text-xs font-bold text-white/40">
<div className="flex items-center gap-1">
<User className="w-3 h-3" />
{video.doctor || 'کادر علمی کنینا'}
</div>
{video.duration && (
<div className="flex items-center gap-1">
<User className="w-3 h-3" />
{video.doctor || 'کادر علمی کنینا'}
<Clock className="w-3 h-3" />
<span>{video.duration}</span>
</div>
<div className="flex items-center gap-1">
<Clock className="w-3 h-3" />
<span>{video.duration || 'آموزش ویدئویی'}</span>
</div>
</div>
)}
</div>
</div>
</motion.div>
))}
</div>
</motion.div>
))}
</div>
)}
</div>
{/* Custom Feature-Rich Video Player Modal */}
+8
View File
@@ -41,6 +41,14 @@ const nextConfig: NextConfig = {
protocol: 'https',
hostname: 'canina.de',
},
{
protocol: 'https',
hostname: 'images.unsplash.com',
},
{
protocol: 'https',
hostname: 'plus.unsplash.com',
},
{
protocol: 'http',
hostname: 'localhost',