تغییرات کلی در backend و frontend

This commit is contained in:
parsa aghaei committed 2026-07-11 12:30:17 +03:30
1 parent a74f4bda48
commit 3dedc89ee1
41 files changed
+2373 -1957

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
# نقشه جامع اتصال به بک‌بند (Comprehensive Backend Integration Map) 🏗️
این سند حاوی معماری دقیق، فهرست کامل نقاط اتصال (API Endpoints)، کامنت‌های مکان‌نما در کد (TODO Markers)، و تعاریف رسمی تمامی تایپ‌های ورودی (Inputs) و خروجی (Outputs) پلتفرم درمانی و فروشگاهی کانی‌نو ایران است.
این سند حاوی معماری دقیق، فهرست کامل نقاط اتصال (API Endpoints)، کامنت‌های مکان‌نما در کد (TODO Markers)، و تعاریف رسمی تمامی تایپ‌های ورودی (Inputs) و خروجی (Outputs) پلتفرم درمانی و فروشگاهی کانینو ایران است.
---
+3 -3
View File
@@ -1,6 +1,6 @@
# طرح‌واره پایگاه داده کانی‌نو ایران (Canino Iran Database Schema) 🗄️
# طرح‌واره پایگاه داده کانینو ایران (Canino Iran Database Schema) 🗄️
این سند ساختار دقیق جداول، فیلدها، نوع داده‌ها (Datatypes)، روابط بین موجودیت‌ها (ERD Relations) و ایندکس‌های پیشنهادی را برای راه‌اندازی پایگاه داده نهایی سیستم کانی‌نو طراحی و ارائه می‌کند. جهت انعطاف‌پذیری توسعه، پیاده‌سازی هم بر اساس **پایگاه داده رابطه‌ای (PostgreSQL / MySQL)** و هم **پایگاه داده مستندمحور/سندمراقبتی (NoSQL - MongoDB / Firestore)** مدلسازی شده است.
این سند ساختار دقیق جداول، فیلدها، نوع داده‌ها (Datatypes)، روابط بین موجودیت‌ها (ERD Relations) و ایندکس‌های پیشنهادی را برای راه‌اندازی پایگاه داده نهایی سیستم کانینو طراحی و ارائه می‌کند. جهت انعطاف‌پذیری توسعه، پیاده‌سازی هم بر اساس **پایگاه داده رابطه‌ای (PostgreSQL / MySQL)** و هم **پایگاه داده مستندمحور/سندمراقبتی (NoSQL - MongoDB / Firestore)** مدلسازی شده است.
---
@@ -63,7 +63,7 @@ CREATE TABLE wallet_transactions (
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
-- ۴. جدول کاتالوگ محصولات کانی‌نو (products)
-- ۴. جدول کاتالوگ محصولات کانینو (products)
CREATE TABLE products (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
art_no VARCHAR(20) UNIQUE NOT NULL,
+2 -2
View File
@@ -1,7 +1,7 @@
# پلتفرم کانی‌نو ایران (Canino Iran Platform) 🐾
# پلتفرم کانینو ایران (Canino Iran Platform) 🐾
### لندینگ، فروشگاه تخصصی و پرونده سلامت الکترونیک پت (نمایندگی رسمی دارویی Canina Pharma)
پلتفرم **کانی‌نو ایران** یک برنامه جامع تحت وب (SPA/PWA) مجهز به بردهای تعاملی و ابزارهای بهداشتی-دامپزشکی است که با هدف ارتقای سلامت حیوانات خانگی و دسترسی آسان‌تر به مکمل‌های دارویی گرید فوق‌ارگانیک و دارویی کمپانی والای **Canina pharma GmbH آلمان** توسعه یافته است.
پلتفرم **کانینو ایران** یک برنامه جامع تحت وب (SPA/PWA) مجهز به بردهای تعاملی و ابزارهای بهداشتی-دامپزشکی است که با هدف ارتقای سلامت حیوانات خانگی و دسترسی آسان‌تر به مکمل‌های دارویی گرید فوق‌ارگانیک و دارویی کمپانی والای **Canina pharma GmbH آلمان** توسعه یافته است.
---
+85 -39
View File
@@ -1,12 +1,14 @@
import { PrismaClient } from '@prisma/client';
import * as fs from 'fs';
import * as path from 'path';
import * as ts from 'typescript';
import * as vm from 'vm';
const prisma = new PrismaClient();
async function main() {
console.log('Seeding products and blogs...');
console.log('Seeding products, categories, and blogs...');
// 1. Create a default category
const category = await prisma.category.upsert({
where: { slug: 'supplements' },
@@ -20,59 +22,103 @@ async function main() {
}
});
// 2. Read products.json
const productsPath = 'C:/Users/parsa/.gemini/antigravity-ide/brain/951ff86f-dc4e-4670-9a62-78e1f9c8c223/scratch/products.json';
if (fs.existsSync(productsPath)) {
let productsRaw = fs.readFileSync(productsPath, 'utf8');
// Replace old brand names in memory to seed correctly
productsRaw = productsRaw
.replace(/کانینا/g, 'کانینو')
.replace(/کانی‌نا/g, 'کانی‌نو')
.replace(/Canina/g, 'Canino')
.replace(/canina/g, 'canino');
const products = JSON.parse(productsRaw);
// 2. Read products.ts
const productsFilePath = path.join(__dirname, '..', '..', 'frontend', 'application', 'lib', 'data', 'products.ts');
if (fs.existsSync(productsFilePath)) {
const fileContent = fs.readFileSync(productsFilePath, 'utf-8');
const jsCode = ts.transpile(fileContent, {
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2018,
});
const context = { exports: {} };
vm.createContext(context);
vm.runInContext(jsCode, context);
const PRODUCTS = (context.exports as any).PRODUCTS;
if (!PRODUCTS || !Array.isArray(PRODUCTS)) {
console.error('Could not load PRODUCTS from frontend/application/lib/data/products.ts');
process.exit(1);
}
let count = 0;
for (const p of products) {
// Parse price "1,550,000 T"
let price = 0;
if (p.price) {
price = parseInt(p.price.replace(/,/g, '').replace(' T', ''));
}
const artNo = p.article_number || `ART-${count}`;
const slug = (p.product_name_en || p.product_name_fa || `product-${count}`).replace(/\s+/g, '-').toLowerCase().replace(/[^a-z0-9-]/g, '');
const priceVal = price || 0;
const imageUrl = '/placeholder.png'; // Fallback
await prisma.product.upsert({
for (const p of PRODUCTS) {
const artNo = p.artNo || `ART-${count}`;
// Replace brand names in string fields
const cleanName = (p.name || '').replace(/کانینا/g, 'کانینو').replace(/کانی‌نا/g, 'کانینو').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
const cleanScientificTagline = (p.scientificTagline || '').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
const cleanDescription = (p.description || '').replace(/کانینا/g, 'کانینو').replace(/کانی‌نا/g, 'کانینو').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
const cleanShortDesc = (p.shortDescription || '').replace(/کانینا/g, 'کانینو').replace(/کانی‌نا/g, 'کانینو').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
const cleanPriceDisplay = (p.price || '0 T').replace(/کانینا/g, 'کانینو').replace(/کانی‌نا/g, 'کانینو').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
const slug = (p.slug || p.id || `product-${count}`).replace(/\s+/g, '-').toLowerCase().replace(/[^a-z0-9-]/g, '');
const product = await prisma.product.upsert({
where: { artNo: artNo },
update: {
categoryId: category.id,
categorySlug: category.slug,
slug: slug,
name: cleanName,
scientificTagline: cleanScientificTagline,
description: cleanDescription,
shortDescription: cleanShortDesc,
priceValue: p.priceValue || 0,
priceDisplay: cleanPriceDisplay,
unit: p.unit || 'g',
packageSize: p.packageSize || 100,
dosageLogic: p.dosage_logic || '',
suitableFor: p.suitableFor || 'هر دو',
imageUrl: p.image || '/placeholder.png',
},
create: {
artNo: artNo,
slug: slug,
name: p.product_name_fa || p.product_name_en || 'بدون نام',
scientificTagline: p.product_name_en || null,
description: p.description || '',
name: cleanName,
scientificTagline: cleanScientificTagline,
description: cleanDescription,
shortDescription: cleanShortDesc,
categoryId: category.id,
categorySlug: category.slug,
priceValue: priceVal,
priceDisplay: p.price || '0 T',
unit: p.volume_weight?.includes('ml') ? 'ml' : 'g',
packageSize: parseFloat(p.volume_weight || '100') || 100,
suitableFor: 'هر دو', // Default
imageUrl: imageUrl,
priceValue: p.priceValue || 0,
priceDisplay: cleanPriceDisplay,
unit: p.unit || 'g',
packageSize: p.packageSize || 100,
dosageLogic: p.dosage_logic || '',
suitableFor: p.suitableFor || 'هر دو',
imageUrl: p.image || '/placeholder.png',
}
});
// Clear existing ingredients/symptoms and insert new ones
await prisma.productIngredient.deleteMany({ where: { productId: product.id } });
if (p.main_ingredients) {
for (const ing of p.main_ingredients) {
const cleanIng = ing.replace(/کانینا/g, 'کانینو').replace(/کانی‌نا/g, 'کانینو').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
await prisma.productIngredient.create({
data: { productId: product.id, ingredient: cleanIng }
});
}
}
await prisma.productSymptom.deleteMany({ where: { productId: product.id } });
if (p.symptoms) {
for (const sym of p.symptoms) {
const cleanSym = sym.replace(/کانینا/g, 'کانینو').replace(/کانی‌نا/g, 'کانینو').replace(/Canina/g, 'Canino').replace(/canina/g, 'canino');
await prisma.productSymptom.create({
data: { productId: product.id, symptom: cleanSym }
});
}
}
count++;
}
console.log(`Seeded ${count} products.`);
} else {
console.log('products.json not found at', productsPath);
console.log('products.ts not found at', productsFilePath);
}
// Create admin user for blogs
@@ -96,14 +142,14 @@ async function main() {
title: 'راهنمای جامع تغذیه سگ‌های بالغ',
slug: 'adult-dog-nutrition-guide',
content: 'محتوای کامل مقاله در مورد تغذیه سگ‌های بالغ...',
authorId: '12345678-1234-1234-1234-123456789012', // Admin UUID
authorId: adminId,
isPublished: true,
},
{
title: 'چرا مکمل‌های کانینو؟',
slug: 'why-canino-supplements',
content: 'محتوای کامل مقاله در مورد محصولات کانینو...',
authorId: '12345678-1234-1234-1234-123456789012',
authorId: adminId,
isPublished: true,
}
];
+1 -1
View File
@@ -132,7 +132,7 @@ async function main() {
// 2. Seed Scientific Terms
console.log('Seeding Scientific Terms...');
const termsFilePath = path.join(__dirname, '..', '..', 'src', 'data', 'scientificTerms.ts');
const termsFilePath = path.join(__dirname, '..', '..', 'frontend', 'application', 'lib', 'data', 'scientificTerms.ts');
if (fs.existsSync(termsFilePath)) {
const termsContent = fs.readFileSync(termsFilePath, 'utf-8');
const termsJsCode = ts.transpile(termsContent, {
+2 -1
View File
@@ -14,9 +14,10 @@ import { WikiService } from './wiki.service';
import { PetsController } from './pets.controller';
import { PetsService } from './pets.service';
import { PrismaModule } from '../prisma/prisma.module';
import { RedisModule } from '../redis/redis.module';
@Module({
imports: [PrismaModule],
imports: [PrismaModule, RedisModule],
controllers: [AdminController, ReportsController, MediaController, CategoriesController, BlogsController, WikiController, PetsController],
providers: [AdminService, ReportsService, MediaService, CategoriesService, BlogsService, WikiService, PetsService],
})
+17 -3
View File
@@ -1,9 +1,13 @@
import { Injectable, HttpException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { RedisService } from '../redis/redis.service';
@Injectable()
export class AdminService {
constructor(private prisma: PrismaService) {}
constructor(
private prisma: PrismaService,
private redisService: RedisService,
) {}
async getDashboardStats() {
// total revenue
@@ -14,7 +18,7 @@ export class AdminService {
const revenue = orders.reduce((sum, o) => sum + Number(o.totalAmount), 0);
// new orders count (last 24 hours or total depending on logic, let's do total processing)
// new orders count (processing status)
const newOrders = await this.prisma.order.count({
where: { status: 'processing' }
});
@@ -22,11 +26,21 @@ export class AdminService {
// active users count
const users = await this.prisma.user.count();
// Today's request count from Redis counter (set by MetricsController)
const todayKey = `visits:${new Date().toISOString().split('T')[0]}`;
let todayVisits = 0;
try {
const count = await this.redisService.get(todayKey);
todayVisits = count ? parseInt(count, 10) : 0;
} catch {
todayVisits = 0;
}
return {
revenue,
newOrders,
users,
todayVisits: Math.floor(Math.random() * 500) + 100 // mock visits since we don't track analytics
todayVisits
};
}
+7
View File
@@ -3,6 +3,7 @@ import { PrismaModule } from './prisma/prisma.module';
import { ProductsModule } from './products/products.module';
import { UsersModule } from './users/users.module';
import { RedisModule } from './redis/redis.module';
import { RedisService } from './redis/redis.service';
import { AuthModule } from './auth/auth.module';
import { PetsModule } from './pets/pets.module';
import { OrdersModule } from './orders/orders.module';
@@ -40,13 +41,19 @@ import { WikiModule } from './wiki/wiki.module';
provide: APP_GUARD,
useClass: ThrottlerGuard,
},
RedisService,
],
})
export class AppModule implements NestModule {
constructor(private readonly redisService: RedisService) {}
configure(consumer: MiddlewareConsumer) {
consumer
.apply((req: any, res: any, next: () => void) => {
MetricsController.incrementRequestCount();
// Increment daily visits counter in Redis (fire-and-forget)
const todayKey = `visits:${new Date().toISOString().split('T')[0]}`;
this.redisService.incr(todayKey, 86400).catch(() => {}); // TTL = 24h
next();
})
.exclude('metrics')
+6 -3
View File
@@ -53,13 +53,16 @@ describe('AuthService', () => {
});
describe('sendOtp', () => {
it('should generate a 5 digit OTP and save it in Redis', async () => {
it('should generate a 5 digit OTP, save it in Redis, and not expose it in response', async () => {
const result = await service.sendOtp({ phoneNumber: '09123456789' });
expect(result.success).toBe(true);
expect(result.code).toHaveLength(5);
expect(result.message).toBe('کد تایید ارسال شد');
// Code should NOT be in the response (security)
expect((result as any).code).toBeUndefined();
// But it should have been stored in Redis
expect(redis.set).toHaveBeenCalledWith(
'otp:09123456789',
result.code,
expect.stringMatching(/^\d{5}$/),
120,
);
});
+4 -2
View File
@@ -18,11 +18,13 @@ export class AuthService {
const { phoneNumber } = sendOtpDto;
const code = Math.floor(10000 + Math.random() * 90000).toString();
console.log(`[Mock SMS] Sending OTP ${code} to ${phoneNumber}`);
// In production: replace this log with a real SMS provider (e.g. KaveNegar, Melipayamak)
console.log(`[Dev SMS] OTP for ${phoneNumber}: ${code}`);
await this.redisService.set(`otp:${phoneNumber}`, code, 120);
return { success: true, message: 'کد تایید ارسال شد', code };
// SECURITY: Never return the OTP code in the response
return { success: true, message: 'کد تایید ارسال شد' };
}
async verifyOtp(verifyOtpDto: VerifyOtpDto) {
@@ -20,6 +20,11 @@ export class CreateOrderDto {
@IsString()
petId?: string;
@ApiPropertyOptional({ description: 'کد تخفیف (اختیاری)' })
@IsOptional()
@IsString()
couponCode?: string;
@ApiProperty({ description: 'لیست اقلام سفارش', type: [OrderItemDto] })
@IsArray()
@ValidateNested({ each: true })
+32 -2
View File
@@ -1,9 +1,19 @@
import { Controller, Get, Post, Body, Param, UseGuards, Req, HttpStatus, Query } from '@nestjs/common';
import { Controller, Get, Post, Patch, Body, Param, UseGuards, Req, HttpStatus, Query } from '@nestjs/common';
import { OrdersService } from './orders.service';
import { CreateOrderDto } from './dto/create-order.dto';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse, ApiOkResponse, ApiCreatedResponse, ApiBadRequestResponse, ApiNotFoundResponse } from '@nestjs/swagger';
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse, ApiOkResponse, ApiCreatedResponse, ApiBadRequestResponse, ApiNotFoundResponse, ApiBody } from '@nestjs/swagger';
import { PaginationDto } from '../common/dto/pagination.dto';
import { IsString, IsNumber, IsNotEmpty } from 'class-validator';
class ValidateCouponDto {
@IsString()
@IsNotEmpty()
code: string;
@IsNumber()
cartTotal: number;
}
@ApiTags('Orders - مدیریت سفارش‌ها')
@ApiBearerAuth()
@@ -56,6 +66,26 @@ export class OrdersController {
return this.ordersService.create(req.user.id, createOrderDto);
}
@Post('validate-coupon')
@ApiOperation({ summary: 'اعتبارسنجی کد تخفیف و محاسبه میزان تخفیف' })
@ApiOkResponse({
description: 'نتیجه اعتبارسنجی کد تخفیف',
schema: {
example: {
valid: true,
couponId: 'abc-123',
code: 'CANINO10',
type: 'percent',
discountValue: 175000,
message: 'کد تخفیف اعمال شد — ۱۷۵,۰۰۰ تومان تخفیف'
}
}
})
@ApiBadRequestResponse({ description: 'کد تخفیف نامعتبر، منقضی، یا شرایط آن برقرار نیست' })
validateCoupon(@Req() req: any, @Body() body: ValidateCouponDto) {
return this.ordersService.validateCoupon(body.code, body.cartTotal, req.user.id);
}
@Get()
@ApiOperation({ summary: 'لیست سفارش‌های کاربر فعلی' })
@ApiOkResponse({
+85 -1
View File
@@ -2,13 +2,75 @@ import { Injectable, NotFoundException, BadRequestException } from '@nestjs/comm
import { PrismaService } from '../prisma/prisma.service';
import { PaginationDto } from '../common/dto/pagination.dto';
import { CreateOrderDto } from './dto/create-order.dto';
import { Decimal } from '@prisma/client/runtime/library';
@Injectable()
export class OrdersService {
constructor(private prisma: PrismaService) {}
private generateTrackingNumber(): string {
const date = new Date();
const dateStr = `${date.getFullYear()}${String(date.getMonth() + 1).padStart(2, '0')}${String(date.getDate()).padStart(2, '0')}`;
const random = Math.floor(10000 + Math.random() * 90000);
return `CN-${dateStr}-${random}`;
}
async validateCoupon(code: string, cartTotal: number, userId: string) {
const coupon = await this.prisma.coupon.findUnique({
where: { code: code.toUpperCase().trim() },
include: { targets: true },
});
if (!coupon || !coupon.isActive) {
throw new BadRequestException({ message: 'کد تخفیف معتبر نیست یا منقضی شده است', error: 'COUPON_INVALID' });
}
if (coupon.expiresAt && new Date() > coupon.expiresAt) {
throw new BadRequestException({ message: 'کد تخفیف منقضی شده است', error: 'COUPON_EXPIRED' });
}
if (coupon.maxUses && coupon.usedCount >= coupon.maxUses) {
throw new BadRequestException({ message: 'ظرفیت استفاده از این کد تخفیف تکمیل شده است', error: 'COUPON_LIMIT_REACHED' });
}
if (coupon.minCartValue && cartTotal < Number(coupon.minCartValue)) {
throw new BadRequestException({
message: `حداقل مبلغ سبد خرید برای استفاده از این کد ${Number(coupon.minCartValue).toLocaleString('fa-IR')} تومان است`,
error: 'COUPON_MIN_CART'
});
}
// Check user-specific targets
const userTargets = coupon.targets.filter(t => t.targetType === 'USER');
if (userTargets.length > 0 && !userTargets.some(t => t.targetId === userId)) {
throw new BadRequestException({ message: 'این کد تخفیف برای حساب شما معتبر نیست', error: 'COUPON_NOT_FOR_USER' });
}
let discountValue: number;
if (coupon.type === 'percent') {
discountValue = cartTotal * (Number(coupon.value) / 100);
if (coupon.maxCartValue) {
discountValue = Math.min(discountValue, Number(coupon.maxCartValue));
}
} else {
discountValue = Number(coupon.value);
}
discountValue = Math.min(discountValue, cartTotal);
return {
valid: true,
couponId: coupon.id,
code: coupon.code,
type: coupon.type,
discountValue,
message: `کد تخفیف اعمال شد — ${discountValue.toLocaleString('fa-IR')} تومان تخفیف`,
};
}
async create(userId: string, createOrderDto: CreateOrderDto) {
let totalAmount = 0;
let couponId: string | null = null;
const orderItems = [];
for (const item of createOrderDto.items) {
@@ -27,10 +89,32 @@ export class OrdersService {
throw new BadRequestException('سبد خرید خالی است');
}
// Apply coupon if provided
let discountAmount = 0;
if (createOrderDto.couponCode) {
try {
const couponResult = await this.validateCoupon(createOrderDto.couponCode, totalAmount, userId);
discountAmount = couponResult.discountValue;
couponId = couponResult.couponId;
// Increment usedCount
await this.prisma.coupon.update({
where: { id: couponId },
data: { usedCount: { increment: 1 } },
});
} catch {
// Invalid coupon — ignore and proceed without discount
}
}
const finalAmount = Math.max(totalAmount - discountAmount, 0);
const trackingNumber = this.generateTrackingNumber();
return this.prisma.order.create({
data: {
userId,
totalAmount,
couponId,
totalAmount: finalAmount,
trackingNumber,
status: 'processing',
orderItems: {
create: orderItems,
@@ -0,0 +1,24 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsOptional } from 'class-validator';
export class CreateHealthLogDto {
@ApiProperty({ description: 'وضعیت اشتها', example: 'عالی' })
@IsNotEmpty()
@IsString()
appetite: string;
@ApiProperty({ description: 'وضعیت انرژی', example: 'نرمال' })
@IsNotEmpty()
@IsString()
energy: string;
@ApiProperty({ description: 'وضعیت گوارش', example: 'نرمال' })
@IsNotEmpty()
@IsString()
digestion: string;
@ApiPropertyOptional({ description: 'یادداشت یا توضیح اضافی', example: 'امروز فعالیت خوبی داشت.' })
@IsOptional()
@IsString()
note?: string;
}
@@ -0,0 +1,24 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsNotEmpty, IsString, IsOptional } from 'class-validator';
export class CreateReminderDto {
@ApiProperty({ description: 'عنوان یادآور', example: 'قرص کلسیم' })
@IsNotEmpty()
@IsString()
title: string;
@ApiProperty({ description: 'زمان یادآور (مثال: 08:30)', example: '08:30' })
@IsNotEmpty()
@IsString()
time: string;
@ApiProperty({ description: 'دوره زمانی (روزانه / هفتگی)', example: 'روزانه' })
@IsNotEmpty()
@IsString()
frequency: string;
@ApiPropertyOptional({ description: 'شناسه محصول مربوطه', example: 'a1b2c3d4-1234-5678-abcd-ef1234567890' })
@IsOptional()
@IsString()
productId?: string;
}
+33
View File
@@ -2,6 +2,8 @@ import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Req, Http
import { PetsService } from './pets.service';
import { CreatePetDto } from './dto/create-pet.dto';
import { UpdatePetDto } from './dto/update-pet.dto';
import { CreateReminderDto } from './dto/create-reminder.dto';
import { CreateHealthLogDto } from './dto/create-health-log.dto';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse, ApiOkResponse, ApiCreatedResponse, ApiBadRequestResponse, ApiNotFoundResponse } from '@nestjs/swagger';
import { PaginationDto } from '../common/dto/pagination.dto';
@@ -185,4 +187,35 @@ export class PetsController {
remove(@Req() req: any, @Param('id') id: string) {
return this.petsService.remove(id, req.user.id);
}
@Post(':petId/reminders')
@ApiOperation({ summary: 'ثبت یادآور جدید برای پت' })
addReminder(
@Req() req: any,
@Param('petId') petId: string,
@Body() createReminderDto: CreateReminderDto,
) {
return this.petsService.addReminder(req.user.id, petId, createReminderDto);
}
@Post(':petId/reminders/:reminderId/toggle')
@ApiOperation({ summary: 'تغییر وضعیت انجام یادآور در یک تاریخ خاص' })
toggleReminder(
@Req() req: any,
@Param('petId') petId: string,
@Param('reminderId') reminderId: string,
@Body('date') date: string,
) {
return this.petsService.toggleReminder(req.user.id, petId, reminderId, date);
}
@Post(':petId/health-logs')
@ApiOperation({ summary: 'ثبت لاگ سلامت جدید برای پت' })
addHealthLog(
@Req() req: any,
@Param('petId') petId: string,
@Body() createHealthLogDto: CreateHealthLogDto,
) {
return this.petsService.addHealthLog(req.user.id, petId, createHealthLogDto);
}
}
+65
View File
@@ -103,4 +103,69 @@ export class PetsService {
where: { id },
});
}
async addReminder(userId: string, petId: string, data: any) {
await this.findOne(petId, userId);
return this.prisma.reminder.create({
data: {
petId,
productId: data.productId || null,
title: data.title,
time: data.time,
frequency: data.frequency,
},
});
}
async toggleReminder(userId: string, petId: string, reminderId: string, dateStr: string) {
await this.findOne(petId, userId);
const reminder = await this.prisma.reminder.findUnique({
where: { id: reminderId },
});
if (!reminder || reminder.petId !== petId) {
throw new NotFoundException('یادآور یافت نشد');
}
const dateParts = dateStr.split('-');
const completedDate = new Date(Date.UTC(Number(dateParts[0]), Number(dateParts[1]) - 1, Number(dateParts[2])));
const existingCompletion = await this.prisma.reminderCompletion.findUnique({
where: {
reminderId_completedDate: {
reminderId,
completedDate,
},
},
});
if (existingCompletion) {
await this.prisma.reminderCompletion.delete({
where: { id: existingCompletion.id },
});
return { completed: false };
} else {
await this.prisma.reminderCompletion.create({
data: {
reminderId,
completedDate,
},
});
return { completed: true };
}
}
async addHealthLog(userId: string, petId: string, data: any) {
await this.findOne(petId, userId);
return this.prisma.healthLog.create({
data: {
petId,
appetite: data.appetite,
energy: data.energy,
digestion: data.digestion,
note: data.note || null,
loggedDate: new Date(),
},
});
}
}
+9
View File
@@ -31,4 +31,13 @@ export class RedisService implements OnModuleInit, OnModuleDestroy {
async del(key: string): Promise<void> {
await this.client.del(key);
}
async incr(key: string, ttlSeconds?: number): Promise<number> {
const count = await this.client.incr(key);
// Set expiry only on the first increment (count === 1)
if (count === 1 && ttlSeconds) {
await this.client.expire(key, ttlSeconds);
}
return count;
}
}
+27 -1
View File
@@ -1,4 +1,4 @@
import { Controller, Get, Patch, Post, Delete, Body, Param, UseGuards, Req, HttpStatus } from '@nestjs/common';
import { Controller, Get, Patch, Post, Delete, Body, Param, UseGuards, Req, HttpStatus, BadRequestException } from '@nestjs/common';
import { UsersService } from './users.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { ApiTags, ApiBearerAuth, ApiOperation, ApiResponse, ApiOkResponse, ApiCreatedResponse, ApiBadRequestResponse } from '@nestjs/swagger';
@@ -169,4 +169,30 @@ export class UsersController {
setDefaultAddress(@Req() req: any, @Param('addressId') addressId: string) {
return this.usersService.setDefaultAddress(req.user.id, addressId);
}
@UseGuards(JwtAuthGuard)
@Post('wallet/top-up')
@ApiOperation({ summary: 'شارژ کیف پول کاربر' })
@ApiCreatedResponse({
description: 'کیف پول با موفقیت شارژ شد',
schema: {
example: {
id: 'txn-uuid',
userId: 'user-uuid',
amount: '500000.00',
type: 'deposit',
status: 'completed',
description: 'شارژ کیف پول',
createdAt: '2026-07-11T08:00:00.000Z'
}
}
})
@ApiBadRequestResponse({ description: 'مبلغ نامعتبر است' })
async topUpWallet(@Req() req: any, @Body() body: { amount: number }) {
const amount = Number(body.amount);
if (!amount || amount <= 0) {
throw new BadRequestException('مبلغ شارژ باید بزرگتر از صفر باشد');
}
return this.usersService.topUpWallet(req.user.id, amount);
}
}
+40 -2
View File
@@ -9,8 +9,19 @@ export class UsersService {
return this.prisma.user.findUnique({
where: { id },
include: {
pets: true,
pets: {
include: {
medicalConditions: true,
reminders: {
include: {
completions: true
}
},
healthLogs: true,
}
},
orders: {
orderBy: { createdAt: 'desc' },
include: {
orderItems: {
include: { product: true }
@@ -18,7 +29,10 @@ export class UsersService {
}
},
addresses: true,
walletTransactions: true
walletTransactions: {
orderBy: { createdAt: 'desc' },
take: 50
}
}
});
}
@@ -103,6 +117,30 @@ export class UsersService {
});
}
async topUpWallet(userId: string, amount: number) {
if (amount <= 0) {
throw new Error('مبلغ شارژ باید بزرگتر از صفر باشد');
}
const [transaction] = await this.prisma.$transaction([
this.prisma.walletTransaction.create({
data: {
userId,
amount,
type: 'deposit',
status: 'completed',
description: 'شارژ کیف پول',
},
}),
this.prisma.user.update({
where: { id: userId },
data: { walletBalance: { increment: amount } },
}),
]);
return transaction;
}
async findByPhone(phoneNumber: string) {
return this.prisma.user.findUnique({
where: { mobile: phoneNumber },
+1 -1
View File
@@ -10,7 +10,7 @@ services:
POSTGRES_PASSWORD: caninopassword
POSTGRES_DB: caninodb
ports:
- "5432:5432"
- "5433:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
+42 -44
View File
@@ -58,55 +58,53 @@ export default function Sidebar({ isOpen, setIsOpen }: SidebarProps) {
<>
{/* Mobile Backdrop */}
{isOpen && (
<div
<div
className="fixed inset-0 bg-black/50 z-40 lg:hidden backdrop-blur-sm"
onClick={() => setIsOpen(false)}
/>
)}
<aside className={`w-64 bg-white border-l border-gray-200 h-screen fixed lg:sticky top-0 flex flex-col font-vazir shadow-sm z-50 transform transition-transform duration-300 ease-in-out ${
isOpen ? 'translate-x-0' : 'translate-x-full lg:translate-x-0'
}`}>
<div className="h-16 flex items-center justify-center border-b border-gray-200 shrink-0">
<h1 className="text-xl font-black text-purple-600">کانی‌نو | ادمین‌پنل</h1>
</div>
<nav className="flex-1 overflow-y-auto py-4 px-3 space-y-6">
{menuGroups.map((group, idx) => (
<div key={idx}>
<h3 className="px-3 mb-2 text-xs font-black text-gray-400 uppercase tracking-wider">{group.title}</h3>
<div className="space-y-1">
{group.items.map((item) => {
const isActive = location.pathname === item.path || (item.path !== '/' && location.pathname.startsWith(item.path));
const Icon = item.icon;
return (
<Link
key={item.path}
to={item.path}
className={`flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all font-bold ${
isActive
? 'bg-purple-50 text-purple-600'
: 'text-gray-500 hover:bg-gray-50 hover:text-gray-900'
}`}
>
<Icon className="w-5 h-5" />
<span>{item.label}</span>
</Link>
);
})}
</div>
</div>
))}
</nav>
<div className="p-4 border-t border-gray-200">
<button onClick={handleLogout} className="flex items-center gap-3 px-3 py-3 w-full text-red-500 hover:bg-red-50 rounded-xl transition-all font-bold">
<LogOut className="w-5 h-5" />
<span>خروج از حساب</span>
</button>
</div>
</aside>
<aside className={`w-64 bg-white border-l border-gray-200 h-screen fixed lg:sticky top-0 flex flex-col font-vazir shadow-sm z-50 transform transition-transform duration-300 ease-in-out ${isOpen ? 'translate-x-0' : 'translate-x-full lg:translate-x-0'
}`}>
<div className="h-16 flex items-center justify-center border-b border-gray-200 shrink-0">
<h1 className="text-xl font-black text-purple-600">کانینو | ادمین‌پنل</h1>
</div>
<nav className="flex-1 overflow-y-auto py-4 px-3 space-y-6">
{menuGroups.map((group, idx) => (
<div key={idx}>
<h3 className="px-3 mb-2 text-xs font-black text-gray-400 uppercase tracking-wider">{group.title}</h3>
<div className="space-y-1">
{group.items.map((item) => {
const isActive = location.pathname === item.path || (item.path !== '/' && location.pathname.startsWith(item.path));
const Icon = item.icon;
return (
<Link
key={item.path}
to={item.path}
className={`flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all font-bold ${isActive
? 'bg-purple-50 text-purple-600'
: 'text-gray-500 hover:bg-gray-50 hover:text-gray-900'
}`}
>
<Icon className="w-5 h-5" />
<span>{item.label}</span>
</Link>
);
})}
</div>
</div>
))}
</nav>
<div className="p-4 border-t border-gray-200">
<button onClick={handleLogout} className="flex items-center gap-3 px-3 py-3 w-full text-red-500 hover:bg-red-50 rounded-xl transition-all font-bold">
<LogOut className="w-5 h-5" />
<span>خروج از حساب</span>
</button>
</div>
</aside>
</>
);
}
+1 -1
View File
@@ -53,7 +53,7 @@ export default function Dashboard() {
<div className="space-y-6">
<div>
<h2 className="text-2xl font-black text-gray-900">داشبورد</h2>
<p className="text-gray-500 font-medium mt-1">خلاصه‌ای از وضعیت فروشگاه کانی‌نو</p>
<p className="text-gray-500 font-medium mt-1">خلاصه‌ای از وضعیت فروشگاه کانینو</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
+2 -2
View File
@@ -12,7 +12,7 @@ export default function Login() {
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();
setIsLoading(true);
try {
const response = await api.post('/auth/admin-login', { email, password });
if (response.data?.success) {
@@ -36,7 +36,7 @@ export default function Login() {
ورود به پنل مدیریت
</h2>
<p className="mt-2 text-center text-sm text-gray-600 font-bold">
کانی‌نو | لابراتوار تخصصی مکمل‌های درمانی حیوانات
کانینو | لابراتوار تخصصی مکمل‌های درمانی حیوانات
</p>
</div>
+18 -18
View File
@@ -57,7 +57,7 @@ export default function Settings() {
<SettingsIcon className="w-6 h-6 text-purple-600" />
تنظیمات فروشگاه
</h2>
<p className="text-gray-500 font-medium mt-1">مدیریت پارامترهای اصلی و سیستمی کانی‌نو</p>
<p className="text-gray-500 font-medium mt-1">مدیریت پارامترهای اصلی و سیستمی کانینو</p>
</div>
</div>
@@ -65,21 +65,21 @@ export default function Settings() {
<div className="flex justify-center p-12"><Spinner size="lg" className="text-purple-600" /></div>
) : (
<form onSubmit={handleSave} className="grid grid-cols-1 lg:grid-cols-2 gap-6">
{/* Financial Settings */}
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-200 space-y-6">
<h3 className="text-lg font-bold text-gray-900 border-b border-gray-100 pb-4 flex items-center gap-2">
<Truck className="w-5 h-5 text-blue-500" />
تنظیمات مالی و ارسال
</h3>
<div className="space-y-5">
<div>
<label className="block text-sm font-bold text-gray-700 mb-2">هزینه ثابت ارسال (تومان)</label>
<input
type="number"
<input
type="number"
value={settings.SHIPPING_FEE}
onChange={(e) => setSettings({...settings, SHIPPING_FEE: e.target.value})}
onChange={(e) => setSettings({ ...settings, SHIPPING_FEE: e.target.value })}
className="w-full border border-gray-200 rounded-xl p-3 outline-none focus:ring-2 focus:ring-purple-500 font-bold"
dir="ltr"
/>
@@ -87,10 +87,10 @@ export default function Settings() {
<div>
<label className="block text-sm font-bold text-gray-700 mb-2">حداقل مبلغ سفارش (تومان)</label>
<input
type="number"
<input
type="number"
value={settings.MIN_ORDER_AMOUNT}
onChange={(e) => setSettings({...settings, MIN_ORDER_AMOUNT: e.target.value})}
onChange={(e) => setSettings({ ...settings, MIN_ORDER_AMOUNT: e.target.value })}
className="w-full border border-gray-200 rounded-xl p-3 outline-none focus:ring-2 focus:ring-purple-500 font-bold"
dir="ltr"
/>
@@ -105,14 +105,14 @@ export default function Settings() {
<Percent className="w-5 h-5 text-green-500" />
همکاران B2B
</h3>
<div className="space-y-5">
<div>
<label className="block text-sm font-bold text-gray-700 mb-2">تخفیف پیش‌فرض همکار (درصد)</label>
<input
type="number"
<input
type="number"
value={settings.B2B_DISCOUNT_PERCENT}
onChange={(e) => setSettings({...settings, B2B_DISCOUNT_PERCENT: e.target.value})}
onChange={(e) => setSettings({ ...settings, B2B_DISCOUNT_PERCENT: e.target.value })}
className="w-full border border-gray-200 rounded-xl p-3 outline-none focus:ring-2 focus:ring-purple-500 font-bold"
dir="ltr"
max="100"
@@ -129,7 +129,7 @@ export default function Settings() {
<ShieldAlert className="w-5 h-5 text-orange-500" />
وضعیت سیستم
</h3>
<div className="flex items-center justify-between p-4 bg-orange-50 rounded-xl border border-orange-100">
<div className="flex items-center gap-3">
<AlertCircle className="w-6 h-6 text-orange-500" />
@@ -139,11 +139,11 @@ export default function Settings() {
</div>
</div>
<label className="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
<input
type="checkbox"
className="sr-only peer"
checked={settings.MAINTENANCE_MODE === 'true'}
onChange={(e) => setSettings({...settings, MAINTENANCE_MODE: e.target.checked ? 'true' : 'false'})}
onChange={(e) => setSettings({ ...settings, MAINTENANCE_MODE: e.target.checked ? 'true' : 'false' })}
/>
<div className="w-14 h-7 bg-gray-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-6 after:w-6 after:transition-all peer-checked:bg-orange-500"></div>
</label>
@@ -151,7 +151,7 @@ export default function Settings() {
</div>
<div className="lg:col-span-2 flex justify-end">
<button
<button
type="submit"
disabled={isSaving}
className="bg-purple-600 hover:bg-purple-700 text-white font-bold py-3 px-8 rounded-xl transition-colors flex items-center gap-2 shadow-md shadow-purple-200"
+14 -14
View File
@@ -14,7 +14,7 @@ export default function Wiki() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [editingTerm, setEditingTerm] = useState<any>(null);
const [formData, setFormData] = useState({
key: '',
term: '',
@@ -100,11 +100,11 @@ export default function Wiki() {
<div>
<h2 className="text-2xl font-black text-gray-900 flex items-center gap-2">
<BookOpen className="w-6 h-6 text-purple-600" />
دانشنامه کانی‌نو (Wiki)
دانشنامه کانینو (Wiki)
</h2>
<p className="text-gray-500 font-medium mt-1">مدیریت اصطلاحات علمی، مواد تشکیل‌دهنده و خواص درمانی</p>
</div>
<button
<button
onClick={() => openModal()}
className="bg-purple-600 hover:bg-purple-700 text-white px-5 py-2.5 rounded-xl flex items-center gap-2 font-bold transition-all shadow-md shadow-purple-200"
>
@@ -116,9 +116,9 @@ export default function Wiki() {
<div className="bg-white p-4 rounded-2xl shadow-sm border border-gray-200 flex flex-col sm:flex-row gap-4">
<div className="relative flex-1">
<Search className="w-5 h-5 absolute right-4 top-1/2 -translate-y-1/2 text-gray-400" />
<input
type="text"
placeholder="جستجو در اصطلاحات..."
<input
type="text"
placeholder="جستجو در اصطلاحات..."
value={search}
onChange={(e) => { setSearch(e.target.value); setPage(1); }}
className="w-full pl-4 pr-12 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none transition-all"
@@ -178,44 +178,44 @@ export default function Wiki() {
<XCircle className="w-6 h-6" />
</button>
</div>
<div className="p-6 overflow-y-auto flex-1">
<form id="wikiForm" onSubmit={handleSave} className="space-y-6">
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-2">
<label className="text-sm font-bold text-gray-700">شناسه یکتا (Key) *</label>
<input required type="text" value={formData.key} disabled={!!editingTerm} dir="ltr" onChange={(e) => setFormData({...formData, key: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm disabled:bg-gray-100" />
<input required type="text" value={formData.key} disabled={!!editingTerm} dir="ltr" onChange={(e) => setFormData({ ...formData, key: e.target.value })} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none font-mono text-sm disabled:bg-gray-100" />
</div>
<div className="space-y-2">
<label className="text-sm font-bold text-gray-700">نام اصطلاح (Term) *</label>
<input required type="text" value={formData.term} onChange={(e) => setFormData({...formData, term: e.target.value})} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
<input required type="text" value={formData.term} onChange={(e) => setFormData({ ...formData, term: e.target.value })} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none" />
</div>
</div>
<div className="space-y-2">
<label className="text-sm font-bold text-gray-700">توضیح علمی *</label>
<textarea required value={formData.definition} onChange={(e) => setFormData({...formData, definition: e.target.value})} rows={5} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
<textarea required value={formData.definition} onChange={(e) => setFormData({ ...formData, definition: e.target.value })} rows={5} className="w-full px-4 py-3 rounded-xl border border-gray-200 focus:border-purple-500 outline-none"></textarea>
</div>
<div className="space-y-4 border border-gray-200 p-4 rounded-xl bg-gray-50/50">
<h4 className="font-bold text-purple-700 text-sm mb-2">تنظیمات سئو (SEO)</h4>
<div className="space-y-2">
<label className="text-xs font-bold text-gray-700">عنوان متا</label>
<input type="text" value={formData.metaTitle} onChange={(e) => setFormData({...formData, metaTitle: e.target.value})} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
<input type="text" value={formData.metaTitle} onChange={(e) => setFormData({ ...formData, metaTitle: e.target.value })} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
</div>
<div className="space-y-2">
<label className="text-xs font-bold text-gray-700">کلمات کلیدی</label>
<input type="text" value={formData.keywords} onChange={(e) => setFormData({...formData, keywords: e.target.value})} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
<input type="text" value={formData.keywords} onChange={(e) => setFormData({ ...formData, keywords: e.target.value })} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm" />
</div>
<div className="space-y-2">
<label className="text-xs font-bold text-gray-700">توضیحات متا</label>
<textarea rows={2} value={formData.metaDescription} onChange={(e) => setFormData({...formData, metaDescription: e.target.value})} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm"></textarea>
<textarea rows={2} value={formData.metaDescription} onChange={(e) => setFormData({ ...formData, metaDescription: e.target.value })} className="w-full px-3 py-2 rounded-lg border border-gray-200 focus:border-purple-500 outline-none text-sm"></textarea>
</div>
</div>
</form>
</div>
<div className="p-4 border-t border-gray-100 bg-gray-50 flex justify-end gap-3 rounded-b-2xl">
<button type="button" onClick={() => setIsModalOpen(false)} className="px-5 py-2.5 rounded-xl font-bold text-gray-600 hover:bg-gray-200 transition-colors">انصراف</button>
<button type="submit" form="wikiForm" className="bg-purple-600 hover:bg-purple-700 text-white px-8 py-2.5 rounded-xl font-bold transition-all shadow-md shadow-purple-200">ذخیره</button>
+3 -2
View File
@@ -7,11 +7,12 @@ export const metadata: Metadata = {
};
async function getBlogs() {
const apiUrl = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4000';
try {
const res = await fetch('http://localhost:4001/api/blogs', { next: { revalidate: 60 } });
const res = await fetch(`${apiUrl}/api/blogs`, { next: { revalidate: 60 } });
if (!res.ok) throw new Error('Failed to fetch blogs');
const data = await res.json();
return data.map((b: any) => ({
return (data.data || data).map((b: any) => ({
id: b.id,
slug: b.slug,
title: b.title,
+45 -45
View File
@@ -60,7 +60,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
const handleLogin = async (e: React.FormEvent) => {
e.preventDefault();
if (!phoneNumber || !password) return toast.error("شماره موبایل و رمز عبور الزامی است");
setIsLoading(true);
try {
const res = await authService.login(phoneNumber, password);
@@ -171,7 +171,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
className="fixed inset-0 bg-black/60 backdrop-blur-sm z-[60]"
onClick={onClose}
/>
{/* Modal content */}
<motion.div
initial={{ opacity: 0, scale: 0.9, y: 20 }}
@@ -182,10 +182,10 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
>
{/* Top highlight bar */}
<div className="absolute top-0 left-0 w-full h-2 bg-gradient-to-r from-canino-blue to-indigo-500" />
<div className="p-8 relative">
{/* Close Button */}
<button
<button
onClick={onClose}
className="absolute top-6 left-6 p-2 rounded-full hover:bg-medical-gray-50 text-medical-gray-400 hover:text-medical-gray-600 transition-colors"
>
@@ -198,10 +198,10 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
<ShieldCheck className="w-10 h-10 text-canino-blue" />
</div>
<h2 className="text-3xl font-black text-medical-gray-900 mb-2 italic">
ورود به دنیای کانی‌نو
ورود به دنیای کانینو
</h2>
<p className="text-medical-gray-500 text-sm font-bold max-w-[280px]">
{view === "otp"
{view === "otp"
? `کد تایید ارسال شده به شماره ${toPersian(phoneNumber)} را وارد کنید`
: "برای دسترسی به پرونده سلامت و سفارشات وارد شوید"}
</p>
@@ -220,10 +220,10 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
>
<div className="space-y-2">
<label className="text-xs font-bold text-medical-gray-500">شماره موبایل</label>
<input
type="tel"
<input
type="tel"
maxLength={11}
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
value={phoneNumber}
onChange={(e) => setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))}
disabled={isLoading}
@@ -232,26 +232,26 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</div>
<div className="space-y-2">
<label className="text-xs font-bold text-medical-gray-500">رمز عبور</label>
<input
type="password"
placeholder="رمز عبور خود را وارد کنید"
<input
type="password"
placeholder="رمز عبور خود را وارد کنید"
value={password}
onChange={(e) => setPassword(e.target.value)}
disabled={isLoading}
className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-xl py-3 px-4 focus:ring-2 focus:ring-canino-blue/20 outline-none text-left"
/>
</div>
<div className="flex items-center justify-between pt-2">
<button
type="button"
<button
type="button"
onClick={() => setView("otp-phone")}
className="text-xs font-bold text-canino-blue hover:underline"
>
ورود با کد یکبار مصرف (OTP)
</button>
<button
type="button"
<button
type="button"
onClick={() => setView("register")}
className="text-xs font-bold text-canino-blue hover:underline"
>
@@ -259,7 +259,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</button>
</div>
<button
<button
type="submit"
disabled={isLoading || !phoneNumber || !password}
className="w-full py-4 mt-4 bg-canino-blue text-white rounded-xl font-black hover:bg-indigo-700 disabled:opacity-50 transition-all shadow-lg shadow-canino-blue/20 flex items-center justify-center gap-2 cursor-pointer"
@@ -281,8 +281,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
<div className="grid grid-cols-2 gap-3">
<div className="space-y-1">
<label className="text-xs font-bold text-medical-gray-500">نام</label>
<input
type="text"
<input
type="text"
value={firstName}
onChange={(e) => setFirstName(e.target.value)}
disabled={isLoading}
@@ -291,8 +291,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-medical-gray-500">نام خانوادگی</label>
<input
type="text"
<input
type="text"
value={lastName}
onChange={(e) => setLastName(e.target.value)}
disabled={isLoading}
@@ -300,11 +300,11 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
/>
</div>
</div>
<div className="space-y-1">
<label className="text-xs font-bold text-medical-gray-500">شماره موبایل *</label>
<input
type="tel"
<input
type="tel"
maxLength={11}
value={phoneNumber}
onChange={(e) => setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))}
@@ -315,8 +315,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
<div className="space-y-1">
<label className="text-xs font-bold text-medical-gray-500">ایمیل (اختیاری)</label>
<input
type="email"
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
disabled={isLoading}
@@ -326,8 +326,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
<div className="space-y-1">
<label className="text-xs font-bold text-medical-gray-500">رمز عبور *</label>
<input
type="password"
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
disabled={isLoading}
@@ -336,8 +336,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</div>
<div className="flex justify-start pt-1">
<button
type="button"
<button
type="button"
onClick={() => setView("login")}
className="text-xs font-bold text-canino-blue hover:underline"
>
@@ -345,7 +345,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</button>
</div>
<button
<button
type="submit"
disabled={isLoading || !phoneNumber || !password || !firstName || !lastName}
className="w-full py-3 mt-2 bg-canino-blue text-white rounded-xl font-black hover:bg-indigo-700 disabled:opacity-50 transition-all flex items-center justify-center gap-2 cursor-pointer"
@@ -367,8 +367,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
<div className="space-y-2">
<div className="flex justify-between items-center">
<label className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest">شماره موبایل</label>
<button
type="button"
<button
type="button"
onClick={() => setView("login")}
className="text-[10px] font-black text-canino-blue hover:underline"
>
@@ -377,11 +377,11 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</div>
<div className="relative">
<Phone className="absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-medical-gray-400" />
<input
<input
autoFocus
type="tel"
type="tel"
maxLength={11}
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
value={phoneNumber}
onChange={(e) => setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))}
disabled={isLoading}
@@ -390,7 +390,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</div>
</div>
<button
<button
type="submit"
disabled={isLoading || phoneNumber.length < 11}
className="w-full py-5 bg-canino-blue text-white rounded-2xl font-black text-xl hover:bg-indigo-700 disabled:opacity-50 transition-all shadow-xl shadow-canino-blue/20 flex items-center justify-center gap-3 cursor-pointer"
@@ -419,8 +419,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
<div className="space-y-2">
<div className="flex justify-between items-center">
<label className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest">کد تایید پیامکی</label>
<button
type="button"
<button
type="button"
onClick={() => setView("otp-phone")}
className="text-[10px] font-black text-canino-blue flex items-center gap-1 hover:underline"
>
@@ -430,11 +430,11 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
</div>
<div className="relative">
<Key className="absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-medical-gray-400" />
<input
<input
ref={otpInputRef}
type="text"
type="text"
maxLength={5}
placeholder="کد ۵ رقمی"
placeholder="کد ۵ رقمی"
value={otpCode}
onChange={(e) => setOtpCode(e.target.value.replace(/[^0-9]/g, ''))}
disabled={isLoading}
@@ -449,7 +449,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
ارسال مجدد کد پس از {toPersian(countdown)} ثانیه
</span>
) : (
<button
<button
type="button"
onClick={handleResendOtp}
disabled={isLoading}
@@ -461,7 +461,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
)}
</div>
<button
<button
type="submit"
disabled={isLoading || otpCode.length < 5}
className="w-full py-5 bg-canino-blue text-white rounded-2xl font-black text-xl hover:bg-indigo-700 disabled:opacity-50 transition-all shadow-xl shadow-canino-blue/20 flex items-center justify-center gap-3 cursor-pointer"
+298 -298
View File
@@ -6,316 +6,316 @@ import { Product } from "../lib/data/products";
import { productService } from "../lib/services/productService";
export interface BlogPost {
id: string;
slug: string;
title: string;
excerpt: string;
image: string;
date: string;
author: string;
content: string;
id: string;
slug: string;
title: string;
excerpt: string;
image: string;
date: string;
author: string;
content: string;
}
import { useRouter } from 'next/navigation';
export default function BlogPage({ blogs = [] }: { blogs: BlogPost[] }) {
const router = useRouter();
const [selectedPost, setSelectedPost] = React.useState<BlogPost | null>(null);
const [products, setProducts] = React.useState<Product[]>([]);
const router = useRouter();
const [selectedPost, setSelectedPost] = React.useState<BlogPost | null>(null);
const [products, setProducts] = React.useState<Product[]>([]);
React.useEffect(() => {
productService.getProducts().then(data => setProducts(data));
}, []);
React.useEffect(() => {
productService.getProducts().then(data => setProducts(data));
}, []);
if (selectedPost) {
return (
<div className="min-h-screen bg-medical-gray-50 pt-8 pb-20 px-4 font-vazir" dir="rtl">
<div className="max-w-7xl mx-auto">
{/* Breadcrumbs */}
<div className="flex items-center gap-2 text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-10">
<span className="cursor-pointer hover:text-canino-blue" onClick={() => router.push('/')}>خانه</span>
<ChevronRight className="w-2.5 h-2.5" />
<span className="cursor-pointer hover:text-canino-blue" onClick={() => setSelectedPost(null)}>مجله سلامت</span>
<ChevronRight className="w-2.5 h-2.5" />
<span className="text-canino-blue">{selectedPost.title}</span>
</div>
<div className="grid lg:grid-cols-12 gap-12">
<div className="lg:col-span-8">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-[3.5rem] border border-medical-gray-200 shadow-2xl overflow-hidden"
>
<div className="aspect-video w-full overflow-hidden">
<img src={selectedPost.image} alt={selectedPost.title} className="w-full h-full object-cover" />
</div>
<div className="p-12">
<div className="flex items-center gap-4 text-xs font-bold text-canino-blue mb-8">
<div className="bg-canino-blue/10 px-4 py-1.5 rounded-full uppercase tracking-widest">تحقیق بالینی</div>
<div className="flex items-center gap-1">
<Calendar className="w-4 h-4" />
{selectedPost.date}
</div>
</div>
<h1 className="text-4xl lg:text-5xl font-black text-medical-gray-900 mb-10 leading-tight">
{selectedPost.title}
</h1>
<div className="prose prose-lg max-w-none text-medical-gray-600 leading-[2] text-justify space-y-6">
<p className="font-bold text-medical-gray-900 italic text-xl border-r-4 border-canino-blue pr-6 py-2">
{selectedPost.excerpt}
</p>
<div className="whitespace-pre-line">
{selectedPost.content}
</div>
</div>
<div className="mt-16 pt-10 border-t border-medical-gray-100 flex items-center justify-between">
<div className="flex items-center gap-4">
<div className="w-14 h-14 bg-medical-gray-100 rounded-full flex items-center justify-center text-medical-gray-400 border-2 border-white shadow-lg">
<User className="w-8 h-8" />
</div>
<div>
<div className="font-black text-medical-gray-900 text-lg">{selectedPost.author}</div>
<div className="font-bold text-medical-gray-400">تیم تحقیق و توسعه کانی‌نو آلمان</div>
</div>
</div>
<div className="flex gap-4">
<button className="p-4 bg-medical-gray-100 rounded-2xl hover:bg-canino-blue hover:text-white transition-all text-medical-gray-400">
<Sparkles className="w-6 h-6" />
</button>
</div>
</div>
</div>
</motion.div>
</div>
<div className="lg:col-span-4 space-y-10">
<div className="bg-canino-blue rounded-[3rem] p-10 text-white shadow-2xl relative overflow-hidden">
<div className="absolute top-0 left-0 p-8 opacity-10">
<Sparkles className="w-20 h-20" />
</div>
<h4 className="text-2xl font-black mb-6 italic relative z-10">محصولات پیشنهادی</h4>
<div className="space-y-6 relative z-10">
{products.slice(4, 7).map(p => (
<div
key={p.id}
onClick={() => router.push(`/shop/${p.id}`)}
className="bg-white/10 border border-white/20 p-4 rounded-3xl flex items-center gap-4 cursor-pointer hover:bg-white/20 transition-all group"
>
<div className="w-16 h-16 bg-white rounded-2xl p-2 shrink-0 group-hover:scale-110 transition-transform">
<img src={p.image} alt={p.name} className="w-full h-full object-contain" />
</div>
<div>
<div className="text-[10px] font-black opacity-50 uppercase tracking-widest">{p.category}</div>
<div className="text-sm font-black font-vazir text-white">{p.name}</div>
</div>
</div>
))}
</div>
if (selectedPost) {
return (
<div className="min-h-screen bg-medical-gray-50 pt-8 pb-20 px-4 font-vazir" dir="rtl">
<div className="max-w-7xl mx-auto">
{/* Breadcrumbs */}
<div className="flex items-center gap-2 text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-10">
<span className="cursor-pointer hover:text-canino-blue" onClick={() => router.push('/')}>خانه</span>
<ChevronRight className="w-2.5 h-2.5" />
<span className="cursor-pointer hover:text-canino-blue" onClick={() => setSelectedPost(null)}>مجله سلامت</span>
<ChevronRight className="w-2.5 h-2.5" />
<span className="text-canino-blue">{selectedPost.title}</span>
</div>
<div className="bg-white rounded-[3rem] border border-medical-gray-200 p-10 shadow-xl">
<h4 className="text-xl font-black italic mb-6">محبوب‌ترین مقالات</h4>
<div className="space-y-6">
{blogs.map(p => (
<div
key={p.id}
onClick={() => router.push(`/blog/${p.slug}`)}
className="flex items-center gap-4 cursor-pointer group"
>
<div className="w-16 h-16 rounded-2xl overflow-hidden shrink-0">
<img src={p.image} className="w-full h-full object-cover group-hover:scale-110 transition-transform" />
</div>
<div className="text-sm font-black text-medical-gray-900 group-hover:text-canino-blue transition-colors line-clamp-2">
{p.title}
</div>
</div>
<div className="grid lg:grid-cols-12 gap-12">
<div className="lg:col-span-8">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-[3.5rem] border border-medical-gray-200 shadow-2xl overflow-hidden"
>
<div className="aspect-video w-full overflow-hidden">
<img src={selectedPost.image} alt={selectedPost.title} className="w-full h-full object-cover" />
</div>
<div className="p-12">
<div className="flex items-center gap-4 text-xs font-bold text-canino-blue mb-8">
<div className="bg-canino-blue/10 px-4 py-1.5 rounded-full uppercase tracking-widest">تحقیق بالینی</div>
<div className="flex items-center gap-1">
<Calendar className="w-4 h-4" />
{selectedPost.date}
</div>
</div>
<h1 className="text-4xl lg:text-5xl font-black text-medical-gray-900 mb-10 leading-tight">
{selectedPost.title}
</h1>
<div className="prose prose-lg max-w-none text-medical-gray-600 leading-[2] text-justify space-y-6">
<p className="font-bold text-medical-gray-900 italic text-xl border-r-4 border-canino-blue pr-6 py-2">
{selectedPost.excerpt}
</p>
<div className="whitespace-pre-line">
{selectedPost.content}
</div>
</div>
<div className="mt-16 pt-10 border-t border-medical-gray-100 flex items-center justify-between">
<div className="flex items-center gap-4">
<div className="w-14 h-14 bg-medical-gray-100 rounded-full flex items-center justify-center text-medical-gray-400 border-2 border-white shadow-lg">
<User className="w-8 h-8" />
</div>
<div>
<div className="font-black text-medical-gray-900 text-lg">{selectedPost.author}</div>
<div className="font-bold text-medical-gray-400">تیم تحقیق و توسعه کانینو آلمان</div>
</div>
</div>
<div className="flex gap-4">
<button className="p-4 bg-medical-gray-100 rounded-2xl hover:bg-canino-blue hover:text-white transition-all text-medical-gray-400">
<Sparkles className="w-6 h-6" />
</button>
</div>
</div>
</div>
</motion.div>
</div>
<div className="lg:col-span-4 space-y-10">
<div className="bg-canino-blue rounded-[3rem] p-10 text-white shadow-2xl relative overflow-hidden">
<div className="absolute top-0 left-0 p-8 opacity-10">
<Sparkles className="w-20 h-20" />
</div>
<h4 className="text-2xl font-black mb-6 italic relative z-10">محصولات پیشنهادی</h4>
<div className="space-y-6 relative z-10">
{products.slice(4, 7).map(p => (
<div
key={p.id}
onClick={() => router.push(`/shop/${p.id}`)}
className="bg-white/10 border border-white/20 p-4 rounded-3xl flex items-center gap-4 cursor-pointer hover:bg-white/20 transition-all group"
>
<div className="w-16 h-16 bg-white rounded-2xl p-2 shrink-0 group-hover:scale-110 transition-transform">
<img src={p.image} alt={p.name} className="w-full h-full object-contain" />
</div>
<div>
<div className="text-[10px] font-black opacity-50 uppercase tracking-widest">{p.category}</div>
<div className="text-sm font-black font-vazir text-white">{p.name}</div>
</div>
</div>
))}
</div>
</div>
<div className="bg-white rounded-[3rem] border border-medical-gray-200 p-10 shadow-xl">
<h4 className="text-xl font-black italic mb-6">محبوب‌ترین مقالات</h4>
<div className="space-y-6">
{blogs.map(p => (
<div
key={p.id}
onClick={() => router.push(`/blog/${p.slug}`)}
className="flex items-center gap-4 cursor-pointer group"
>
<div className="w-16 h-16 rounded-2xl overflow-hidden shrink-0">
<img src={p.image} className="w-full h-full object-cover group-hover:scale-110 transition-transform" />
</div>
<div className="text-sm font-black text-medical-gray-900 group-hover:text-canino-blue transition-colors line-clamp-2">
{p.title}
</div>
</div>
))}
</div>
</div>
</div>
</div>
</div>
</div>
);
}
return (
<div className="min-h-screen bg-medical-gray-50 pt-8 pb-20 px-4 font-vazir" dir="rtl">
<div className="max-w-7xl mx-auto">
{/* Header */}
<div className="flex flex-col md:flex-row items-center justify-between mb-16 gap-6">
<div className="text-right">
<div className="inline-flex items-center gap-2 px-3 py-1 bg-canino-blue/10 text-canino-blue rounded-full text-[10px] font-black uppercase tracking-widest mb-4">
<BookOpen className="w-3 h-3" />
Canino Science Blog
</div>
<h1 className="text-4xl lg:text-6xl font-black text-medical-gray-900 italic leading-tight">
مجله تخصصی <span className="text-canino-blue">سلامت پت‌ها</span>
</h1>
<p className="text-lg text-medical-gray-500 font-medium mt-4 max-w-xl">
آخرین یافته‌های علمی محققین کانینو آلمان در مورد تغذیه و سلامت پت‌ها.
</p>
</div>
<button
onClick={() => router.push('/')}
className="px-8 py-3 bg-white border border-medical-gray-200 rounded-2xl text-medical-gray-700 shadow-sm flex items-center gap-2 font-black hover:bg-medical-gray-50 transition-all"
>
<ChevronRight className="w-5 h-5" />
بازگشت به خانه
</button>
</div>
{/* Featured Post */}
{blogs.length > 0 && (
<div className="mb-20">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-[3.5rem] overflow-hidden border border-medical-gray-200 shadow-2xl flex flex-col lg:flex-row cursor-pointer group"
onClick={() => router.push(`/blog/${blogs[0].slug}`)}
>
<div className="lg:w-1/2 aspect-video lg:aspect-auto">
<img
src={blogs[0].image}
alt={blogs[0].title}
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
/>
</div>
<div className="lg:w-1/2 p-12 flex flex-col justify-center">
<div className="flex items-center gap-4 text-xs font-bold text-canino-blue mb-6">
<div className="bg-canino-blue/10 px-3 py-1 rounded-full uppercase tracking-widest">تخصصی</div>
<div className="flex items-center gap-1">
<Calendar className="w-3 h-3" />
{blogs[0].date}
</div>
</div>
<h2 className="text-3xl lg:text-4xl font-black text-medical-gray-900 mb-6 leading-tight group-hover:text-canino-blue transition-colors">
{blogs[0].title}
</h2>
<p className="text-lg text-medical-gray-500 mb-8 leading-relaxed italic">
{blogs[0].excerpt}
</p>
<div className="flex items-center justify-between pt-8 border-t border-medical-gray-100">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-medical-gray-100 rounded-full flex items-center justify-center text-medical-gray-400">
<User className="w-6 h-6" />
</div>
<div className="text-sm">
<div className="font-black text-medical-gray-900">{blogs[0].author}</div>
<div className="font-bold text-medical-gray-400">نویسنده کانینو</div>
</div>
</div>
<div className="flex items-center gap-2 text-canino-blue font-black">
ادامه مطلب
<ArrowLeft className="w-5 h-5 group-hover:-translate-x-2 transition-transform" />
</div>
</div>
</div>
</motion.div>
</div>
)}
{/* Post Grid */}
<div className="grid md:grid-cols-2 gap-8">
{blogs.slice(1).map((post, idx) => (
<motion.div
key={post.id}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ delay: idx * 0.1 }}
className="bg-white rounded-[3rem] overflow-hidden border border-medical-gray-200 shadow-xl group hover:shadow-2xl transition-all cursor-pointer"
onClick={() => router.push(`/blog/${post.slug}`)}
>
<div className="aspect-[16/9] overflow-hidden">
<img
src={post.image}
alt={post.title}
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-700"
/>
</div>
<div className="p-8">
<div className="flex items-center gap-4 text-[10px] font-bold text-canino-blue mb-4">
<div className="flex items-center gap-1">
<Calendar className="w-3 h-3" />
{post.date}
</div>
</div>
<h3 className="text-xl font-black text-medical-gray-900 mb-4 group-hover:text-canino-blue transition-colors">
{post.title}
</h3>
<p className="text-sm text-medical-gray-500 mb-8 leading-relaxed line-clamp-2">
{post.excerpt}
</p>
<div className="flex items-center gap-2 text-medical-gray-900 font-bold group">
مطالعه مقاله
<ArrowLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" />
</div>
</div>
</motion.div>
))}
{/* Newsletter / CTA Box */}
<div className="bg-canino-blue rounded-[3rem] p-10 text-white relative overflow-hidden flex flex-col justify-center">
<div className="absolute top-0 right-0 p-8 opacity-20">
<Sparkles className="w-24 h-24" />
</div>
<h3 className="text-3xl font-black mb-4 italic">مشترک خبرنامه علمی شوید</h3>
<p className="text-white/80 mb-8 font-medium leading-relaxed">
ماهانه یک ایمیل حاوی مهم‌ترین نکات سلامت پت‌ها و کدهای تخفیف اختصاصی دریافت کنید.
</p>
<div className="flex gap-2">
<input
type="email"
placeholder="آدرس ایمیل شما"
className="flex-1 bg-white/10 border border-white/20 rounded-xl px-4 py-3 outline-none focus:bg-white/20 placeholder:text-white/40"
/>
<button className="bg-white text-canino-blue px-6 py-3 rounded-xl font-black">
عضویت
</button>
</div>
</div>
</div>
{/* Synergy Products Cross-sell */}
<section className="mt-32 p-12 bg-canino-blue rounded-[4rem] text-white overflow-hidden relative shadow-2xl">
<div className="absolute inset-0 opacity-20 pointer-events-none">
<div className="grid grid-cols-6 h-full w-full">
{Array.from({ length: 36 }).map((_, i) => (
<div key={i} className="border border-white/20" />
))}
</div>
</div>
</div>
</div>
</div>
</div>
);
}
return (
<div className="min-h-screen bg-medical-gray-50 pt-8 pb-20 px-4 font-vazir" dir="rtl">
<div className="max-w-7xl mx-auto">
{/* Header */}
<div className="flex flex-col md:flex-row items-center justify-between mb-16 gap-6">
<div className="text-right">
<div className="inline-flex items-center gap-2 px-3 py-1 bg-canino-blue/10 text-canino-blue rounded-full text-[10px] font-black uppercase tracking-widest mb-4">
<BookOpen className="w-3 h-3" />
Canino Science Blog
</div>
<h1 className="text-4xl lg:text-6xl font-black text-medical-gray-900 italic leading-tight">
مجله تخصصی <span className="text-canino-blue">سلامت پت‌ها</span>
</h1>
<p className="text-lg text-medical-gray-500 font-medium mt-4 max-w-xl">
آخرین یافته‌های علمی محققین کانی‌نو آلمان در مورد تغذیه و سلامت پت‌ها.
</p>
</div>
<button
onClick={() => router.push('/')}
className="px-8 py-3 bg-white border border-medical-gray-200 rounded-2xl text-medical-gray-700 shadow-sm flex items-center gap-2 font-black hover:bg-medical-gray-50 transition-all"
>
<ChevronRight className="w-5 h-5" />
بازگشت به خانه
</button>
</div>
{/* Featured Post */}
{blogs.length > 0 && (
<div className="mb-20">
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
className="bg-white rounded-[3.5rem] overflow-hidden border border-medical-gray-200 shadow-2xl flex flex-col lg:flex-row cursor-pointer group"
onClick={() => router.push(`/blog/${blogs[0].slug}`)}
>
<div className="lg:w-1/2 aspect-video lg:aspect-auto">
<img
src={blogs[0].image}
alt={blogs[0].title}
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-700"
/>
</div>
<div className="lg:w-1/2 p-12 flex flex-col justify-center">
<div className="flex items-center gap-4 text-xs font-bold text-canino-blue mb-6">
<div className="bg-canino-blue/10 px-3 py-1 rounded-full uppercase tracking-widest">تخصصی</div>
<div className="flex items-center gap-1">
<Calendar className="w-3 h-3" />
{blogs[0].date}
</div>
</div>
<h2 className="text-3xl lg:text-4xl font-black text-medical-gray-900 mb-6 leading-tight group-hover:text-canino-blue transition-colors">
{blogs[0].title}
</h2>
<p className="text-lg text-medical-gray-500 mb-8 leading-relaxed italic">
{blogs[0].excerpt}
</p>
<div className="flex items-center justify-between pt-8 border-t border-medical-gray-100">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-medical-gray-100 rounded-full flex items-center justify-center text-medical-gray-400">
<User className="w-6 h-6" />
</div>
<div className="text-sm">
<div className="font-black text-medical-gray-900">{blogs[0].author}</div>
<div className="font-bold text-medical-gray-400">نویسنده کانینو</div>
</div>
</div>
<div className="flex items-center gap-2 text-canino-blue font-black">
ادامه مطلب
<ArrowLeft className="w-5 h-5 group-hover:-translate-x-2 transition-transform" />
</div>
</div>
</div>
</motion.div>
</div>
)}
{/* Post Grid */}
<div className="grid md:grid-cols-2 gap-8">
{blogs.slice(1).map((post, idx) => (
<motion.div
key={post.id}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
transition={{ delay: idx * 0.1 }}
className="bg-white rounded-[3rem] overflow-hidden border border-medical-gray-200 shadow-xl group hover:shadow-2xl transition-all cursor-pointer"
onClick={() => router.push(`/blog/${post.slug}`)}
>
<div className="aspect-[16/9] overflow-hidden">
<img
src={post.image}
alt={post.title}
className="w-full h-full object-cover group-hover:scale-110 transition-transform duration-700"
/>
</div>
<div className="p-8">
<div className="flex items-center gap-4 text-[10px] font-bold text-canino-blue mb-4">
<div className="flex items-center gap-1">
<Calendar className="w-3 h-3" />
{post.date}
</div>
</div>
<h3 className="text-xl font-black text-medical-gray-900 mb-4 group-hover:text-canino-blue transition-colors">
{post.title}
</h3>
<p className="text-sm text-medical-gray-500 mb-8 leading-relaxed line-clamp-2">
{post.excerpt}
</p>
<div className="flex items-center gap-2 text-medical-gray-900 font-bold group">
مطالعه مقاله
<ArrowLeft className="w-4 h-4 group-hover:-translate-x-1 transition-transform" />
</div>
</div>
</motion.div>
))}
{/* Newsletter / CTA Box */}
<div className="bg-canino-blue rounded-[3rem] p-10 text-white relative overflow-hidden flex flex-col justify-center">
<div className="absolute top-0 right-0 p-8 opacity-20">
<Sparkles className="w-24 h-24" />
</div>
<h3 className="text-3xl font-black mb-4 italic">مشترک خبرنامه علمی شوید</h3>
<p className="text-white/80 mb-8 font-medium leading-relaxed">
ماهانه یک ایمیل حاوی مهم‌ترین نکات سلامت پت‌ها و کدهای تخفیف اختصاصی دریافت کنید.
</p>
<div className="flex gap-2">
<input
type="email"
placeholder="آدرس ایمیل شما"
className="flex-1 bg-white/10 border border-white/20 rounded-xl px-4 py-3 outline-none focus:bg-white/20 placeholder:text-white/40"
/>
<button className="bg-white text-canino-blue px-6 py-3 rounded-xl font-black">
عضویت
</button>
</div>
</div>
</div>
{/* Synergy Products Cross-sell */}
<section className="mt-32 p-12 bg-canino-blue rounded-[4rem] text-white overflow-hidden relative shadow-2xl">
<div className="absolute inset-0 opacity-20 pointer-events-none">
<div className="grid grid-cols-6 h-full w-full">
{Array.from({length: 36}).map((_, i) => (
<div key={i} className="border border-white/20" />
))}
</div>
</div>
<div className="relative z-10 flex flex-col lg:flex-row items-center gap-12">
<div className="flex-1">
<h3 className="text-3xl lg:text-4xl font-black italic mb-6">علم آلمانی در خدمت سلامت پت شما</h3>
<p className="text-white/80 mb-8 leading-relaxed max-w-xl">
تمامی مقالات این وبلاگ بر اساس کاتالوگ‌های رسمی و نتایج آزمایشگاهی کمپانی کانی‌نو آلمان تدوین شده است.
</p>
<button
onClick={() => router.push('/shop')}
className="bg-white text-canino-blue px-8 py-4 rounded-2xl font-black hover:scale-105 transition-transform"
>
مشاهده محصولات تخصصی
</button>
<div className="relative z-10 flex flex-col lg:flex-row items-center gap-12">
<div className="flex-1">
<h3 className="text-3xl lg:text-4xl font-black italic mb-6">علم آلمانی در خدمت سلامت پت شما</h3>
<p className="text-white/80 mb-8 leading-relaxed max-w-xl">
تمامی مقالات این وبلاگ بر اساس کاتالوگ‌های رسمی و نتایج آزمایشگاهی کمپانی کانینو آلمان تدوین شده است.
</p>
<button
onClick={() => router.push('/shop')}
className="bg-white text-canino-blue px-8 py-4 rounded-2xl font-black hover:scale-105 transition-transform"
>
مشاهده محصولات تخصصی
</button>
</div>
<div className="grid grid-cols-2 gap-4 flex-shrink-0">
{products.slice(0, 2).map((p) => (
<div
key={p.id}
onClick={() => router.push(`/shop/${p.id}`)}
className="bg-white/10 border border-white/20 p-6 rounded-3xl cursor-pointer hover:bg-white/20 transition-all text-center group"
>
<img src={p.image} alt={p.name} className="w-20 h-20 mx-auto mb-4 object-contain filter brightness-0 invert group-hover:scale-110 transition-transform" />
<h5 className="text-[10px] font-black">{p.name}</h5>
</div>
))}
</div>
</div>
<div className="grid grid-cols-2 gap-4 flex-shrink-0">
{products.slice(0, 2).map((p) => (
<div
key={p.id}
onClick={() => router.push(`/shop/${p.id}`)}
className="bg-white/10 border border-white/20 p-6 rounded-3xl cursor-pointer hover:bg-white/20 transition-all text-center group"
>
<img src={p.image} alt={p.name} className="w-20 h-20 mx-auto mb-4 object-contain filter brightness-0 invert group-hover:scale-110 transition-transform" />
<h5 className="text-[10px] font-black">{p.name}</h5>
</div>
))}
</div>
</div>
</section>
</section>
</div>
</div>
</div>
);
);
}
+302 -303
View File
@@ -37,16 +37,16 @@ const MENU_ITEMS = [
}
];
export default function Header({
onNavigate,
onShopNavigate,
export default function Header({
onNavigate,
onShopNavigate,
currentView,
onCartOpen,
onSearch,
onB2BOpen
}: {
onNavigate: (v: any) => void,
onShopNavigate: (c?: string, s?: string) => void,
}: {
onNavigate: (v: any) => void,
onShopNavigate: (c?: string, s?: string) => void,
currentView: string,
onCartOpen: () => void,
onSearch: (q: string) => void,
@@ -59,9 +59,9 @@ export default function Header({
const [searchQuery, setSearchQuery] = useState("");
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const [isMobileSolutionsOpen, setIsMobileSolutionsOpen] = useState(false);
const petMenuRef = useRef<HTMLDivElement>(null);
const { getTotalItems } = useCartStore();
const { pets, activePetId, setActivePet, getActivePet } = usePetStore();
const { role, isLoggedIn, logout, profile } = useUserStore();
@@ -88,175 +88,175 @@ export default function Header({
return (
<>
<AuthModal isOpen={isAuthModalOpen} onClose={() => setIsAuthModalOpen(false)} />
<div className="bg-canino-gold text-canino-dark text-xs font-black py-2.5 text-center font-vazir tracking-wider flex items-center justify-center gap-2">
<span>🚚</span>
<span>ارسال رایگان برای سفارش‌های بالای ۱۵۰ هزار تومان</span>
</div>
<header className="sticky top-0 z-50 bg-white/95 backdrop-blur-md border-b border-medical-gray-100 shadow-sm">
<div className="max-w-7xl mx-auto h-24 flex items-center justify-between gap-4 px-4 sm:px-6 lg:px-8" dir="rtl">
<div className="flex items-center gap-2">
{/* Mobile Menu Toggle */}
<button
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
className="lg:hidden p-2 rounded-xl text-medical-gray-600 hover:bg-medical-gray-50 transition-all"
aria-label="منو"
>
{isMobileMenuOpen ? <X className="w-6 h-6" /> : <Menu className="w-6 h-6" />}
</button>
<AuthModal isOpen={isAuthModalOpen} onClose={() => setIsAuthModalOpen(false)} />
{/* Logo Section */}
<div
className="flex-shrink-0 flex items-center gap-3 cursor-pointer group"
onClick={() => {
onNavigate("home");
setIsMobileMenuOpen(false);
}}
>
<div className="w-12 h-12 bg-canino-blue rounded-2xl flex items-center justify-center text-white font-bold text-2xl group-hover:bg-medical-gray-900 transition-all shadow-xl shadow-canino-blue/20 italic">C</div>
<div className="flex flex-col">
<span className="text-canino-blue font-black text-2xl tracking-tighter leading-none italic font-inter">Canino <span className="text-sm not-italic font-medium border-l-2 border-medical-gray-100 pl-2 ml-2 font-vazir">ایران</span></span>
<span className="text-[10px] text-medical-gray-400 font-bold uppercase tracking-widest leading-none mt-1.5 font-vazir">نماینده رسمی Canina Pharma GmbH آلمان</span>
<div className="bg-canino-gold text-canino-dark text-xs font-black py-2.5 text-center font-vazir tracking-wider flex items-center justify-center gap-2">
<span>🚚</span>
<span>ارسال رایگان برای سفارش‌های بالای ۱۵۰ هزار تومان</span>
</div>
<header className="sticky top-0 z-50 bg-white/95 backdrop-blur-md border-b border-medical-gray-100 shadow-sm">
<div className="max-w-7xl mx-auto h-24 flex items-center justify-between gap-4 px-4 sm:px-6 lg:px-8" dir="rtl">
<div className="flex items-center gap-2">
{/* Mobile Menu Toggle */}
<button
onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
className="lg:hidden p-2 rounded-xl text-medical-gray-600 hover:bg-medical-gray-50 transition-all"
aria-label="منو"
>
{isMobileMenuOpen ? <X className="w-6 h-6" /> : <Menu className="w-6 h-6" />}
</button>
{/* Logo Section */}
<div
className="flex-shrink-0 flex items-center gap-3 cursor-pointer group"
onClick={() => {
onNavigate("home");
setIsMobileMenuOpen(false);
}}
>
<div className="w-12 h-12 bg-canino-blue rounded-2xl flex items-center justify-center text-white font-bold text-2xl group-hover:bg-medical-gray-900 transition-all shadow-xl shadow-canino-blue/20 italic">C</div>
<div className="flex flex-col">
<span className="text-canino-blue font-black text-2xl tracking-tighter leading-none italic font-inter">Canino <span className="text-sm not-italic font-medium border-l-2 border-medical-gray-100 pl-2 ml-2 font-vazir">ایران</span></span>
<span className="text-[10px] text-medical-gray-400 font-bold uppercase tracking-widest leading-none mt-1.5 font-vazir">نماینده رسمی Canina Pharma GmbH آلمان</span>
</div>
</div>
</div>
</div>
{/* Navigation Items */}
<nav className="hidden lg:flex items-center gap-1 flex-grow justify-center h-full">
<div
className="relative h-full flex items-center group"
onMouseEnter={() => setIsMegaMenuOpen(true)}
onMouseLeave={() => setIsMegaMenuOpen(false)}
>
<button className={`flex items-center justify-center gap-1.5 px-4 py-3 rounded-xl text-sm font-black transition-all whitespace-nowrap focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none min-h-[48px] ${isMegaMenuOpen ? 'bg-medical-gray-50 text-canino-blue' : 'text-medical-gray-600 hover:bg-medical-gray-50 hover:text-canino-blue'} font-vazir`}>
راهکارهای درمانی
<ChevronDown className={`w-4 h-4 transition-transform duration-300 ${isMegaMenuOpen ? 'rotate-180' : ''}`} />
</button>
{/* Navigation Items */}
<nav className="hidden lg:flex items-center gap-1 flex-grow justify-center h-full">
<div
className="relative h-full flex items-center group"
onMouseEnter={() => setIsMegaMenuOpen(true)}
onMouseLeave={() => setIsMegaMenuOpen(false)}
>
<button className={`flex items-center justify-center gap-1.5 px-4 py-3 rounded-xl text-sm font-black transition-all whitespace-nowrap focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none min-h-[48px] ${isMegaMenuOpen ? 'bg-medical-gray-50 text-canino-blue' : 'text-medical-gray-600 hover:bg-medical-gray-50 hover:text-canino-blue'} font-vazir`}>
راهکارهای درمانی
<ChevronDown className={`w-4 h-4 transition-transform duration-300 ${isMegaMenuOpen ? 'rotate-180' : ''}`} />
</button>
<AnimatePresence>
{isMegaMenuOpen && (
<motion.div
initial={{ opacity: 0, y: 15, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 15, scale: 0.98 }}
className="absolute top-[80%] right-0 w-[640px] bg-white border border-medical-gray-100 shadow-2xl rounded-[2.5rem] p-10 grid grid-cols-2 gap-10 z-50 pointer-events-auto"
>
{MENU_ITEMS.map((item, idx) => (
<div
key={idx}
<AnimatePresence>
{isMegaMenuOpen && (
<motion.div
initial={{ opacity: 0, y: 15, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: 15, scale: 0.98 }}
className="absolute top-[80%] right-0 w-[640px] bg-white border border-medical-gray-100 shadow-2xl rounded-[2.5rem] p-10 grid grid-cols-2 gap-10 z-50 pointer-events-auto"
>
{MENU_ITEMS.map((item, idx) => (
<div
key={idx}
className="group/item cursor-pointer"
onClick={() => {
onShopNavigate(item.id);
setIsMegaMenuOpen(false);
onShopNavigate(item.id);
setIsMegaMenuOpen(false);
}}
>
<div className="flex items-center gap-4 mb-4">
<div className="p-3 bg-medical-gray-50 rounded-2xl text-canino-blue group-hover/item:bg-canino-blue group-hover/item:text-white transition-all shadow-sm">
{item.icon}
>
<div className="flex items-center gap-4 mb-4">
<div className="p-3 bg-medical-gray-50 rounded-2xl text-canino-blue group-hover/item:bg-canino-blue group-hover/item:text-white transition-all shadow-sm">
{item.icon}
</div>
<h4 className="font-black text-medical-gray-900 text-sm font-vazir whitespace-nowrap">{item.title}</h4>
</div>
<h4 className="font-black text-medical-gray-900 text-sm font-vazir whitespace-nowrap">{item.title}</h4>
<ul className="space-y-2.5 border-r-2 border-medical-gray-50 pr-4">
{item.solutions.map((sol, sIdx) => (
<li
key={sIdx}
className="text-[12px] text-medical-gray-400 hover:text-canino-blue hover:translate-x-[-4px] transition-all font-bold cursor-pointer font-vazir whitespace-nowrap"
onClick={(e) => {
e.stopPropagation();
onShopNavigate(item.id, sol);
setIsMegaMenuOpen(false);
}}
>
{sol}
</li>
))}
</ul>
</div>
<ul className="space-y-2.5 border-r-2 border-medical-gray-50 pr-4">
{item.solutions.map((sol, sIdx) => (
<li
key={sIdx}
className="text-[12px] text-medical-gray-400 hover:text-canino-blue hover:translate-x-[-4px] transition-all font-bold cursor-pointer font-vazir whitespace-nowrap"
onClick={(e) => {
e.stopPropagation();
onShopNavigate(item.id, sol);
setIsMegaMenuOpen(false);
}}
>
{sol}
</li>
))}
</ul>
</div>
))}
</motion.div>
)}
</AnimatePresence>
</div>
{[
{ id: 'shop', label: 'محصولات تخصصی', action: () => onShopNavigate() },
{ id: 'wiki', label: 'دانشنامه علمی', action: () => onNavigate('wiki') },
{ id: 'blog', label: 'مجله سلامت پت', action: () => onNavigate('blog') },
{ id: 'profile', label: 'شناسنامه پتها', action: () => onNavigate({ view: 'profile', subview: 'index' }) }
].map((item) => (
<button
key={item.id}
onClick={item.action}
className={`px-4 py-3 rounded-xl text-sm font-black transition-all font-vazir whitespace-nowrap focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none min-h-[48px] ${currentView === item.id ? 'bg-canino-blue/5 text-canino-blue' : 'text-medical-gray-600 hover:bg-medical-gray-50 hover:text-canino-blue'}`}
>
{item.label}
</button>
))}
</nav>
))}
</motion.div>
)}
</AnimatePresence>
</div>
{/* Action Area */}
<div className="flex items-center gap-4 flex-shrink-0 justify-end h-16 pl-2">
{/* Elastic Search */}
<div className="relative flex items-center justify-end z-20">
<AnimatePresence>
{isSearchFocused && (
<motion.div
initial={{ width: 0, opacity: 0 }}
animate={{ width: 350, opacity: 1 }}
exit={{ width: 0, opacity: 0 }}
transition={{ type: "spring", damping: 20, stiffness: 200 }}
className="absolute right-0 top-1/2 -translate-y-1/2 bg-white border-2 border-canino-blue rounded-2xl shadow-xl overflow-hidden h-12 flex items-center pr-10"
>
<form onSubmit={handleSearch} className="w-full flex items-center">
<input
autoFocus
type="text"
value={searchQuery}
onChange={e => setSearchQuery(e.target.value)}
onBlur={() => !searchQuery && setIsSearchFocused(false)}
placeholder="جستجوی محصولات، مقالات سلامت و..."
className="w-full bg-transparent px-4 py-2 text-[12px] font-bold outline-none font-vazir text-medical-gray-900"
/>
<button type="submit" className="px-4 py-2 bg-canino-blue text-white text-[10px] font-black hover:bg-medical-gray-900 transition-colors">
جستجو
</button>
</form>
</motion.div>
)}
</AnimatePresence>
<HeaderButton
variant={isSearchFocused ? "primary" : "secondary"}
className={cn("w-12 h-12 transition-all duration-300", isSearchFocused ? "z-30 bg-canino-blue text-white" : "")}
onClick={() => setIsSearchFocused(!isSearchFocused)}
>
<Search className="w-5 h-5" />
</HeaderButton>
</div>
{[
{ id: 'shop', label: 'محصولات تخصصی', action: () => onShopNavigate() },
{ id: 'wiki', label: 'دانشنامه علمی', action: () => onNavigate('wiki') },
{ id: 'blog', label: 'مجله سلامت پت', action: () => onNavigate('blog') },
{ id: 'profile', label: 'شناسنامه پتها', action: () => onNavigate({ view: 'profile', subview: 'index' }) }
].map((item) => (
<button
key={item.id}
onClick={item.action}
className={`px-4 py-3 rounded-xl text-sm font-black transition-all font-vazir whitespace-nowrap focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none min-h-[48px] ${currentView === item.id ? 'bg-canino-blue/5 text-canino-blue' : 'text-medical-gray-600 hover:bg-medical-gray-50 hover:text-canino-blue'}`}
>
{item.label}
</button>
))}
</nav>
<div className="flex gap-2 items-center h-12">
{isLoggedIn ? (
<div className="flex items-center h-full gap-2 p-1.5 bg-medical-gray-50/50 border border-medical-gray-100 rounded-3xl">
{/* User Name (Direct link to dashboard) */}
<div
className="flex items-center gap-2.5 px-4 py-2 hover:bg-white rounded-2xl cursor-pointer transition-all border border-transparent hover:border-medical-gray-200"
onClick={() => onNavigate("user-dashboard")}
>
<User className="w-5 h-5 text-canino-blue" />
<span className="text-[14px] font-black font-vazir text-medical-gray-900 leading-none">
{profile.firstName}
</span>
</div>
{/* Action Area */}
<div className="flex items-center gap-4 flex-shrink-0 justify-end h-16 pl-2">
{/* Separator Line */}
<div className="w-[1.5px] h-5 bg-medical-gray-200" />
{/* Elastic Search */}
<div className="relative flex items-center justify-end z-20">
<AnimatePresence>
{isSearchFocused && (
<motion.div
initial={{ width: 0, opacity: 0 }}
animate={{ width: 350, opacity: 1 }}
exit={{ width: 0, opacity: 0 }}
transition={{ type: "spring", damping: 20, stiffness: 200 }}
className="absolute right-0 top-1/2 -translate-y-1/2 bg-white border-2 border-canino-blue rounded-2xl shadow-xl overflow-hidden h-12 flex items-center pr-10"
>
<form onSubmit={handleSearch} className="w-full flex items-center">
<input
autoFocus
type="text"
value={searchQuery}
onChange={e => setSearchQuery(e.target.value)}
onBlur={() => !searchQuery && setIsSearchFocused(false)}
placeholder="جستجوی محصولات، مقالات سلامت و..."
className="w-full bg-transparent px-4 py-2 text-[12px] font-bold outline-none font-vazir text-medical-gray-900"
/>
<button type="submit" className="px-4 py-2 bg-canino-blue text-white text-[10px] font-black hover:bg-medical-gray-900 transition-colors">
جستجو
</button>
</form>
</motion.div>
)}
</AnimatePresence>
{/* Pet Name & Switcher */}
<div className="relative h-full flex items-center" ref={petMenuRef}>
<div
<HeaderButton
variant={isSearchFocused ? "primary" : "secondary"}
className={cn("w-12 h-12 transition-all duration-300", isSearchFocused ? "z-30 bg-canino-blue text-white" : "")}
onClick={() => setIsSearchFocused(!isSearchFocused)}
>
<Search className="w-5 h-5" />
</HeaderButton>
</div>
<div className="flex gap-2 items-center h-12">
{isLoggedIn ? (
<div className="flex items-center h-full gap-2 p-1.5 bg-medical-gray-50/50 border border-medical-gray-100 rounded-3xl">
{/* User Name (Direct link to dashboard) */}
<div
className="flex items-center gap-2.5 px-4 py-2 hover:bg-white rounded-2xl cursor-pointer transition-all border border-transparent hover:border-medical-gray-200"
onClick={() => onNavigate("user-dashboard")}
>
<User className="w-5 h-5 text-canino-blue" />
<span className="text-[14px] font-black font-vazir text-medical-gray-900 leading-none">
{profile.firstName}
</span>
</div>
{/* Separator Line */}
<div className="w-[1.5px] h-5 bg-medical-gray-200" />
{/* Pet Name & Switcher */}
<div className="relative h-full flex items-center" ref={petMenuRef}>
<div
className={cn(
"flex items-center gap-2.5 px-4 py-2 rounded-2xl transition-all cursor-pointer",
isPetSwitcherOpen ? "bg-canino-blue text-white shadow-lg shadow-canino-blue/20" : "text-canino-blue hover:bg-white"
@@ -292,7 +292,7 @@ export default function Header({
activePetId === pet.id ? "bg-canino-blue/5 text-canino-blue" : "hover:bg-medical-gray-50 text-medical-gray-600"
)}
>
<div
<div
className="flex items-center gap-3 flex-1 cursor-pointer"
onClick={() => {
setActivePet(pet.id);
@@ -308,7 +308,7 @@ export default function Header({
</div>
<span className="text-[13px] font-bold font-vazir">{pet.name}</span>
</div>
<div className="flex items-center gap-1">
{activePetId === pet.id && <Check className="w-4 h-4 ml-2" />}
<button
@@ -327,173 +327,172 @@ export default function Header({
</div>
))}
</div>
<div className="pt-4 border-t border-medical-gray-100 space-y-1">
<button
<button
onClick={() => { onNavigate({ view: "profile", subview: "add" }); setIsPetSwitcherOpen(false); }}
className="w-full flex items-center gap-3 p-3 text-canino-blue hover:bg-canino-blue/5 rounded-xl transition-all text-[12px] font-black font-vazir"
>
<PlusCircle className="w-5 h-5" />
ثبت همدم (Pet) جدید
</button>
<button
<button
onClick={() => { onNavigate({ view: "user-dashboard" }); setIsPetSwitcherOpen(false); }}
className="w-full flex items-center gap-3 p-3 text-medical-gray-600 hover:bg-medical-gray-50 rounded-xl transition-all text-[12px] font-bold font-vazir"
>
<Wallet className="w-5 h-5" />
کیف پول و سفارشات
</button>
<button
<button
onClick={() => { logout(); setIsPetSwitcherOpen(false); }}
className="w-full flex items-center gap-3 p-3 text-red-500 hover:bg-red-50 rounded-xl transition-all text-[12px] font-bold font-vazir mt-1"
>
<LogOut className="w-5 h-5" />
خروج از حساب کانی‌نو
خروج از حساب کانینو
</button>
</div>
</motion.div>
)}
</AnimatePresence>
</div>
</div>
) : (
<HeaderButton
variant="outline"
className="px-6 h-12 text-sm font-black"
onClick={() => setIsAuthModalOpen(true)}
icon={<LogIn className="w-5 h-5" />}
>
ورود / ثبت‌نام
</HeaderButton>
)}
</div>
</div>
) : (
<HeaderButton
variant="outline"
className="px-6 h-12 text-sm font-black"
onClick={() => setIsAuthModalOpen(true)}
icon={<LogIn className="w-5 h-5" />}
>
ورود / ثبت‌نام
</HeaderButton>
)}
<HeaderButton
<HeaderButton
variant="primary"
className="w-16 h-12"
onClick={onCartOpen}
badge={getTotalItems()}
icon={<ShoppingBag className="w-6 h-6" />}
>
>
<div className="text-[8px] font-black tracking-tight whitespace-nowrap mt-0.5">سبد خرید</div>
</HeaderButton>
</div>
</div>
</div>
</header>
</HeaderButton>
</div>
</div>
</div>
</header>
{/* Mobile Drawer Menu */}
<AnimatePresence>
{isMobileMenuOpen && (
<>
{/* Backdrop */}
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 0.5 }}
exit={{ opacity: 0 }}
onClick={() => setIsMobileMenuOpen(false)}
className="fixed inset-0 bg-black z-40 lg:hidden"
/>
{/* Drawer */}
<motion.div
initial={{ x: "100%" }}
animate={{ x: 0 }}
exit={{ x: "100%" }}
transition={{ type: "spring", damping: 25, stiffness: 200 }}
className="fixed top-0 right-0 bottom-0 w-80 max-w-[85vw] bg-white z-50 shadow-2xl p-6 flex flex-col gap-6 overflow-y-auto lg:hidden"
dir="rtl"
>
<div className="flex items-center justify-between border-b border-medical-gray-100 pb-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-canino-blue rounded-xl flex items-center justify-center text-white font-bold text-xl italic">C</div>
<span className="text-canino-blue font-black text-xl italic font-inter">Canino</span>
</div>
<button
onClick={() => setIsMobileMenuOpen(false)}
className="p-2 rounded-xl hover:bg-medical-gray-50 text-medical-gray-600 transition-all"
>
<X className="w-6 h-6" />
</button>
</div>
{/* Mobile Drawer Menu */}
<AnimatePresence>
{isMobileMenuOpen && (
<>
{/* Backdrop */}
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 0.5 }}
exit={{ opacity: 0 }}
onClick={() => setIsMobileMenuOpen(false)}
className="fixed inset-0 bg-black z-40 lg:hidden"
/>
{/* Drawer */}
<motion.div
initial={{ x: "100%" }}
animate={{ x: 0 }}
exit={{ x: "100%" }}
transition={{ type: "spring", damping: 25, stiffness: 200 }}
className="fixed top-0 right-0 bottom-0 w-80 max-w-[85vw] bg-white z-50 shadow-2xl p-6 flex flex-col gap-6 overflow-y-auto lg:hidden"
dir="rtl"
>
<div className="flex items-center justify-between border-b border-medical-gray-100 pb-4">
<div className="flex items-center gap-3">
<div className="w-10 h-10 bg-canino-blue rounded-xl flex items-center justify-center text-white font-bold text-xl italic">C</div>
<span className="text-canino-blue font-black text-xl italic font-inter">Canino</span>
</div>
<button
onClick={() => setIsMobileMenuOpen(false)}
className="p-2 rounded-xl hover:bg-medical-gray-50 text-medical-gray-600 transition-all"
>
<X className="w-6 h-6" />
</button>
</div>
{/* Navigation Links */}
<nav className="flex flex-col gap-2">
{/* Treatment Solutions accordion */}
<div className="flex flex-col">
<button
onClick={() => setIsMobileSolutionsOpen(!isMobileSolutionsOpen)}
className="w-full flex items-center justify-between px-4 py-3 rounded-xl text-sm font-black text-medical-gray-600 hover:bg-medical-gray-50 transition-all font-vazir"
>
<span>راهکارهای درمانی</span>
<ChevronDown className={`w-4 h-4 transition-transform duration-300 ${isMobileSolutionsOpen ? 'rotate-180' : ''}`} />
</button>
<AnimatePresence>
{isMobileSolutionsOpen && (
<motion.div
initial={{ height: 0, opacity: 0 }}
animate={{ height: "auto", opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
className="overflow-hidden mr-4 pr-2 border-r-2 border-medical-gray-100 mt-1 space-y-3"
>
{MENU_ITEMS.map((item, idx) => (
<div key={idx} className="py-1">
<div
className="text-[13px] font-bold text-medical-gray-800 font-vazir hover:text-canino-blue cursor-pointer flex items-center gap-2"
onClick={() => {
onShopNavigate(item.id);
setIsMobileMenuOpen(false);
}}
>
<span className="text-canino-blue/80">{item.icon}</span>
<span>{item.title}</span>
</div>
<ul className="mt-1 space-y-1 mr-6">
{item.solutions.map((sol, sIdx) => (
<li
key={sIdx}
className="text-[11px] text-medical-gray-500 hover:text-canino-blue cursor-pointer py-1 font-vazir"
onClick={(e) => {
e.stopPropagation();
onShopNavigate(item.id, sol);
setIsMobileMenuOpen(false);
}}
>
{sol}
</li>
))}
</ul>
</div>
))}
</motion.div>
)}
</AnimatePresence>
</div>
{/* Navigation Links */}
<nav className="flex flex-col gap-2">
{/* Treatment Solutions accordion */}
<div className="flex flex-col">
<button
onClick={() => setIsMobileSolutionsOpen(!isMobileSolutionsOpen)}
className="w-full flex items-center justify-between px-4 py-3 rounded-xl text-sm font-black text-medical-gray-600 hover:bg-medical-gray-50 transition-all font-vazir"
>
<span>راهکارهای درمانی</span>
<ChevronDown className={`w-4 h-4 transition-transform duration-300 ${isMobileSolutionsOpen ? 'rotate-180' : ''}`} />
</button>
<AnimatePresence>
{isMobileSolutionsOpen && (
<motion.div
initial={{ height: 0, opacity: 0 }}
animate={{ height: "auto", opacity: 1 }}
exit={{ height: 0, opacity: 0 }}
className="overflow-hidden mr-4 pr-2 border-r-2 border-medical-gray-100 mt-1 space-y-3"
>
{MENU_ITEMS.map((item, idx) => (
<div key={idx} className="py-1">
<div
className="text-[13px] font-bold text-medical-gray-800 font-vazir hover:text-canino-blue cursor-pointer flex items-center gap-2"
onClick={() => {
onShopNavigate(item.id);
setIsMobileMenuOpen(false);
}}
>
<span className="text-canino-blue/80">{item.icon}</span>
<span>{item.title}</span>
</div>
<ul className="mt-1 space-y-1 mr-6">
{item.solutions.map((sol, sIdx) => (
<li
key={sIdx}
className="text-[11px] text-medical-gray-500 hover:text-canino-blue cursor-pointer py-1 font-vazir"
onClick={(e) => {
e.stopPropagation();
onShopNavigate(item.id, sol);
setIsMobileMenuOpen(false);
}}
>
{sol}
</li>
))}
</ul>
</div>
))}
</motion.div>
)}
</AnimatePresence>
</div>
{[
{ id: 'shop', label: 'محصولات تخصصی', action: () => onShopNavigate() },
{ id: 'wiki', label: 'دانشنامه علمی', action: () => onNavigate('wiki') },
{ id: 'blog', label: 'مجله سلامت پت', action: () => onNavigate('blog') },
{ id: 'profile', label: 'شناسنامه پتها', action: () => onNavigate({ view: 'profile', subview: 'index' }) }
].map((item) => (
<button
key={item.id}
onClick={() => {
item.action();
setIsMobileMenuOpen(false);
}}
className={`w-full text-right px-4 py-3 rounded-xl text-sm font-black transition-all font-vazir ${
currentView === item.id
? 'bg-canino-blue/5 text-canino-blue'
: 'text-medical-gray-600 hover:bg-medical-gray-50'
}`}
>
{item.label}
</button>
))}
</nav>
</motion.div>
</>
)}
</AnimatePresence>
</>
);
}
{[
{ id: 'shop', label: 'محصولات تخصصی', action: () => onShopNavigate() },
{ id: 'wiki', label: 'دانشنامه علمی', action: () => onNavigate('wiki') },
{ id: 'blog', label: 'مجله سلامت پت', action: () => onNavigate('blog') },
{ id: 'profile', label: 'شناسنامه پتها', action: () => onNavigate({ view: 'profile', subview: 'index' }) }
].map((item) => (
<button
key={item.id}
onClick={() => {
item.action();
setIsMobileMenuOpen(false);
}}
className={`w-full text-right px-4 py-3 rounded-xl text-sm font-black transition-all font-vazir ${currentView === item.id
? 'bg-canino-blue/5 text-canino-blue'
: 'text-medical-gray-600 hover:bg-medical-gray-50'
}`}
>
{item.label}
</button>
))}
</nav>
</motion.div>
</>
)}
</AnimatePresence>
</>
);
}
+25 -18
View File
@@ -9,8 +9,8 @@ function StatCounter({ target }: { target: number }) {
const [displayValue, setDisplayValue] = useState(0);
useEffect(() => {
const controls = animate(0, target, {
duration: 3,
const controls = animate(0, target, {
duration: 3,
ease: [0.16, 1, 0.3, 1], // Custom cubic-bezier for a more polished feel
onUpdate: (latest) => setDisplayValue(Math.round(latest))
});
@@ -18,7 +18,7 @@ function StatCounter({ target }: { target: number }) {
}, [target]);
return (
<motion.div
<motion.div
initial={{ scale: 0.8, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={{ duration: 2.5, ease: "easeOut" }}
@@ -50,7 +50,7 @@ function Typewriter({ text }: { text: string }) {
<div className="text-4xl lg:text-6xl font-black text-canino-blue font-vazir flex flex-row-reverse items-center">
<span className="relative">
{toPersian(displayText)}
<motion.span
<motion.span
animate={{ opacity: [0, 1, 0] }}
transition={{ duration: 0.8, repeat: Infinity }}
className="absolute -left-1 top-0 h-full w-[3px] bg-canino-blue"
@@ -92,13 +92,13 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
<span className="w-2 h-2 rounded-full bg-canino-blue animate-pulse" />
<span className="text-canino-blue text-xs font-bold uppercase tracking-widest leading-none">{getText('hero_badge', "تخصص دارویی از آلمان")}</span>
</div>
<h1 className="text-4xl lg:text-7xl font-black text-medical-gray-900 leading-[1.1] mb-6">
{titleParts[0]} <br />
{titleParts[1] && <span className="text-canino-blue font-vazir">{titleParts[1]}</span>}
</h1>
<p
<p
className="text-lg lg:text-xl text-medical-gray-600 mb-10 max-w-2xl mx-auto lg:mx-0 leading-relaxed font-vazir animate-fade-in"
dangerouslySetInnerHTML={{
__html: subtitle
@@ -106,7 +106,7 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
/>
<div className="flex flex-wrap justify-center lg:justify-start gap-4 sm:gap-6">
<button
<button
onClick={() => {
const element = document.getElementById('canino-advisor');
if (element) {
@@ -118,7 +118,7 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
{getText('hero_btn_advisor', "دستیار سلامت پت")}
<ChevronLeft className="w-5 h-5 group-hover:-translate-x-1 transition-transform" />
</button>
<button
<button
onClick={() => router.push('/shop')}
className="bg-white border-2 border-medical-gray-200 text-medical-gray-700 px-10 py-5 rounded-full font-bold text-lg hover:border-canino-blue hover:text-canino-blue focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all font-vazir min-h-[48px]"
>
@@ -136,12 +136,19 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
transition={{ duration: 1, ease: "easeOut" }}
className="relative z-10"
>
<div className="aspect-square bg-medical-gray-100 rounded-[2rem] overflow-hidden border-4 border-white shadow-2xl relative">
<img
<div className="aspect-square bg-gradient-to-br from-slate-200 to-slate-300 rounded-[2rem] overflow-hidden border-4 border-white shadow-2xl relative">
<img
src={banners.length > 0 && banners[0].imageUrl ? banners[0].imageUrl : "https://images.unsplash.com/photo-1583337130417-3346a1be7dee?auto=format&fit=crop&q=80&w=800"}
alt={banners.length > 0 ? banners[0].title : "German Veterinary Expert"}
alt={banners.length > 0 ? banners[0].title : "German Veterinary Expert"}
className="w-full h-full object-cover grayscale-[20%] hover:grayscale-0 transition-all duration-700"
referrerPolicy="no-referrer"
loading="eager"
crossOrigin="anonymous"
onError={(e) => {
const target = e.currentTarget;
target.style.display = 'none';
// Show gradient fallback
target.parentElement!.style.background = 'linear-gradient(135deg, #e2e8f0 0%, #94a3b8 100%)';
}}
/>
<div className="absolute bottom-0 left-0 right-0 p-8 bg-gradient-to-t from-black/80 to-transparent text-white text-right">
<div className="text-sm font-medium mb-1 opacity-80 uppercase tracking-widest text-[10px]">{getText('hero_image_badge', "سرآمد علمی در پزشکی پت‌ها")}</div>
@@ -166,14 +173,14 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
{/* Stats - Centered, full-width row under Hero content to decrease cognitive load */}
<div className="max-w-7xl mx-auto px-4 relative">
<motion.div
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: 0.8, duration: 0.6 }}
className="grid grid-cols-1 md:grid-cols-3 gap-8 py-12 border-t border-medical-gray-150"
>
<div className="flex flex-col items-center justify-center text-center">
<Typewriter text={getText('hero_stat_founded', "۱۹۸۴ سال تأسیس")} />
<Typewriter text={getText('hero_stat_founded', "سال تأسیس ۱۹۸۴")} />
</div>
<div className="flex flex-col items-center justify-center text-center">
<StatCounter target={40} />
@@ -181,12 +188,12 @@ export default function Hero({ banners = [] }: { banners?: any[] }) {
</div>
<div className="flex flex-col items-center justify-center text-center">
<div className="relative overflow-hidden group">
<motion.div
className="text-4xl lg:text-6xl font-black text-canino-blue font-vazir relative z-10"
<motion.div
className="text-4xl lg:text-6xl font-black text-canino-blue font-vazir relative z-10"
>
۱۰۰٪
</motion.div>
<motion.div
<motion.div
initial={{ x: "-100%" }}
animate={{ x: "200%" }}
transition={{ duration: 3, repeat: Infinity, ease: "linear" }}
+19 -19
View File
@@ -120,16 +120,16 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
{isOpen && (
<div className="fixed inset-0 z-[200] flex items-center justify-center p-4">
{/* Backdrop */}
<motion.div
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={onClose}
className="absolute inset-0 bg-medical-gray-900/60 backdrop-blur-md"
/>
{/* Modal Container */}
<motion.div
<motion.div
initial={{ opacity: 0, scale: 0.9, y: 20 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.9, y: 20 }}
@@ -138,9 +138,9 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
>
{/* Top color indicator */}
<div className="absolute top-0 left-0 w-full h-2 bg-gradient-to-r from-canino-blue to-indigo-500" />
{/* Close Button */}
<button
<button
onClick={onClose}
className="absolute top-8 left-8 p-2 rounded-full hover:bg-medical-gray-50 text-medical-gray-400 hover:text-medical-gray-600 transition-colors"
>
@@ -153,7 +153,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
<ShieldCheck className="w-10 h-10 text-canino-blue" />
</div>
<h3 className="text-3xl font-black text-medical-gray-900 mb-2 italic">
ورود به کانی‌نو
ورود به کانینو
</h3>
{isAdvisorContext ? (
<p className="text-medical-gray-500 font-bold leading-relaxed px-2 text-sm">
@@ -167,7 +167,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
{/* Step-based Forms */}
<AnimatePresence mode="wait">
{step === "phone" ? (
<motion.form
<motion.form
key="phone-form"
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
@@ -179,11 +179,11 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
<label className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest block">شماره موبایل</label>
<div className="relative">
<Phone className="absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-medical-gray-400" />
<input
<input
autoFocus
type="tel"
type="tel"
maxLength={11}
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
placeholder="مثال: ۰۹۱۲۳۴۵۶۷۸۹"
value={phoneNumber}
onChange={(e) => setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))}
disabled={isLoading}
@@ -192,7 +192,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
</div>
</div>
<button
<button
type="submit"
disabled={isLoading || phoneNumber.length < 11}
className="w-full py-5 bg-canino-blue text-white rounded-2xl font-black text-xl hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all shadow-xl shadow-canino-blue/20 flex items-center justify-center gap-3 cursor-pointer"
@@ -208,7 +208,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
</button>
</motion.form>
) : (
<motion.form
<motion.form
key="otp-form"
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
@@ -219,8 +219,8 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
<div className="space-y-2">
<div className="flex justify-between items-center">
<label className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest">کد تایید پیامکی</label>
<button
type="button"
<button
type="button"
onClick={() => setStep("phone")}
className="text-[10px] font-black text-canino-blue flex items-center gap-1 hover:underline"
>
@@ -230,11 +230,11 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
</div>
<div className="relative">
<Key className="absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-medical-gray-400" />
<input
<input
ref={otpInputRef}
type="text"
type="text"
maxLength={5}
placeholder="کد ۵ رقمی"
placeholder="کد ۵ رقمی"
value={otpCode}
onChange={(e) => setOtpCode(e.target.value.replace(/[^0-9]/g, ''))}
disabled={isLoading}
@@ -252,7 +252,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
ارسال مجدد کد پس از {toPersian(countdown)} ثانیه
</span>
) : (
<button
<button
type="button"
onClick={handleResendOtp}
disabled={isLoading}
@@ -264,7 +264,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
)}
</div>
<button
<button
type="submit"
disabled={isLoading || otpCode.length < 5}
className="w-full py-5 bg-canino-blue text-white rounded-2xl font-black text-xl hover:bg-indigo-700 disabled:opacity-50 disabled:cursor-not-allowed transition-all shadow-xl shadow-canino-blue/20 flex items-center justify-center gap-3 cursor-pointer"
@@ -1,15 +1,15 @@
"use client";
import React from "react";
import { motion, AnimatePresence } from "motion/react";
import {
X,
Printer,
Download,
Package,
import {
X,
Printer,
Download,
Package,
ShoppingBag,
MapPin,
Calendar,
Clock,
MapPin,
Calendar,
Clock,
CreditCard,
CheckCircle2,
AlertCircle,
@@ -62,7 +62,7 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
</head>
<body>
<div class="header">
<div class="logo">CANINO | کانی‌نو</div>
<div class="logo">CANINO | کانینو</div>
<div>تاریخ: ${toPersian(new Date(order.date).toLocaleDateString('fa-IR'))}</div>
</div>
<div class="info">
@@ -122,14 +122,14 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
<AnimatePresence>
{isOpen && (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
<motion.div
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={onClose}
className="absolute inset-0 bg-medical-gray-900/60 backdrop-blur-md"
/>
<motion.div
<motion.div
initial={{ opacity: 0, scale: 0.9, y: 20 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.9, y: 20 }}
@@ -138,124 +138,124 @@ export default function OrderDetailsModal({ isOpen, onClose, order }: OrderDetai
>
{/* Header */}
<div className="bg-medical-gray-50 px-10 py-8 flex items-center justify-between border-b border-medical-gray-100">
<div className="flex items-center gap-4">
<div className="w-14 h-14 bg-canino-blue rounded-2xl flex items-center justify-center text-white shadow-lg">
<Package className="w-7 h-7" />
</div>
<div>
<h3 className="text-xl font-black text-medical-gray-900 italic">جزئیات سفارش {toPersian(order.id)}</h3>
<p className="text-xs font-bold text-medical-gray-400">ثبت شده در {toPersian(orderDate.toLocaleDateString("fa-IR"))}</p>
</div>
</div>
<button
onClick={onClose}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white border border-medical-gray-200 text-medical-gray-400 hover:text-red-500 transition-all"
>
<X className="w-5 h-5" />
</button>
<div className="flex items-center gap-4">
<div className="w-14 h-14 bg-canino-blue rounded-2xl flex items-center justify-center text-white shadow-lg">
<Package className="w-7 h-7" />
</div>
<div>
<h3 className="text-xl font-black text-medical-gray-900 italic">جزئیات سفارش {toPersian(order.id)}</h3>
<p className="text-xs font-bold text-medical-gray-400">ثبت شده در {toPersian(orderDate.toLocaleDateString("fa-IR"))}</p>
</div>
</div>
<button
onClick={onClose}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white border border-medical-gray-200 text-medical-gray-400 hover:text-red-500 transition-all"
>
<X className="w-5 h-5" />
</button>
</div>
{/* Content Scrollable */}
<div className="max-h-[70vh] overflow-y-auto px-10 py-8 space-y-10 custom-scrollbar">
{/* Summary Stats */}
<div className="grid grid-cols-3 gap-4">
<div className="bg-medical-gray-50 p-4 rounded-2xl">
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">وضعیت تحویل</div>
<div className="flex items-center gap-2">
{getStatusIcon(order.status)}
<span className="text-sm font-black text-medical-gray-900">{getStatusLabel(order.status)}</span>
</div>
{/* Summary Stats */}
<div className="grid grid-cols-3 gap-4">
<div className="bg-medical-gray-50 p-4 rounded-2xl">
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">وضعیت تحویل</div>
<div className="flex items-center gap-2">
{getStatusIcon(order.status)}
<span className="text-sm font-black text-medical-gray-900">{getStatusLabel(order.status)}</span>
</div>
<div className="bg-medical-gray-50 p-4 rounded-2xl">
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">کد رهگیری</div>
<div className="text-sm font-mono font-bold text-canino-blue">{toPersian(order.trackingNumber)}</div>
</div>
<div className="bg-medical-gray-50 p-4 rounded-2xl">
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">کد رهگیری</div>
<div className="text-sm font-mono font-bold text-canino-blue">{toPersian(order.trackingNumber)}</div>
</div>
<div className="bg-medical-gray-50 p-4 rounded-2xl">
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">زمان ثبت</div>
<div className="flex items-center gap-2">
<Clock className="w-4 h-4 text-medical-gray-400" />
<span className="text-sm font-black text-medical-gray-900">{toPersian(orderDate.toLocaleTimeString("fa-IR", { hour: '2-digit', minute: '2-digit' }))}</span>
</div>
<div className="bg-medical-gray-50 p-4 rounded-2xl">
<div className="text-[9px] font-black text-medical-gray-400 uppercase tracking-widest mb-1">زمان ثبت</div>
<div className="flex items-center gap-2">
<Clock className="w-4 h-4 text-medical-gray-400" />
<span className="text-sm font-black text-medical-gray-900">{toPersian(orderDate.toLocaleTimeString("fa-IR", { hour: '2-digit', minute: '2-digit' }))}</span>
</div>
</div>
</div>
</div>
</div>
{/* Items List */}
<div>
<h4 className="text-sm font-black text-medical-gray-900 mb-6 flex items-center gap-2">
<ShoppingBag className="w-4 h-4 text-canino-blue" />
سبد محصولات خریده شده
{/* Items List */}
<div>
<h4 className="text-sm font-black text-medical-gray-900 mb-6 flex items-center gap-2">
<ShoppingBag className="w-4 h-4 text-canino-blue" />
سبد محصولات خریده شده
</h4>
<div className="space-y-4">
{(order.items || []).map((item: any) => (
<div key={item.product.id} className="flex items-center justify-between p-4 border border-medical-gray-100 rounded-2xl hover:border-canino-blue transition-all">
<div className="flex items-center gap-4">
<div className="w-16 h-16 bg-medical-gray-50 rounded-xl p-2 flex items-center justify-center shrink-0">
<SafeImage
src={item.product.image}
alt={item.product.name}
className="w-full h-full"
imgClassName="object-contain"
/>
</div>
<div>
<h5 className="font-black text-medical-gray-900 leading-tight mb-1">{item.product.name}</h5>
<div className="text-[10px] font-bold text-medical-gray-400">{toPersian(item.quantity)} عدد × {toPersian(item.product.priceValue.toLocaleString())} تومان</div>
</div>
</div>
<div className="text-left">
<div className="text-lg font-black text-canino-blue italic">{toPersian((item.product.priceValue * item.quantity).toLocaleString())} <span className="text-[10px] not-italic">تومان</span></div>
</div>
</div>
))}
</div>
</div>
{/* Shipping & Payment */}
<div className="grid md:grid-cols-2 gap-8 pt-6 border-t border-medical-gray-100">
<div>
<h4 className="text-sm font-black text-medical-gray-900 mb-4 flex items-center gap-2">
<MapPin className="w-4 h-4 text-canino-blue" />
اطلاعات ارسال
</h4>
<div className="space-y-4">
{(order.items || []).map((item: any) => (
<div key={item.product.id} className="flex items-center justify-between p-4 border border-medical-gray-100 rounded-2xl hover:border-canino-blue transition-all">
<div className="flex items-center gap-4">
<div className="w-16 h-16 bg-medical-gray-50 rounded-xl p-2 flex items-center justify-center shrink-0">
<SafeImage
src={item.product.image}
alt={item.product.name}
className="w-full h-full"
imgClassName="object-contain"
/>
</div>
<div>
<h5 className="font-black text-medical-gray-900 leading-tight mb-1">{item.product.name}</h5>
<div className="text-[10px] font-bold text-medical-gray-400">{toPersian(item.quantity)} عدد × {toPersian(item.product.priceValue.toLocaleString())} تومان</div>
</div>
</div>
<div className="text-left">
<div className="text-lg font-black text-canino-blue italic">{toPersian((item.product.priceValue * item.quantity).toLocaleString())} <span className="text-[10px] not-italic">تومان</span></div>
</div>
</div>
))}
<p className="text-xs font-bold text-medical-gray-500 leading-relaxed">
تهران، خیابان ولیعصر، بالاتر از میدان ونک، بن‌بست آفتاب، پلاک ۱۲، واحد ۳
</p>
</div>
<div>
<h4 className="text-sm font-black text-medical-gray-900 mb-4 flex items-center gap-2">
<CreditCard className="w-4 h-4 text-canino-blue" />
جزئیات پرداخت
</h4>
<div className="space-y-2">
<div className="flex justify-between text-xs font-bold text-medical-gray-400">
<span>جمع ناخالص</span>
<span>{toPersian(order.total.toLocaleString())} تومان</span>
</div>
<div className="flex justify-between text-xs font-bold text-red-500">
<span>تخفیف هوشمند</span>
<span>{toPersian("۰")} تومان</span>
</div>
<div className="flex justify-between text-base font-black text-medical-gray-900 pt-2 border-t border-medical-gray-50 italic">
<span>مبلغ نهایی</span>
<span>{toPersian(order.total.toLocaleString())} تومان</span>
</div>
</div>
</div>
{/* Shipping & Payment */}
<div className="grid md:grid-cols-2 gap-8 pt-6 border-t border-medical-gray-100">
<div>
<h4 className="text-sm font-black text-medical-gray-900 mb-4 flex items-center gap-2">
<MapPin className="w-4 h-4 text-canino-blue" />
اطلاعات ارسال
</h4>
<p className="text-xs font-bold text-medical-gray-500 leading-relaxed">
تهران، خیابان ولیعصر، بالاتر از میدان ونک، بن‌بست آفتاب، پلاک ۱۲، واحد ۳
</p>
</div>
<div>
<h4 className="text-sm font-black text-medical-gray-900 mb-4 flex items-center gap-2">
<CreditCard className="w-4 h-4 text-canino-blue" />
جزئیات پرداخت
</h4>
<div className="space-y-2">
<div className="flex justify-between text-xs font-bold text-medical-gray-400">
<span>جمع ناخالص</span>
<span>{toPersian(order.total.toLocaleString())} تومان</span>
</div>
<div className="flex justify-between text-xs font-bold text-red-500">
<span>تخفیف هوشمند</span>
<span>{toPersian("۰")} تومان</span>
</div>
<div className="flex justify-between text-base font-black text-medical-gray-900 pt-2 border-t border-medical-gray-50 italic">
<span>مبلغ نهایی</span>
<span>{toPersian(order.total.toLocaleString())} تومان</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/* Footer Actions */}
<div className="p-10 bg-medical-gray-50 border-t border-medical-gray-100 flex gap-4">
<button
onClick={handlePrint}
className="flex-1 py-5 bg-white border border-medical-gray-200 text-medical-gray-900 rounded-2xl font-black text-sm flex items-center justify-center gap-3 hover:bg-medical-gray-100 transition-all shadow-sm"
>
<Download className="w-5 h-5" />
دانلود فاکتور رسمی
</button>
<button className="flex items-center justify-center w-14 h-14 bg-medical-gray-900 text-white rounded-2xl hover:bg-canino-blue transition-all shadow-lg shadow-black/10">
<Printer className="w-6 h-6" />
</button>
<button
onClick={handlePrint}
className="flex-1 py-5 bg-white border border-medical-gray-200 text-medical-gray-900 rounded-2xl font-black text-sm flex items-center justify-center gap-3 hover:bg-medical-gray-100 transition-all shadow-sm"
>
<Download className="w-5 h-5" />
دانلود فاکتور رسمی
</button>
<button className="flex items-center justify-center w-14 h-14 bg-medical-gray-900 text-white rounded-2xl hover:bg-canino-blue transition-all shadow-lg shadow-black/10">
<Printer className="w-6 h-6" />
</button>
</div>
</motion.div>
</div>
File diff suppressed because it is too large. Load diff
+224 -224
View File
@@ -1,15 +1,15 @@
"use client";
import { useState, useMemo, useEffect } from "react";
import { motion, AnimatePresence } from "motion/react";
import {
ArrowRight,
Calculator as CalcIcon,
ChevronLeft,
ShieldCheck,
CheckCircle2,
Clock,
FlaskConical,
Stethoscope,
import {
ArrowRight,
Calculator as CalcIcon,
ChevronLeft,
ShieldCheck,
CheckCircle2,
Clock,
FlaskConical,
Stethoscope,
Info,
CalendarDays,
Dog,
@@ -162,28 +162,28 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
<div className="max-w-7xl mx-auto">
{/* Mobile Header with Back Button */}
<div className="flex items-center justify-between mb-6 md:hidden">
<button
onClick={() => router.back()}
className="p-3 bg-white border border-medical-gray-200 rounded-2xl text-medical-gray-700 shadow-sm flex items-center gap-2 font-vazir text-sm font-bold"
>
<ChevronRight className="w-5 h-5" />
بازگشت
</button>
<div className="text-[10px] font-black text-canino-blue bg-canino-blue/5 px-4 py-2 rounded-xl font-vazir whitespace-nowrap">
کانی‌نو ایران
</div>
<button
onClick={() => router.back()}
className="p-3 bg-white border border-medical-gray-200 rounded-2xl text-medical-gray-700 shadow-sm flex items-center gap-2 font-vazir text-sm font-bold"
>
<ChevronRight className="w-5 h-5" />
بازگشت
</button>
<div className="text-[10px] font-black text-canino-blue bg-canino-blue/5 px-4 py-2 rounded-xl font-vazir whitespace-nowrap">
کانینو ایران
</div>
</div>
{/* Breadcrumbs */}
<nav className="hidden md:flex items-center gap-2 text-xs font-bold text-medical-gray-400 mb-8 overflow-x-auto whitespace-nowrap py-2">
<button
onClick={() => router.push('/')}
<button
onClick={() => router.push('/')}
className="hover:text-canino-blue transition-colors font-vazir cursor-pointer"
>
خانه
</button>
<ChevronLeft className="w-3 h-3 flex-shrink-0" />
<button
<button
onClick={() => router.push(`/shop?category=${product.category}`)}
className="hover:text-canino-blue cursor-pointer font-vazir"
>
@@ -238,12 +238,12 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
const Icon = ICON_MAP[benefit.icon] || CheckCircle2;
return (
<div key={i} className="bg-white border border-medical-gray-100 rounded-[2rem] p-8 shadow-sm hover:shadow-xl hover:-translate-y-1 transition-all group overflow-hidden relative">
<div className="absolute -top-10 -left-10 w-24 h-24 bg-canino-blue/5 rounded-full group-hover:scale-150 transition-transform duration-700" />
<div className="w-12 h-12 bg-medical-gray-50 rounded-2xl flex items-center justify-center text-canino-blue mb-6 group-hover:bg-canino-blue group-hover:text-white transition-all">
<Icon className="w-6 h-6" />
</div>
<h4 className="text-xl font-black text-medical-gray-900 mb-2 font-vazir">{benefit.title}</h4>
<p className="text-sm text-medical-gray-500 font-bold font-vazir">{benefit.description}</p>
<div className="absolute -top-10 -left-10 w-24 h-24 bg-canino-blue/5 rounded-full group-hover:scale-150 transition-transform duration-700" />
<div className="w-12 h-12 bg-medical-gray-50 rounded-2xl flex items-center justify-center text-canino-blue mb-6 group-hover:bg-canino-blue group-hover:text-white transition-all">
<Icon className="w-6 h-6" />
</div>
<h4 className="text-xl font-black text-medical-gray-900 mb-2 font-vazir">{benefit.title}</h4>
<p className="text-sm text-medical-gray-500 font-bold font-vazir">{benefit.description}</p>
</div>
);
})}
@@ -251,7 +251,7 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
</section>
)}
<motion.div
<motion.div
initial={{ opacity: 0, scale: 0.95 }}
animate={{ opacity: 1, scale: 1 }}
className="bg-white rounded-[3.5rem] p-12 border border-medical-gray-200 shadow-xl relative group overflow-hidden"
@@ -265,8 +265,8 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
گرید دارویی اختصاصی
</div>
</div>
<SafeImage
src={product.image}
<SafeImage
src={product.image}
alt={product.name}
className="w-full max-w-md mx-auto h-auto drop-shadow-2xl group-hover:scale-105 transition-transform duration-700"
/>
@@ -291,11 +291,11 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
return (
<div key={idx} className="bg-medical-gray-50 border border-medical-gray-100 px-5 py-3 rounded-2xl flex items-center gap-3 group hover:border-canino-blue/30 transition-all">
<span className="text-sm font-bold text-medical-gray-700 font-vazir">
{termKey ? (
<Tooltip termKey={termKey} onWikiNavigate={(id) => router.push(`/wiki?term=${id}`)}>
{ing}
</Tooltip>
) : ing}
{termKey ? (
<Tooltip termKey={termKey} onWikiNavigate={(id) => router.push(`/wiki?term=${id}`)}>
{ing}
</Tooltip>
) : ing}
</span>
<Sparkles className="w-3 h-3 text-canino-blue opacity-40 group-hover:opacity-100 transition-opacity" />
</div>
@@ -306,38 +306,38 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
{/* Analysis Cards Grid */}
<div className="space-y-6">
<div className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-4 font-vazir">تخمین اتمام بسته (هوش مصنوعی)</div>
<div className="grid grid-cols-2 gap-4">
{Object.entries(product.analysis).map(([key, value]) => (
<div key={key} className="bg-canino-blue text-white p-8 rounded-[2rem] border-b-2 border-white/20 shadow-xl group hover:scale-[1.02] transition-all duration-300">
<div className="text-[10px] font-black text-white/80 uppercase tracking-widest mb-3 font-vazir whitespace-nowrap">{key}</div>
<div className="text-3xl font-black font-vazir tracking-tighter text-white">{toPersian(value)}</div>
</div>
))}
</div>
<div className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-4 font-vazir">تخمین اتمام بسته (هوش مصنوعی)</div>
<div className="grid grid-cols-2 gap-4">
{Object.entries(product.analysis).map(([key, value]) => (
<div key={key} className="bg-canino-blue text-white p-8 rounded-[2rem] border-b-2 border-white/20 shadow-xl group hover:scale-[1.02] transition-all duration-300">
<div className="text-[10px] font-black text-white/80 uppercase tracking-widest mb-3 font-vazir whitespace-nowrap">{key}</div>
<div className="text-3xl font-black font-vazir tracking-tighter text-white">{toPersian(value)}</div>
</div>
))}
</div>
</div>
</div>
</section>
{/* Feeding Section */}
<section className="bg-canino-blue/5 border border-canino-blue/10 rounded-[3rem] p-10">
<div className="flex items-center gap-4 mb-8">
<div className="w-10 h-10 bg-canino-blue text-white rounded-xl flex items-center justify-center">
<CalendarDays className="w-6 h-6" />
</div>
<h3 className="text-2xl font-black text-medical-gray-900 italic font-vazir">توصیه غذایی و نحوه مصرف</h3>
</div>
<p className="text-medical-gray-700 leading-relaxed text-sm md:text-base font-medium font-vazir">
{product.feedingAdvice}
</p>
<div className="flex items-center gap-4 mb-8">
<div className="w-10 h-10 bg-canino-blue text-white rounded-xl flex items-center justify-center">
<CalendarDays className="w-6 h-6" />
</div>
<h3 className="text-2xl font-black text-medical-gray-900 italic font-vazir">توصیه غذایی و نحوه مصرف</h3>
</div>
<p className="text-medical-gray-700 leading-relaxed text-sm md:text-base font-medium font-vazir">
{product.feedingAdvice}
</p>
</section>
{/* Specialist Note */}
<section className="bg-white rounded-[3rem] p-10 border border-medical-gray-200">
{product.specialist && (
{product.specialist && (
<div className="flex flex-col md:flex-row gap-10 items-start">
<img
src={product.specialist.image}
<img
src={product.specialist.image}
alt={product.specialist.name}
className="w-32 h-32 rounded-[2.5rem] object-cover border-4 border-medical-gray-50 shadow-xl"
/>
@@ -352,19 +352,19 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
"{product.specialist.message}"
</p>
</div>
</div>
)}
</div>
)}
</section>
{/* Specialized Landing Banner */}
<section>
<div
<div
className="relative bg-canino-blue rounded-[3rem] p-12 overflow-hidden group cursor-pointer"
onClick={() => toast.info("بزودی: صفحه فرود تخصصی این محصول در حال آماده‌سازی است")}
>
<div className="absolute top-0 right-0 w-full h-full bg-[url('https://www.transparenttextures.com/patterns/cubes.png')] opacity-10" />
<div className="absolute -bottom-20 -left-20 w-80 h-80 bg-white/10 rounded-full blur-3xl group-hover:bg-white/20 transition-all duration-700" />
<div className="relative z-10 flex flex-col md:flex-row items-center justify-between gap-8">
<div className="text-center md:text-right">
<h3 className="text-3xl lg:text-4xl font-black text-white mb-4 italic">مشاهده بررسی تخصصی و نتایج درمانی</h3>
@@ -373,13 +373,13 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
</p>
</div>
<div className="bg-white text-canino-blue px-8 py-4 rounded-2xl font-black shadow-2xl hover:scale-105 transition-transform flex items-center gap-3">
ورود به آزمایشگاه علمی
<ArrowRight className="w-5 h-5 rotate-180" />
ورود به آزمایشگاه علمی
<ArrowRight className="w-5 h-5 rotate-180" />
</div>
</div>
</div>
</section>
{/* FAQ Section */}
{product.faqs && (
<section className="pt-10">
@@ -393,11 +393,11 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
{product.faqs.map((faq, i) => (
<details key={i} className="group bg-white border border-medical-gray-200 rounded-3xl overflow-hidden hover:border-canino-blue/30 transition-all">
<summary className="flex items-center justify-between p-6 cursor-pointer list-none">
<span className="font-bold text-medical-gray-900 font-vazir">{faq.question}</span>
<ChevronDown className="w-5 h-5 text-canino-blue group-open:rotate-180 transition-transform" />
<span className="font-bold text-medical-gray-900 font-vazir">{faq.question}</span>
<ChevronDown className="w-5 h-5 text-canino-blue group-open:rotate-180 transition-transform" />
</summary>
<div className="px-6 pb-6 text-sm text-medical-gray-500 font-medium leading-relaxed font-vazir border-t border-medical-gray-50 pt-4">
{faq.answer}
{faq.answer}
</div>
</details>
))}
@@ -409,111 +409,111 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
{/* Sticky Sidebar */}
<div className="lg:col-span-4 lg:sticky lg:top-24 space-y-8">
<div className="bg-white rounded-[3rem] border-2 border-medical-gray-100 p-8 shadow-2xl relative overflow-hidden">
<div className="absolute top-0 right-0 w-24 h-24 bg-canino-blue/5 rounded-full -mr-12 -mt-12" />
<div className="text-4xl font-black font-vazir text-medical-gray-900 tracking-tighter mb-4">
{toPersian(product.price)}
</div>
<div className="absolute top-0 right-0 w-24 h-24 bg-canino-blue/5 rounded-full -mr-12 -mt-12" />
{/* Refill Auto-Calculator */}
<div className="bg-canino-blue rounded-[2rem] p-6 text-white mb-8 border-b-8 border-white/20 shadow-2xl">
<div className="flex items-center gap-2 mb-4 opacity-90">
<Clock className="w-4 h-4 text-white" />
<span className="text-[10px] font-bold uppercase tracking-widest font-vazir text-white">هوش مصنوعی تکرار خرید</span>
</div>
<div className="flex items-center justify-between">
<div>
<div className="text-2xl font-black font-vazir text-white">{toPersian(calculation.duration)} روز</div>
<div className="text-[9px] font-bold text-white/80 font-vazir whitespace-nowrap">تخمین اتمام برای {toPersian(weight)} کیلوگرم</div>
</div>
<div className="text-left">
<div className="text-xl font-black font-vazir text-white">{toPersian(calculation.dailyDose)}</div>
<div className="text-[9px] font-bold text-white/80 font-vazir whitespace-nowrap">دوز روزانه ({calculation.unit === 'g' ? 'گرم' : calculation.unit})</div>
</div>
</div>
</div>
<div className="text-4xl font-black font-vazir text-medical-gray-900 tracking-tighter mb-4">
{toPersian(product.price)}
</div>
{/* Manual Calculator (Mini) */}
<div className="bg-medical-gray-50 rounded-2xl p-6 border border-medical-gray-100 mb-8 space-y-6">
<div className="flex items-center justify-between">
<span className="text-[10px] font-black text-medical-gray-400 font-vazir">وزن پت (کیلوگرم)</span>
<span className="text-sm font-black text-canino-blue font-vazir">{toPersian(weight)}</span>
{/* Refill Auto-Calculator */}
<div className="bg-canino-blue rounded-[2rem] p-6 text-white mb-8 border-b-8 border-white/20 shadow-2xl">
<div className="flex items-center gap-2 mb-4 opacity-90">
<Clock className="w-4 h-4 text-white" />
<span className="text-[10px] font-bold uppercase tracking-widest font-vazir text-white">هوش مصنوعی تکرار خرید</span>
</div>
<div className="flex items-center justify-between">
<div>
<div className="text-2xl font-black font-vazir text-white">{toPersian(calculation.duration)} روز</div>
<div className="text-[9px] font-bold text-white/80 font-vazir whitespace-nowrap">تخمین اتمام برای {toPersian(weight)} کیلوگرم</div>
</div>
<input
type="range"
min="1" max="100"
value={weight}
onChange={(e) => setWeight(parseInt(e.target.value))}
className="w-full h-1.5 bg-medical-gray-200 rounded-lg appearance-none cursor-pointer accent-canino-blue"
/>
<div className="flex gap-2">
<button onClick={() => setPetType("young")} className={`flex-1 py-2 rounded-xl text-[10px] font-black transition-all ${petType === "young" ? 'bg-canino-blue text-white shadow-lg' : 'bg-white text-medical-gray-400'}`}>جوان</button>
<button onClick={() => setPetType("adult")} className={`flex-1 py-2 rounded-xl text-[10px] font-black transition-all ${petType === "adult" ? 'bg-canino-blue text-white shadow-lg' : 'bg-white text-medical-gray-400'}`}>بالغ</button>
<div className="text-left">
<div className="text-xl font-black font-vazir text-white">{toPersian(calculation.dailyDose)}</div>
<div className="text-[9px] font-bold text-white/80 font-vazir whitespace-nowrap">دوز روزانه ({calculation.unit === 'g' ? 'گرم' : calculation.unit})</div>
</div>
</div>
</div>
</div>
<div className="flex gap-4 mb-6">
{/* Quantity Selector - 40% Width */}
<div className="flex items-center gap-4 bg-medical-gray-50 border border-medical-gray-100 rounded-2xl p-2 h-16 w-[40%]">
<button
onClick={() => setItemQuantity(Math.max(1, itemQuantity - 1))}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white text-medical-gray-900 border border-medical-gray-200 hover:bg-canino-blue hover:text-white hover:border-canino-blue transition-all shadow-sm"
>
<Minus className="w-4 h-4" />
</button>
<span className="text-xl font-black text-medical-gray-900 flex-1 text-center font-vazir">
{toPersian(itemQuantity)}
</span>
<button
onClick={() => setItemQuantity(itemQuantity + 1)}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white text-medical-gray-900 border border-medical-gray-200 hover:bg-canino-blue hover:text-white hover:border-canino-blue transition-all shadow-sm"
>
<Plus className="w-4 h-4" />
</button>
</div>
{/* Manual Calculator (Mini) */}
<div className="bg-medical-gray-50 rounded-2xl p-6 border border-medical-gray-100 mb-8 space-y-6">
<div className="flex items-center justify-between">
<span className="text-[10px] font-black text-medical-gray-400 font-vazir">وزن پت (کیلوگرم)</span>
<span className="text-sm font-black text-canino-blue font-vazir">{toPersian(weight)}</span>
</div>
<input
type="range"
min="1" max="100"
value={weight}
onChange={(e) => setWeight(parseInt(e.target.value))}
className="w-full h-1.5 bg-medical-gray-200 rounded-lg appearance-none cursor-pointer accent-canino-blue"
/>
<div className="flex gap-2">
<button onClick={() => setPetType("young")} className={`flex-1 py-2 rounded-xl text-[10px] font-black transition-all ${petType === "young" ? 'bg-canino-blue text-white shadow-lg' : 'bg-white text-medical-gray-400'}`}>جوان</button>
<button onClick={() => setPetType("adult")} className={`flex-1 py-2 rounded-xl text-[10px] font-black transition-all ${petType === "adult" ? 'bg-canino-blue text-white shadow-lg' : 'bg-white text-medical-gray-400'}`}>بالغ</button>
</div>
</div>
{/* Add to Cart Button - 60% Width */}
<button
onClick={() => {
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
toast.success(`${toPersian(itemQuantity)} عدد ${product.name} به سبد خرید اضافه شد`);
}}
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-medical-gray-900 text-white rounded-2xl h-16 font-black text-sm hover:bg-canino-blue transition-all shadow-xl shadow-black/10 font-vazir whitespace-nowrap"
<div className="flex gap-4 mb-6">
{/* Quantity Selector - 40% Width */}
<div className="flex items-center gap-4 bg-medical-gray-50 border border-medical-gray-100 rounded-2xl p-2 h-16 w-[40%]">
<button
onClick={() => setItemQuantity(Math.max(1, itemQuantity - 1))}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white text-medical-gray-900 border border-medical-gray-200 hover:bg-canino-blue hover:text-white hover:border-canino-blue transition-all shadow-sm"
>
<ShoppingBag className="w-5 h-5 mb-1" />
افزودن به سبد خرید
<Minus className="w-4 h-4" />
</button>
</div>
<div className="mt-6 flex flex-col gap-3">
<div className="flex items-center gap-2 text-[10px] font-bold text-medical-gray-400 font-vazir">
<ShieldCheck className="w-4 h-4 text-green-500" />
ضمانت اصالت محصول (Made in Germany)
</div>
<div className="flex items-center gap-2 text-[10px] font-bold text-medical-gray-400 font-vazir">
<Clock className="w-4 h-4 text-canino-blue" />
آماده ارسال (تحویل حداکثر ۴۸ ساعت)
</div>
</div>
<span className="text-xl font-black text-medical-gray-900 flex-1 text-center font-vazir">
{toPersian(itemQuantity)}
</span>
<button
onClick={() => setItemQuantity(itemQuantity + 1)}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white text-medical-gray-900 border border-medical-gray-200 hover:bg-canino-blue hover:text-white hover:border-canino-blue transition-all shadow-sm"
>
<Plus className="w-4 h-4" />
</button>
</div>
{/* Add to Cart Button - 60% Width */}
<button
onClick={() => {
addItem(product, itemQuantity, { quantity: calculation.dailyDose, unit: calculation.unit });
toast.success(`${toPersian(itemQuantity)} عدد ${product.name} به سبد خرید اضافه شد`);
}}
className="w-[60%] flex items-center justify-center gap-1.5 px-4 bg-medical-gray-900 text-white rounded-2xl h-16 font-black text-sm hover:bg-canino-blue transition-all shadow-xl shadow-black/10 font-vazir whitespace-nowrap"
>
<ShoppingBag className="w-5 h-5 mb-1" />
افزودن به سبد خرید
</button>
</div>
<div className="mt-6 flex flex-col gap-3">
<div className="flex items-center gap-2 text-[10px] font-bold text-medical-gray-400 font-vazir">
<ShieldCheck className="w-4 h-4 text-green-500" />
ضمانت اصالت محصول (Made in Germany)
</div>
<div className="flex items-center gap-2 text-[10px] font-bold text-medical-gray-400 font-vazir">
<Clock className="w-4 h-4 text-canino-blue" />
آماده ارسال (تحویل حداکثر ۴۸ ساعت)
</div>
</div>
</div>
{/* expected results box */}
{product.expectedResults && (
<div className="bg-white rounded-[2.5rem] border border-medical-gray-200 p-8">
<h4 className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-6 font-vazir">تغییرات قابل انتظار</h4>
<div className="space-y-4">
{product.expectedResults.map((res, i) => {
const Icon = ICON_MAP[res.icon] || Sparkles;
return (
<div key={i} className="flex items-center gap-4 group">
<div className="w-10 h-10 bg-medical-gray-50 rounded-xl flex items-center justify-center text-canino-blue group-hover:bg-canino-blue group-hover:text-white transition-all">
<Icon className="w-5 h-5" />
</div>
<span className="text-xs font-bold text-medical-gray-700 font-vazir">{res.text}</span>
<h4 className="text-[10px] font-black text-medical-gray-400 uppercase tracking-widest mb-6 font-vazir">تغییرات قابل انتظار</h4>
<div className="space-y-4">
{product.expectedResults.map((res, i) => {
const Icon = ICON_MAP[res.icon] || Sparkles;
return (
<div key={i} className="flex items-center gap-4 group">
<div className="w-10 h-10 bg-medical-gray-50 rounded-xl flex items-center justify-center text-canino-blue group-hover:bg-canino-blue group-hover:text-white transition-all">
<Icon className="w-5 h-5" />
</div>
);
})}
</div>
<span className="text-xs font-bold text-medical-gray-700 font-vazir">{res.text}</span>
</div>
);
})}
</div>
</div>
)}
</div>
@@ -533,37 +533,37 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
</div>
<div className="grid lg:grid-cols-2 gap-8">
{product.relatedProducts.map(relId => {
const relProduct = allProducts.find(p => p.id === relId);
if (!relProduct) return null;
return (
<motion.div
{product.relatedProducts.map(relId => {
const relProduct = allProducts.find(p => p.id === relId);
if (!relProduct) return null;
return (
<motion.div
key={relId}
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
className="bg-white rounded-[3rem] p-8 border border-medical-gray-200 flex flex-col md:flex-row gap-8 items-center cursor-pointer hover:shadow-2xl transition-all"
onClick={() => router.push(`/shop/${relProduct.id}`)}
>
<div className="w-40 h-40 bg-medical-gray-50 rounded-[2rem] p-4 flex items-center justify-center">
<SafeImage src={relProduct.image} alt={relProduct.name} className="w-full h-full object-contain drop-shadow-xl" />
</div>
<div className="flex-1 text-center md:text-right">
<h4 className="text-xl font-black text-medical-gray-900 mb-2">{relProduct.name}</h4>
<p className="text-sm text-medical-gray-500 mb-6">{relProduct.description}</p>
<div className="flex items-center justify-center md:justify-start gap-4">
<span className="text-lg font-black text-canino-blue">{relProduct.price}</span>
<ArrowRight className="w-4 h-4 text-medical-gray-300" />
</div>
</div>
<div className="w-px h-24 bg-medical-gray-100 hidden md:block" />
<div className="flex items-center justify-center gap-1 group">
<span className="text-xs font-black text-medical-gray-400 group-hover:text-canino-blue transition-colors">مشاهده محصول مکمل</span>
<ChevronLeft className="w-4 h-4 text-medical-gray-300 group-hover:text-canino-blue group-hover:-translate-x-1 transition-all rtl:group-hover:translate-x-1" />
</div>
</motion.div>
);
})}
>
<div className="w-40 h-40 bg-medical-gray-50 rounded-[2rem] p-4 flex items-center justify-center">
<SafeImage src={relProduct.image} alt={relProduct.name} className="w-full h-full object-contain drop-shadow-xl" />
</div>
<div className="flex-1 text-center md:text-right">
<h4 className="text-xl font-black text-medical-gray-900 mb-2">{relProduct.name}</h4>
<p className="text-sm text-medical-gray-500 mb-6">{relProduct.description}</p>
<div className="flex items-center justify-center md:justify-start gap-4">
<span className="text-lg font-black text-canino-blue">{relProduct.price}</span>
<ArrowRight className="w-4 h-4 text-medical-gray-300" />
</div>
</div>
<div className="w-px h-24 bg-medical-gray-100 hidden md:block" />
<div className="flex items-center justify-center gap-1 group">
<span className="text-xs font-black text-medical-gray-400 group-hover:text-canino-blue transition-colors">مشاهده محصول مکمل</span>
<ChevronLeft className="w-4 h-4 text-medical-gray-300 group-hover:text-canino-blue group-hover:-translate-x-1 transition-all rtl:group-hover:translate-x-1" />
</div>
</motion.div>
);
})}
</div>
</section>
)}
@@ -573,59 +573,59 @@ export default function ProductPage({ productSlug }: { productSlug: string }) {
<AnimatePresence>
{showRefillModal && (
<div className="fixed inset-0 z-[100] flex items-center justify-center p-4">
<motion.div
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={() => setShowRefillModal(false)}
className="absolute inset-0 bg-medical-gray-900/60 backdrop-blur-md"
/>
<motion.div
/>
<motion.div
initial={{ opacity: 0, scale: 0.9, y: 20 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.9, y: 20 }}
className="bg-white w-full max-w-lg rounded-[3rem] p-10 relative z-10 shadow-2xl overflow-hidden"
>
<div className="absolute top-0 left-0 w-full h-2 bg-gradient-to-r from-canino-blue via-blue-400 to-canino-blue" />
<button
onClick={() => setShowRefillModal(false)}
className="absolute top-6 left-6 text-medical-gray-400 hover:text-medical-gray-600 transition-colors"
>
<X className="w-6 h-6" />
</button>
>
<div className="absolute top-0 left-0 w-full h-2 bg-gradient-to-r from-canino-blue via-blue-400 to-canino-blue" />
<button
onClick={() => setShowRefillModal(false)}
className="absolute top-6 left-6 text-medical-gray-400 hover:text-medical-gray-600 transition-colors"
>
<X className="w-6 h-6" />
</button>
<div className="text-center">
<div className="w-20 h-20 bg-canino-blue/10 rounded-[2rem] flex items-center justify-center mx-auto mb-8">
<Bell className="w-10 h-10 text-canino-blue animate-bounce" />
</div>
<h3 className="text-3xl font-black text-medical-gray-900 mb-4 leading-tight italic">سیستم یادآوری هوشمند</h3>
<div className="bg-medical-gray-50 border border-medical-gray-100 rounded-3xl p-6 mb-8 text-right">
<p className="text-medical-gray-700 leading-relaxed font-medium font-vazir">
بر اساس وزن <span className="text-canino-blue font-bold">{toPersian(weight)} کیلوگرمی</span> {activePet ? `برای ${activePet.name}` : 'سگ شما'}، این بسته {toPersian(product.packageSize)} تایی دقیقاً <span className="text-canino-blue font-bold">{toPersian(calculation.duration)} روز</span> دیگر تمام می‌شود.
</p>
<div className="mt-4 flex items-center gap-2 text-xs font-bold text-medical-gray-500 font-vazir">
<ShieldCheck className="w-4 h-4 text-green-500" />
آیا مایلید سیستم ۵ روز قبل از اتمام، به شما پیامک یادآوری ارسال کند؟
</div>
</div>
<div className="flex flex-col gap-3">
<button
onClick={() => setShowRefillModal(false)}
className="w-full bg-canino-blue text-white py-5 rounded-2xl font-black text-lg hover:shadow-xl hover:shadow-canino-blue/20 transition-all flex items-center justify-center gap-2"
>
<CheckCircle2 className="w-5 h-5" />
بله، پیامک یادآوری فعال شود
</button>
<button
onClick={() => setShowRefillModal(false)}
className="w-full py-4 text-medical-gray-400 font-bold text-sm hover:text-medical-gray-600 transition-colors"
>
خیر، فقط محصول را به سبد خرید اضافه کن
</button>
<div className="text-center">
<div className="w-20 h-20 bg-canino-blue/10 rounded-[2rem] flex items-center justify-center mx-auto mb-8">
<Bell className="w-10 h-10 text-canino-blue animate-bounce" />
</div>
<h3 className="text-3xl font-black text-medical-gray-900 mb-4 leading-tight italic">سیستم یادآوری هوشمند</h3>
<div className="bg-medical-gray-50 border border-medical-gray-100 rounded-3xl p-6 mb-8 text-right">
<p className="text-medical-gray-700 leading-relaxed font-medium font-vazir">
بر اساس وزن <span className="text-canino-blue font-bold">{toPersian(weight)} کیلوگرمی</span> {activePet ? `برای ${activePet.name}` : 'سگ شما'}، این بسته {toPersian(product.packageSize)} تایی دقیقاً <span className="text-canino-blue font-bold">{toPersian(calculation.duration)} روز</span> دیگر تمام می‌شود.
</p>
<div className="mt-4 flex items-center gap-2 text-xs font-bold text-medical-gray-500 font-vazir">
<ShieldCheck className="w-4 h-4 text-green-500" />
آیا مایلید سیستم ۵ روز قبل از اتمام، به شما پیامک یادآوری ارسال کند؟
</div>
</div>
</motion.div>
<div className="flex flex-col gap-3">
<button
onClick={() => setShowRefillModal(false)}
className="w-full bg-canino-blue text-white py-5 rounded-2xl font-black text-lg hover:shadow-xl hover:shadow-canino-blue/20 transition-all flex items-center justify-center gap-2"
>
<CheckCircle2 className="w-5 h-5" />
بله، پیامک یادآوری فعال شود
</button>
<button
onClick={() => setShowRefillModal(false)}
className="w-full py-4 text-medical-gray-400 font-bold text-sm hover:text-medical-gray-600 transition-colors"
>
خیر، فقط محصول را به سبد خرید اضافه کن
</button>
</div>
</div>
</motion.div>
</div>
)}
</AnimatePresence>
@@ -2,15 +2,15 @@
import React, { useState } from "react";
import { motion, AnimatePresence } from "motion/react";
import { useSettingsStore } from "../lib/store/settingsStore";
import {
Dog,
Cat,
ChevronLeft,
ChevronRight,
ShieldCheck,
Activity,
Bone,
Sparkles,
import {
Dog,
Cat,
ChevronLeft,
ChevronRight,
ShieldCheck,
Activity,
Bone,
Sparkles,
Pill,
Sparkle
} from "lucide-react";
@@ -53,7 +53,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
}, [texts]);
const [step, setStep] = useState(1);
// Step 1 Data
const [name, setName] = useState("");
const [type, setType] = useState<"سگ" | "گربه">("سگ");
@@ -71,7 +71,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
const handleBack = () => setStep(s => s - 1);
const handleSubmit = () => {
const data = {
const data = {
name, type, breed, age, weight, activityLevel, medicalConditions
};
if (onComplete) {
@@ -92,7 +92,7 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
<section id="canino-advisor" className="py-24 bg-white">
<div className="max-w-4xl mx-auto px-4">
<div className="text-center mb-12">
<motion.div
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
className="inline-flex items-center gap-2 px-4 py-2 bg-canino-blue/5 rounded-full mb-6"
@@ -100,24 +100,24 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
<Sparkle className="w-4 h-4 text-canino-blue" />
<span className="text-canino-blue text-xs font-black uppercase tracking-widest font-vazir">تکنولوژی پایش هوشمند</span>
</motion.div>
<h2 className="text-4xl lg:text-5xl font-black text-medical-gray-900 mb-4 font-vazir italic">دستیار سلامت کانی‌نو</h2>
<h2 className="text-4xl lg:text-5xl font-black text-medical-gray-900 mb-4 font-vazir italic">دستیار سلامت کانینو</h2>
<p className="text-medical-gray-600 font-bold text-lg font-vazir">فقط چند قدم تا صدور شناسنامه هوشمند و دریافت پیشنهادات تخصصی</p>
</div>
<div className="bg-medical-gray-50 rounded-[3.5rem] border border-medical-gray-100 p-8 lg:p-12 shadow-2xl shadow-medical-gray-200/50 relative overflow-hidden">
{/* Progress Indicator */}
<div className="absolute top-0 left-0 w-full h-2 bg-medical-gray-200">
<motion.div
className="h-full bg-canino-blue"
<motion.div
className="h-full bg-canino-blue"
initial={{ width: "0%" }}
animate={{ width: `${(step / 3) * 100}%` }}
transition={{ duration: 0.5 }}
/>
</div>
<AnimatePresence mode="wait">
{step === 1 && (
<motion.div
<motion.div
key="step1"
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
@@ -128,16 +128,16 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">گام اول: هویت بصری</h3>
<p className="text-medical-gray-600 font-bold font-vazir">همدم شما رو با چه اسمی صدا می‌زنید؟</p>
</div>
<div className="grid grid-cols-2 gap-4">
<button
<button
onClick={() => setType("سگ")}
className={`flex flex-col items-center gap-4 p-8 rounded-[2.5rem] border-4 transition-all focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none ${type === "سگ" ? 'border-canino-blue bg-white shadow-xl shadow-canino-blue/10 scale-105' : 'border-transparent bg-white/50 text-medical-gray-400 hover:bg-white'}`}
>
<Dog className={`w-12 h-12 ${type === "سگ" ? 'text-canino-blue' : 'text-current'}`} />
<span className="text-lg font-black font-vazir">سگ</span>
</button>
<button
<button
onClick={() => setType("گربه")}
className={`flex flex-col items-center gap-4 p-8 rounded-[2.5rem] border-4 transition-all focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none ${type === "گربه" ? 'border-canino-blue bg-white shadow-xl shadow-canino-blue/10 scale-105' : 'border-transparent bg-white/50 text-medical-gray-400 hover:bg-white'}`}
>
@@ -145,12 +145,12 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
<span className="text-lg font-black font-vazir">گربه</span>
</button>
</div>
<div className="grid md:grid-cols-2 gap-6">
<div className="space-y-2">
<label className="text-xs font-black text-medical-gray-600 pr-2">نام پت</label>
<input
type="text"
<input
type="text"
value={name}
onChange={e => setName(e.target.value)}
placeholder="لوسی، تدی..."
@@ -159,8 +159,8 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
</div>
<div className="space-y-2">
<label className="text-xs font-black text-medical-gray-600 pr-2">نژاد</label>
<input
type="text"
<input
type="text"
value={breed}
onChange={e => setBreed(e.target.value)}
placeholder="ژرمن، پرشین..."
@@ -168,11 +168,11 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
/>
</div>
</div>
<button
<button
onClick={handleNext}
disabled={!name || !breed}
className="w-full py-6 bg-medical-gray-900 text-white rounded-3xl font-black text-lg hover:bg-canino-blue focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-medical-gray-900/10 flex items-center justify-center gap-3 font-vazir disabled:bg-medical-gray-200 disabled:text-medical-gray-500 disabled:cursor-not-allowed disabled:shadow-none min-h-[48px]"
className="w-full py-6 bg-medical-gray-900 text-white rounded-3xl font-black text-lg hover:bg-canino-blue focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-medical-gray-900/10 flex items-center justify-center gap-3 font-vazir disabled:bg-gray-300 disabled:text-gray-500 disabled:cursor-not-allowed disabled:shadow-none min-h-[48px] disabled:border disabled:border-gray-400"
>
ثبت هویت و ادامه
<ChevronLeft className="w-5 h-5" />
@@ -184,9 +184,9 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
)}
</motion.div>
)}
{step === 2 && (
<motion.div
<motion.div
key="step2"
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
@@ -197,31 +197,31 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">گام دوم: پایش فیزیکی</h3>
<p className="text-medical-gray-600 font-bold font-vazir">اطلاعات فیزیکی دقیق به دوزبندی صحیح مکمل‌ها کمک می‌کند</p>
</div>
<div className="grid grid-cols-2 gap-6">
<div className="space-y-4">
<label className="block text-center text-xs font-black text-medical-gray-600 uppercase tracking-widest font-vazir">سن (سال)</label>
<div className="flex items-center gap-4 bg-white rounded-3xl p-2 border border-medical-gray-200">
<label className="block text-center text-xs font-black text-medical-gray-600 uppercase tracking-widest font-vazir">سن حیوان <span className="normal-case">(سال)</span></label>
<div className="flex items-center gap-4 bg-white rounded-3xl p-2 border-2 border-medical-gray-200">
<button onClick={() => setAge(Math.max(0, age - 1))} className="w-12 h-12 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canino-blue hover:text-white focus-visible:ring-2 focus-visible:ring-canino-blue focus-visible:outline-none transition-all shadow-sm font-black text-lg">-</button>
<span className="flex-1 text-center text-2xl font-black text-canino-blue font-vazir">{toPersian(age.toString())}</span>
<span className="flex-1 text-center text-2xl font-black text-canino-blue font-vazir">{toPersian(age.toString())} <span className="text-sm font-bold text-medical-gray-400">سال</span></span>
<button onClick={() => setAge(age + 1)} className="w-12 h-12 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canino-blue hover:text-white focus-visible:ring-2 focus-visible:ring-canino-blue focus-visible:outline-none transition-all shadow-sm font-black text-lg">+</button>
</div>
</div>
<div className="space-y-4">
<label className="block text-center text-xs font-black text-medical-gray-600 uppercase tracking-widest font-vazir">وزن (کیلوگرم)</label>
<div className="flex items-center gap-4 bg-white rounded-3xl p-2 border border-medical-gray-200">
<label className="block text-center text-xs font-black text-medical-gray-600 uppercase tracking-widest font-vazir">وزن حیوان <span className="normal-case">(کیلوگرم)</span></label>
<div className="flex items-center gap-4 bg-white rounded-3xl p-2 border-2 border-medical-gray-200">
<button onClick={() => setWeight(Math.max(1, weight - 1))} className="w-12 h-12 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canino-blue hover:text-white focus-visible:ring-2 focus-visible:ring-canino-blue focus-visible:outline-none transition-all shadow-sm font-black text-lg">-</button>
<span className="flex-1 text-center text-2xl font-black text-canino-blue font-vazir">{toPersian(weight.toString())}</span>
<span className="flex-1 text-center text-2xl font-black text-canino-blue font-vazir">{toPersian(weight.toString())} <span className="text-sm font-bold text-medical-gray-400">kg</span></span>
<button onClick={() => setWeight(weight + 1)} className="w-12 h-12 flex items-center justify-center bg-medical-gray-50 rounded-xl text-medical-gray-900 hover:bg-canino-blue hover:text-white focus-visible:ring-2 focus-visible:ring-canino-blue focus-visible:outline-none transition-all shadow-sm font-black text-lg">+</button>
</div>
</div>
</div>
<div className="space-y-4">
<label className="block text-center text-xs font-black text-medical-gray-600 uppercase tracking-widest font-vazir">سطح فعالیت روزانه</label>
<div className="grid grid-cols-3 gap-3">
{["کم", "متوسط", "زیاد"].map(level => (
<button
<button
key={level}
onClick={() => setActivityLevel(level as any)}
className={`py-4 rounded-2xl border-2 transition-all font-black italic focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none min-h-[48px] ${activityLevel === level ? 'border-canino-blue bg-white text-canino-blue shadow-lg' : 'border-transparent bg-white/50 text-medical-gray-500 hover:bg-white'}`}
@@ -231,16 +231,16 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
))}
</div>
</div>
<div className="flex gap-4 pt-4">
<button
<button
onClick={handleBack}
className="flex-1 py-6 bg-medical-gray-100 text-medical-gray-600 rounded-3xl font-black text-lg hover:bg-medical-gray-200 focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all flex items-center justify-center gap-3 font-vazir min-h-[48px]"
>
<ChevronRight className="w-5 h-5" />
قبلی
</button>
<button
<button
onClick={handleNext}
className="flex-[2] py-6 bg-medical-gray-900 text-white rounded-3xl font-black text-lg hover:bg-canino-blue focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-medical-gray-900/10 flex items-center justify-center gap-3 font-vazir min-h-[48px]"
>
@@ -250,9 +250,9 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
</div>
</motion.div>
)}
{step === 3 && (
<motion.div
<motion.div
key="step3"
initial={{ opacity: 0, x: 20 }}
animate={{ opacity: 1, x: 0 }}
@@ -263,13 +263,13 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
<h3 className="text-2xl font-black text-medical-gray-900 mb-2 font-vazir uppercase italic tracking-tight">گام آخر: سوابق و حساسیت‌ها</h3>
<p className="text-medical-gray-600 font-bold font-vazir">در صورت وجود هر یک از موارد زیر، آن را تیک بزنید</p>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
{medicalOptions.map((opt) => (
<button
<button
key={opt.id}
onClick={() => {
setMedicalConditions(prev =>
setMedicalConditions(prev =>
prev.includes(opt.condition) ? prev.filter(c => c !== opt.condition) : [...prev, opt.condition]
);
}}
@@ -282,16 +282,16 @@ export default function SmartAdvisor({ onComplete, rules = [] }: SmartAdvisorPro
</button>
))}
</div>
<div className="flex gap-4 pt-4">
<button
<button
onClick={handleBack}
className="flex-1 py-6 bg-medical-gray-100 text-medical-gray-600 rounded-3xl font-black text-lg hover:bg-medical-gray-200 focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all flex items-center justify-center gap-3 font-vazir min-h-[48px]"
>
<ChevronRight className="w-5 h-5" />
قبلی
</button>
<button
<button
onClick={handleSubmit}
className="flex-[2] py-6 bg-canino-blue text-white rounded-3xl font-black text-lg hover:bg-indigo-700 focus-visible:ring-4 focus-visible:ring-canino-blue/30 focus-visible:outline-none transition-all shadow-xl shadow-canino-blue/20 flex items-center justify-center gap-3 font-vazir min-h-[48px]"
>
@@ -59,14 +59,14 @@ export default function TopUpModal({ isOpen, onClose, onConfirm }: TopUpModalPro
<AnimatePresence>
{isOpen && (
<div className="fixed inset-0 z-[110] flex items-center justify-center p-4">
<motion.div
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
onClick={onClose}
className="absolute inset-0 bg-medical-gray-900/60 backdrop-blur-md"
/>
<motion.div
<motion.div
initial={{ opacity: 0, scale: 0.9, y: 20 }}
animate={{ opacity: 1, scale: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.9, y: 20 }}
@@ -80,7 +80,7 @@ export default function TopUpModal({ isOpen, onClose, onConfirm }: TopUpModalPro
</div>
<h3 className="text-xl font-black text-medical-gray-900 italic">شارژ سریع کیف پول</h3>
</div>
<button
<button
onClick={onClose}
className="w-10 h-10 flex items-center justify-center rounded-xl bg-white border border-medical-gray-200 text-medical-gray-400 hover:text-red-500 transition-all"
>
@@ -99,8 +99,8 @@ export default function TopUpModal({ isOpen, onClose, onConfirm }: TopUpModalPro
onClick={() => handlePresetSelect(preset.value)}
className={cn(
"px-6 py-3 rounded-2xl text-sm font-black transition-all border",
selectedPreset === preset.value
? "bg-canino-blue text-white border-canino-blue shadow-lg shadow-canino-blue/20"
selectedPreset === preset.value
? "bg-canino-blue text-white border-canino-blue shadow-lg shadow-canino-blue/20"
: "bg-white text-medical-gray-700 border-medical-gray-100 hover:border-canino-blue"
)}
>
@@ -128,8 +128,8 @@ export default function TopUpModal({ isOpen, onClose, onConfirm }: TopUpModalPro
</div>
<div className="bg-blue-50 border border-blue-100 rounded-2xl p-4 flex gap-3">
<Sparkles className="w-5 h-5 text-canino-blue shrink-0" />
<p className="text-[10px] font-bold text-canino-blue leading-relaxed">با شارژ کیف پول، از هدیه‌های هوشمند کانی‌نو و اولویت در ارسال سفارش‌ها بهره‌مند شوید.</p>
<Sparkles className="w-5 h-5 text-canino-blue shrink-0" />
<p className="text-[10px] font-bold text-canino-blue leading-relaxed">با شارژ کیف پول، از هدیه‌های هوشمند کانینو و اولویت در ارسال سفارش‌ها بهره‌مند شوید.</p>
</div>
<button
@@ -19,13 +19,13 @@ export default function UserDashboard() {
const { profile, logout, addAddress, updateAddress, deleteAddress, setDefaultAddress, topUpWallet } = useUserStore();
const { orders } = useCartStore();
const [activeTab, setActiveTab] = React.useState<"profile" | "orders" | "wallet" | "addresses">("profile");
const [isLoadingOrders, setIsLoadingOrders] = useState(true);
const [isLoadingOrders, setIsLoadingOrders] = useState(false);
// Fetch fresh profile data (which includes orders) whenever orders tab is opened
React.useEffect(() => {
if (activeTab === "orders") {
setIsLoadingOrders(true);
const timer = setTimeout(() => setIsLoadingOrders(false), 800);
return () => clearTimeout(timer);
useUserStore.getState().fetchProfile().finally(() => setIsLoadingOrders(false));
}
}, [activeTab]);
const [selectedOrder, setSelectedOrder] = useState<any>(null);
+83 -83
View File
@@ -97,9 +97,9 @@ export const INGREDIENTS_WIKI: IngredientInfo[] = [
name: "عصاره پیت (Peat Extract)",
description: "ماده‌ای کاملا طبیعی حاصل از تجزیه گیاهان در طول هزاران سال که غنی از اسیدهای هومیک و مواد معدنی است.",
benefits: [
"جذب سموم در دستگاه گوارش",
"تنظیم فلور روده",
"بهبود اشتها و هضم"
"جذب سموم در دستگاه گوارش",
"تنظیم فلور روده",
"بهبود اشتها و هضم"
]
}
];
@@ -139,19 +139,19 @@ export const PRODUCTS: Product[] = [
onSetOfAction: "هفته چهارم",
optimisticTemplate: "[PetName] از [OnSet] با نشاط بیشتری می‌دود و بازی می‌کند.",
expectedResults: [
{ icon: "Sparkles", text: "استحکام مفاصل" },
{ icon: "Activity", text: "حرکت بدون درد" },
{ icon: "ShieldCheck", text: "دندان‌های قوی" }
{ icon: "Sparkles", text: "استحکام مفاصل" },
{ icon: "Activity", text: "حرکت بدون درد" },
{ icon: "ShieldCheck", text: "دندان‌های قوی" }
],
calculateDosage: (weight, isYoung) => {
const rate = isYoung ? 2 : 4;
let qty = (weight / 10) * rate;
qty = Math.min(qty, 16);
return {
quantity: Number(qty.toFixed(1)),
unit: "قرص",
description: isYoung ? "دوز رشد (تا ۱۵ ماهگی)" : "دوز حمایتی / سگ کاری"
};
const rate = isYoung ? 2 : 4;
let qty = (weight / 10) * rate;
qty = Math.min(qty, 16);
return {
quantity: Number(qty.toFixed(1)),
unit: "قرص",
description: isYoung ? "دوز رشد (تا ۱۵ ماهگی)" : "دوز حمایتی / سگ کاری"
};
},
analysis: { "کلسیم": "۱۸.۲٪", "فسفر": "۷.۱٪", "پروتئین": "۱۲.۴٪" },
feedingAdvice: "قرص‌ها را می‌توان مستقیماً در دهان قرار داد یا با غذای روزانه مخلوط کرد.",
@@ -195,17 +195,17 @@ export const PRODUCTS: Product[] = [
onSetOfAction: "روز سوم",
optimisticTemplate: "[PetName] تنها پس از [OnSet] انرژی از دست رفته‌اش را دوباره به دست می‌آورد.",
expectedResults: [
{ icon: "Heart", text: "تقویت ایمنی" },
{ icon: "Flame", text: "رفع خستگی" },
{ icon: "Zap", text: "هوشیاری بیشتر" }
{ icon: "Heart", text: "تقویت ایمنی" },
{ icon: "Flame", text: "رفع خستگی" },
{ icon: "Zap", text: "هوشیاری بیشتر" }
],
calculateDosage: (weight, isYoung) => {
let ml = 0.25;
if (isYoung) ml = 0.25;
else if (weight < 5) ml = 0.5;
else if (weight <= 10) ml = 1;
else ml = 2;
return { quantity: ml, unit: "میلی‌لیتر", description: "خمیر را روی زبان قرار دهید" };
let ml = 0.25;
if (isYoung) ml = 0.25;
else if (weight < 5) ml = 0.5;
else if (weight <= 10) ml = 1;
else ml = 2;
return { quantity: ml, unit: "میلی‌لیتر", description: "خمیر را روی زبان قرار دهید" };
},
analysis: { "چربی": "۶۵٪", "پروتئین": "۱۵٪" },
feedingAdvice: "توصیه می‌شود در زمان‌های استرس (واکسیناسیون، جابجایی) استفاده شود.",
@@ -243,17 +243,17 @@ export const PRODUCTS: Product[] = [
onSetOfAction: "هفته دوم",
optimisticTemplate: "لبخند سفیدتر و نفس تازه‌تر [PetName] از [OnSet] نمایان می‌شود.",
expectedResults: [
{ icon: "Sparkles", text: "رفع بوی دهان" },
{ icon: "ShieldCheck", text: "کاهش جرم" },
{ icon: "Heart", text: "لثه‌های سالم" }
{ icon: "Sparkles", text: "رفع بوی دهان" },
{ icon: "ShieldCheck", text: "کاهش جرم" },
{ icon: "Heart", text: "لثه‌های سالم" }
],
calculateDosage: (weight) => {
let cm = 1;
if (weight <= 10) cm = 1;
else if (weight <= 20) cm = 2;
else if (weight <= 30) cm = 3;
else cm = 4;
return { quantity: cm, unit: "سانتی‌متر", description: "روی لثه‌ها ماساژ دهید" };
let cm = 1;
if (weight <= 10) cm = 1;
else if (weight <= 20) cm = 2;
else if (weight <= 30) cm = 3;
else cm = 4;
return { quantity: cm, unit: "سانتی‌متر", description: "روی لثه‌ها ماساژ دهید" };
},
analysis: { "نقره": "بسیار بالا" },
feedingAdvice: "تا ۳۰ دقیقه بعد از استفاده، پت نباید آب یا غذا بخورد.",
@@ -286,22 +286,22 @@ export const PRODUCTS: Product[] = [
onSetOfAction: "روز چهارم",
optimisticTemplate: "سیستم گوارشی [PetName] از حدود [OnSet] شروع به تنظیم مجدد و دفع راحت‌تر می‌کند.",
expectedResults: [
{ icon: "ShieldCheck", text: "دفع منظم" },
{ icon: "Activity", text: "کاهش التهاب روده" },
{ icon: "Sparkles", text: "کنترل بوی مدفوع" }
{ icon: "ShieldCheck", text: "دفع منظم" },
{ icon: "Activity", text: "کاهش التهاب روده" },
{ icon: "Sparkles", text: "کنترل بوی مدفوع" }
],
calculateDosage: (weight) => {
let g = weight * 0.5;
g = Math.min(g, 15);
return { quantity: Number(g.toFixed(1)), unit: "گرم", description: "با غذا مخلوط شود" };
let g = weight * 0.5;
g = Math.min(g, 15);
return { quantity: Number(g.toFixed(1)), unit: "گرم", description: "با غذا مخلوط شود" };
},
analysis: { "فیبر": "۲۵٪" },
feedingAdvice: "بهتر است با آب ولرم خیسانده و سپس با غذا مخلوط شود.",
specialist: {
name: "دکتر بایر",
title: "گاستروانترولوژیست",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "فیبر سیب منبع پکتین است که به رشد باکتری‌های مفید روده کمک شایانی می‌کند."
name: "دکتر بایر",
title: "گاستروانترولوژیست",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "فیبر سیب منبع پکتین است که به رشد باکتری‌های مفید روده کمک شایانی می‌کند."
},
image: "https://www.canina.de/media/4c/32/38/1715077271/Ballaststoff-Mix-140108-V1-Canino-100g_600x600.webp"
},
@@ -331,14 +331,14 @@ export const PRODUCTS: Product[] = [
onSetOfAction: "هفته سوم",
optimisticTemplate: "شاهد درخشش خیره‌کننده در پوشش موی [PetName] از [OnSet] باشید.",
expectedResults: [
{ icon: "Sparkles", text: "موی براق‌تر" },
{ icon: "Heart", text: "پوست سالم" },
{ icon: "ShieldCheck", text: "کاهش ریزش" }
{ icon: "Sparkles", text: "موی براق‌تر" },
{ icon: "Heart", text: "پوست سالم" },
{ icon: "ShieldCheck", text: "کاهش ریزش" }
],
calculateDosage: (weight) => {
let ml = (weight / 10) * 2;
ml = Math.min(ml, 10);
return { quantity: Number(ml.toFixed(1)), unit: "میلی‌لیتر", description: "دوز روزانه" };
let ml = (weight / 10) * 2;
ml = Math.min(ml, 10);
return { quantity: Number(ml.toFixed(1)), unit: "میلی‌لیتر", description: "دوز روزانه" };
},
analysis: { "چربی خام": "۹۹٪" },
feedingAdvice: "روزانه به غذای اصلی پت اضافه شود.",
@@ -374,17 +374,17 @@ export const PRODUCTS: Product[] = [
symptoms: ["نفس‌نفس زدن", "خستگی", "سن بالا"],
suitableFor: "هر دو",
calculateDosage: (weight) => {
let tsp = (weight / 10) * 0.5;
tsp = Math.min(tsp, 3);
return { quantity: Number(tsp.toFixed(1)), unit: "قاشق چایخوری", description: "معادل " + (tsp * 3).toFixed(1) + " میلی‌لیتر" };
let tsp = (weight / 10) * 0.5;
tsp = Math.min(tsp, 3);
return { quantity: Number(tsp.toFixed(1)), unit: "قاشق چایخوری", description: "معادل " + (tsp * 3).toFixed(1) + " میلی‌لیتر" };
},
analysis: { "ال-کارنیتین": "۳۰۰۰۰mg" },
feedingAdvice: "قبل از مصرف تکان دهید.",
specialist: {
name: "دکتر مایر",
title: "کاردیولوژیست دامپزشکی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "زالزالک جریان خون کرونر را بهبود بخشیده و فشار بر قلب را کاهش می‌دهد."
name: "دکتر مایر",
title: "کاردیولوژیست دامپزشکی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "زالزالک جریان خون کرونر را بهبود بخشیده و فشار بر قلب را کاهش می‌دهد."
},
image: "https://www.canina.de/media/73/6e/8b/1715077271/Herz-Vital-111858-V1-Canino-100ml_600x600.webp"
},
@@ -409,22 +409,22 @@ export const PRODUCTS: Product[] = [
onSetOfAction: "بلافاصله",
optimisticTemplate: "[PetName] بلافاصله پس از مصرف انرژی مضاعفی برای فعالیت‌های روزانه پیدا می‌کند.",
expectedResults: [
{ icon: "Zap", text: "رفع فوری خستگی" },
{ icon: "Activity", text: "بهبود اشتها" },
{ icon: "Heart", text: "نشاط متابولیک" }
{ icon: "Zap", text: "رفع فوری خستگی" },
{ icon: "Activity", text: "بهبود اشتها" },
{ icon: "Heart", text: "نشاط متابولیک" }
],
calculateDosage: (weight) => {
let qty = Math.max(1, weight / 10);
qty = Math.min(qty, 4);
return { quantity: Math.round(qty), unit: "قاشق چایخوری", description: "بمب انرژی" };
let qty = Math.max(1, weight / 10);
qty = Math.min(qty, 4);
return { quantity: Math.round(qty), unit: "قاشق چایخوری", description: "بمب انرژی" };
},
analysis: { "ویتامین B1": "400mg" },
feedingAdvice: "به دلیل غلظت بالا، به تنهایی یا با غذا داده شود.",
specialist: {
name: "دکتر اشمیت",
title: "متخصص تغذیه بالینی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "این ژل برای پت‌هایی که در شرایط بحرانی نیاز به کالری فوزی دارند بی‌نظیر است."
name: "دکتر اشمیت",
title: "متخصص تغذیه بالینی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "این ژل برای پت‌هایی که در شرایط بحرانی نیاز به کالری فوزی دارند بی‌نظیر است."
},
image: "https://www.canina.de/media/cc/e0/75/1715077271/Petvital-Energy-Gel-111452-V1-Canino-100g_600x600.webp"
},
@@ -452,25 +452,25 @@ export const PRODUCTS: Product[] = [
symptoms: ["اسهال", "سم‌زدایی", "تقویت روده"],
suitableFor: "هر دو",
calculateDosage: (weight) => {
let ml = 2.5;
if (weight <= 5) ml = 2.5;
else if (weight <= 10) ml = 5;
else if (weight <= 20) ml = 10;
else ml = 20;
return { quantity: ml, unit: "میلی‌لیتر", description: "قبل از مصرف تکان دهید" };
let ml = 2.5;
if (weight <= 5) ml = 2.5;
else if (weight <= 10) ml = 5;
else if (weight <= 20) ml = 10;
else ml = 20;
return { quantity: ml, unit: "میلی‌لیتر", description: "قبل از مصرف تکان دهید" };
},
analysis: { "اسید هومیک": "بالا" },
feedingAdvice: "روزانه با آب آشامیدنی یا غذا مخلوط شود.",
specialist: {
name: "دکتر کوخ",
title: "متخصص گوارش دامپزشکی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "اسیدهای هومیک سموم را در روده به دام انداخته و دفع می‌کنند."
name: "دکتر کوخ",
title: "متخصص گوارش دامپزشکی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "اسیدهای هومیک سموم را در روده به دام انداخته و دفع می‌کنند."
},
image: "https://www.canina.de/media/89/3b/bc/112404_Moortraenke_Canina-Pharma_1280x1280.png",
faqs: [
{ question: "آیا برای اسهال مزمن موثر است؟", answer: "بله، اسیدهای هومیک موجود در این محصول با ایجاد لایه محافظ روی مخاط روده و جذب سموم، به سرعت وضعیت دفع را بهبود می‌بخند." },
{ question: "نحوه نگهداری محصول چگونه است؟", answer: "پس از باز شدن درب، در جای خنک (یخچال نباشد) نگهداری شود و قبل از هر بار مصرف به خوبی تکان دهید." }
{ question: "آیا برای اسهال مزمن موثر است؟", answer: "بله، اسیدهای هومیک موجود در این محصول با ایجاد لایه محافظ روی مخاط روده و جذب سموم، به سرعت وضعیت دفع را بهبود می‌بخند." },
{ question: "نحوه نگهداری محصول چگونه است؟", answer: "پس از باز شدن درب، در جای خنک (یخچال نباشد) نگهداری شود و قبل از هر بار مصرف به خوبی تکان دهید." }
]
},
{
@@ -498,16 +498,16 @@ export const PRODUCTS: Product[] = [
suitableFor: "سگ",
contraindications: ["برای سگ‌های باردار استفاده نشود", "برای سگ‌های شیرده استفاده نشود"],
calculateDosage: (weight) => {
const ml = weight * 0.3;
return { quantity: Number(ml.toFixed(1)), unit: "میلی‌لیتر", description: "به همراه غذا میل شود" };
const ml = weight * 0.3;
return { quantity: Number(ml.toFixed(1)), unit: "میلی‌لیتر", description: "به همراه غذا میل شود" };
},
analysis: { "چربی خالص": "۱۰۰٪" },
feedingAdvice: "به دلیل غلظت بالای تیموکینون، دقیقاً مطابق دوز مصرف شود.",
specialist: {
name: "دکتر مونیخ",
title: "متخصص طب طبیعی دامپزشکی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "روغن سیاه دانه مصری کانی‌نو حاوی مقادیر بالایی اسیدهای چرب چند غیراشباع است."
name: "دکتر مونیخ",
title: "متخصص طب طبیعی دامپزشکی",
image: "https://images.unsplash.com/photo-1559839734-2b71f1536783?auto=format&fit=crop&q=80&w=200",
message: "روغن سیاه دانه مصری کانینو حاوی مقادیر بالایی اسیدهای چرب چند غیراشباع است."
},
image: "https://www.canina.de/media/1b/83/7d/1715077272/Schwarz-Kuemmel-112503-V1-Canino-250ml_600x600.webp"
}
+2 -2
View File
@@ -88,8 +88,8 @@ export const useCartStore = create<CartStore>()(
applyCoupon: async (code) => {
try {
const cleanCode = code.toUpperCase().trim();
// Assuming API returns { discountValue: number } or similar
const response = await api.post('/cart/apply-coupon', { code: cleanCode });
const subtotal = get().getSubtotal();
const response = await api.post('/orders/validate-coupon', { code: cleanCode, cartTotal: subtotal });
if (response.data && response.data.discountValue) {
set({ coupon: { code: cleanCode, discount: response.data.discountValue } });
return true;
+2 -2
View File
@@ -1,11 +1,11 @@
{
"name": "caninairan-workspace",
"name": "caninoiran-workspace",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "caninairan-workspace",
"name": "caninoiran-workspace",
"version": "1.0.0",
"devDependencies": {
"concurrently": "^8.2.2"