From 3dedc89ee15af61c64fc7a4590c7bce14e37155a Mon Sep 17 00:00:00 2001 From: parsa aghaei Date: Sat, 11 Jul 2026 12:30:17 +0330 Subject: [PATCH] =?UTF-8?q?=D8=AA=D8=BA=DB=8C=DB=8C=D8=B1=D8=A7=D8=AA=20?= =?UTF-8?q?=DA=A9=D9=84=DB=8C=20=D8=AF=D8=B1=20backend=20=D9=88=20frontend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BACKEND_INTEGRATION.md | 2 +- DATABASE_SCHEMA.md | 6 +- README.md | 4 +- backend/prisma/seed-products.ts | 124 +- backend/prisma/seed.ts | 2 +- backend/src/admin/admin.module.ts | 3 +- backend/src/admin/admin.service.ts | 20 +- backend/src/app.module.ts | 7 + backend/src/auth/auth.service.spec.ts | 9 +- backend/src/auth/auth.service.ts | 6 +- backend/src/orders/dto/create-order.dto.ts | 5 + backend/src/orders/orders.controller.ts | 34 +- backend/src/orders/orders.service.ts | 86 +- backend/src/pets/dto/create-health-log.dto.ts | 24 + backend/src/pets/dto/create-reminder.dto.ts | 24 + backend/src/pets/pets.controller.ts | 33 + backend/src/pets/pets.service.ts | 65 + backend/src/redis/redis.service.ts | 9 + backend/src/users/users.controller.ts | 28 +- backend/src/users/users.service.ts | 42 +- docker-compose.yml | 2 +- .../admin-panel/src/components/Sidebar.tsx | 86 +- frontend/admin-panel/src/pages/Dashboard.tsx | 2 +- frontend/admin-panel/src/pages/Login.tsx | 4 +- frontend/admin-panel/src/pages/Settings.tsx | 36 +- frontend/admin-panel/src/pages/Wiki.tsx | 28 +- frontend/application/app/blog/page.tsx | 5 +- frontend/application/components/AuthModal.tsx | 90 +- frontend/application/components/BlogPage.tsx | 596 ++++---- frontend/application/components/Header.tsx | 605 ++++---- frontend/application/components/Hero.tsx | 43 +- .../application/components/LoginModal.tsx | 38 +- .../components/OrderDetailsModal.tsx | 232 +-- .../application/components/PetProfile.tsx | 1286 ++++++++--------- .../application/components/ProductPage.tsx | 448 +++--- .../application/components/SmartAdvisor.tsx | 102 +- .../application/components/TopUpModal.tsx | 14 +- .../application/components/UserDashboard.tsx | 6 +- frontend/application/lib/data/products.ts | 166 +-- frontend/application/lib/store/cartStore.ts | 4 +- package-lock.json | 4 +- 41 files changed, 2373 insertions(+), 1957 deletions(-) create mode 100644 backend/src/pets/dto/create-health-log.dto.ts create mode 100644 backend/src/pets/dto/create-reminder.dto.ts diff --git a/BACKEND_INTEGRATION.md b/BACKEND_INTEGRATION.md index 49c8168c..3782dd1b 100644 --- a/BACKEND_INTEGRATION.md +++ b/BACKEND_INTEGRATION.md @@ -1,6 +1,6 @@ # نقشه جامع اتصال به بک‌بند (Comprehensive Backend Integration Map) 🏗️ -این سند حاوی معماری دقیق، فهرست کامل نقاط اتصال (API Endpoints)، کامنت‌های مکان‌نما در کد (TODO Markers)، و تعاریف رسمی تمامی تایپ‌های ورودی (Inputs) و خروجی (Outputs) پلتفرم درمانی و فروشگاهی کانی‌نو ایران است. +این سند حاوی معماری دقیق، فهرست کامل نقاط اتصال (API Endpoints)، کامنت‌های مکان‌نما در کد (TODO Markers)، و تعاریف رسمی تمامی تایپ‌های ورودی (Inputs) و خروجی (Outputs) پلتفرم درمانی و فروشگاهی کانینو ایران است. --- diff --git a/DATABASE_SCHEMA.md b/DATABASE_SCHEMA.md index 5e33420d..a78285a1 100644 --- a/DATABASE_SCHEMA.md +++ b/DATABASE_SCHEMA.md @@ -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, diff --git a/README.md b/README.md index 66d5985c..565fa7e3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# پلتفرم کانی‌نو ایران (Canino Iran Platform) 🐾 +# پلتفرم کانینو ایران (Canino Iran Platform) 🐾 ### لندینگ، فروشگاه تخصصی و پرونده سلامت الکترونیک پت (نمایندگی رسمی دارویی Canina Pharma) -پلتفرم **کانی‌نو ایران** یک برنامه جامع تحت وب (SPA/PWA) مجهز به بردهای تعاملی و ابزارهای بهداشتی-دامپزشکی است که با هدف ارتقای سلامت حیوانات خانگی و دسترسی آسان‌تر به مکمل‌های دارویی گرید فوق‌ارگانیک و دارویی کمپانی والای **Canina pharma GmbH آلمان** توسعه یافته است. +پلتفرم **کانینو ایران** یک برنامه جامع تحت وب (SPA/PWA) مجهز به بردهای تعاملی و ابزارهای بهداشتی-دامپزشکی است که با هدف ارتقای سلامت حیوانات خانگی و دسترسی آسان‌تر به مکمل‌های دارویی گرید فوق‌ارگانیک و دارویی کمپانی والای **Canina pharma GmbH آلمان** توسعه یافته است. --- diff --git a/backend/prisma/seed-products.ts b/backend/prisma/seed-products.ts index e0706505..72a592bf 100644 --- a/backend/prisma/seed-products.ts +++ b/backend/prisma/seed-products.ts @@ -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, } ]; diff --git a/backend/prisma/seed.ts b/backend/prisma/seed.ts index d18725b3..31779ede 100644 --- a/backend/prisma/seed.ts +++ b/backend/prisma/seed.ts @@ -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, { diff --git a/backend/src/admin/admin.module.ts b/backend/src/admin/admin.module.ts index 978f49d8..b3aeb552 100644 --- a/backend/src/admin/admin.module.ts +++ b/backend/src/admin/admin.module.ts @@ -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], }) diff --git a/backend/src/admin/admin.service.ts b/backend/src/admin/admin.service.ts index bed2e5bf..342a015a 100644 --- a/backend/src/admin/admin.service.ts +++ b/backend/src/admin/admin.service.ts @@ -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 }; } diff --git a/backend/src/app.module.ts b/backend/src/app.module.ts index fed0a797..a38f9d9f 100644 --- a/backend/src/app.module.ts +++ b/backend/src/app.module.ts @@ -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') diff --git a/backend/src/auth/auth.service.spec.ts b/backend/src/auth/auth.service.spec.ts index 3ec8cee6..1861062b 100644 --- a/backend/src/auth/auth.service.spec.ts +++ b/backend/src/auth/auth.service.spec.ts @@ -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, ); }); diff --git a/backend/src/auth/auth.service.ts b/backend/src/auth/auth.service.ts index 3fd2a2bf..7912f6e4 100644 --- a/backend/src/auth/auth.service.ts +++ b/backend/src/auth/auth.service.ts @@ -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) { diff --git a/backend/src/orders/dto/create-order.dto.ts b/backend/src/orders/dto/create-order.dto.ts index f9203049..602c3ea9 100644 --- a/backend/src/orders/dto/create-order.dto.ts +++ b/backend/src/orders/dto/create-order.dto.ts @@ -20,6 +20,11 @@ export class CreateOrderDto { @IsString() petId?: string; + @ApiPropertyOptional({ description: 'کد تخفیف (اختیاری)' }) + @IsOptional() + @IsString() + couponCode?: string; + @ApiProperty({ description: 'لیست اقلام سفارش', type: [OrderItemDto] }) @IsArray() @ValidateNested({ each: true }) diff --git a/backend/src/orders/orders.controller.ts b/backend/src/orders/orders.controller.ts index ca594893..05eda84c 100644 --- a/backend/src/orders/orders.controller.ts +++ b/backend/src/orders/orders.controller.ts @@ -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({ diff --git a/backend/src/orders/orders.service.ts b/backend/src/orders/orders.service.ts index efe80dc1..e6feff4f 100644 --- a/backend/src/orders/orders.service.ts +++ b/backend/src/orders/orders.service.ts @@ -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, diff --git a/backend/src/pets/dto/create-health-log.dto.ts b/backend/src/pets/dto/create-health-log.dto.ts new file mode 100644 index 00000000..60eb8add --- /dev/null +++ b/backend/src/pets/dto/create-health-log.dto.ts @@ -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; +} diff --git a/backend/src/pets/dto/create-reminder.dto.ts b/backend/src/pets/dto/create-reminder.dto.ts new file mode 100644 index 00000000..86077e2a --- /dev/null +++ b/backend/src/pets/dto/create-reminder.dto.ts @@ -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; +} diff --git a/backend/src/pets/pets.controller.ts b/backend/src/pets/pets.controller.ts index cbaf5b70..fb514b81 100644 --- a/backend/src/pets/pets.controller.ts +++ b/backend/src/pets/pets.controller.ts @@ -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); + } } diff --git a/backend/src/pets/pets.service.ts b/backend/src/pets/pets.service.ts index 1a22645e..126e2555 100644 --- a/backend/src/pets/pets.service.ts +++ b/backend/src/pets/pets.service.ts @@ -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(), + }, + }); + } } diff --git a/backend/src/redis/redis.service.ts b/backend/src/redis/redis.service.ts index 76b726b6..3470c10f 100644 --- a/backend/src/redis/redis.service.ts +++ b/backend/src/redis/redis.service.ts @@ -31,4 +31,13 @@ export class RedisService implements OnModuleInit, OnModuleDestroy { async del(key: string): Promise { await this.client.del(key); } + + async incr(key: string, ttlSeconds?: number): Promise { + 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; + } } diff --git a/backend/src/users/users.controller.ts b/backend/src/users/users.controller.ts index ca34c158..1b5844c8 100644 --- a/backend/src/users/users.controller.ts +++ b/backend/src/users/users.controller.ts @@ -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); + } } diff --git a/backend/src/users/users.service.ts b/backend/src/users/users.service.ts index 2d48e06e..76edd5ca 100644 --- a/backend/src/users/users.service.ts +++ b/backend/src/users/users.service.ts @@ -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 }, diff --git a/docker-compose.yml b/docker-compose.yml index 0367c35f..bd6419d9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: POSTGRES_PASSWORD: caninopassword POSTGRES_DB: caninodb ports: - - "5432:5432" + - "5433:5432" volumes: - postgres_data:/var/lib/postgresql/data diff --git a/frontend/admin-panel/src/components/Sidebar.tsx b/frontend/admin-panel/src/components/Sidebar.tsx index 97288168..ec79f50d 100644 --- a/frontend/admin-panel/src/components/Sidebar.tsx +++ b/frontend/admin-panel/src/components/Sidebar.tsx @@ -58,55 +58,53 @@ export default function Sidebar({ isOpen, setIsOpen }: SidebarProps) { <> {/* Mobile Backdrop */} {isOpen && ( -
setIsOpen(false)} /> )} - - + ); } diff --git a/frontend/admin-panel/src/pages/Dashboard.tsx b/frontend/admin-panel/src/pages/Dashboard.tsx index f3df45fa..fd24cc34 100644 --- a/frontend/admin-panel/src/pages/Dashboard.tsx +++ b/frontend/admin-panel/src/pages/Dashboard.tsx @@ -53,7 +53,7 @@ export default function Dashboard() {

داشبورد

-

خلاصه‌ای از وضعیت فروشگاه کانی‌نو

+

خلاصه‌ای از وضعیت فروشگاه کانینو

diff --git a/frontend/admin-panel/src/pages/Login.tsx b/frontend/admin-panel/src/pages/Login.tsx index 523eb0cf..a8d1278b 100644 --- a/frontend/admin-panel/src/pages/Login.tsx +++ b/frontend/admin-panel/src/pages/Login.tsx @@ -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() { ورود به پنل مدیریت

- کانی‌نو | لابراتوار تخصصی مکمل‌های درمانی حیوانات + کانینو | لابراتوار تخصصی مکمل‌های درمانی حیوانات

diff --git a/frontend/admin-panel/src/pages/Settings.tsx b/frontend/admin-panel/src/pages/Settings.tsx index ff7c7b81..ab9e1d78 100644 --- a/frontend/admin-panel/src/pages/Settings.tsx +++ b/frontend/admin-panel/src/pages/Settings.tsx @@ -57,7 +57,7 @@ export default function Settings() { تنظیمات فروشگاه -

مدیریت پارامترهای اصلی و سیستمی کانی‌نو

+

مدیریت پارامترهای اصلی و سیستمی کانینو

@@ -65,21 +65,21 @@ export default function Settings() {
) : (
- + {/* Financial Settings */}

تنظیمات مالی و ارسال

- +
- 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() {
- 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() { همکاران B2B - +
- 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() { وضعیت سیستم - +
@@ -139,11 +139,11 @@ export default function Settings() {
@@ -151,7 +151,7 @@ export default function Settings() {
-
- +
- 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" /> + 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" />
- 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" /> + 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" />
- +

تنظیمات سئو (SEO)

- 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" /> + 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" />
- 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" /> + 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" />
- +
- +
diff --git a/frontend/application/app/blog/page.tsx b/frontend/application/app/blog/page.tsx index 4bb085a0..a9165323 100644 --- a/frontend/application/app/blog/page.tsx +++ b/frontend/application/app/blog/page.tsx @@ -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, diff --git a/frontend/application/components/AuthModal.tsx b/frontend/application/components/AuthModal.tsx index 37d61eac..b5936663 100644 --- a/frontend/application/components/AuthModal.tsx +++ b/frontend/application/components/AuthModal.tsx @@ -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 */} {/* Top highlight bar */}
- +
{/* Close Button */} -

- ورود به دنیای کانی‌نو + ورود به دنیای کانینو

- {view === "otp" + {view === "otp" ? `کد تایید ارسال شده به شماره ${toPersian(phoneNumber)} را وارد کنید` : "برای دسترسی به پرونده سلامت و سفارشات وارد شوید"}

@@ -220,10 +220,10 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) { >
- setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))} disabled={isLoading} @@ -232,26 +232,26 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
- 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" />
- +
- -
-
- +
- setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))} @@ -315,8 +315,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
- setEmail(e.target.value)} disabled={isLoading} @@ -326,8 +326,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
- setPassword(e.target.value)} disabled={isLoading} @@ -336,8 +336,8 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
-
-
- setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))} disabled={isLoading} @@ -390,7 +390,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
-
- setOtpCode(e.target.value.replace(/[^0-9]/g, ''))} disabled={isLoading} @@ -449,7 +449,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) { ارسال مجدد کد پس از {toPersian(countdown)} ثانیه ) : ( - -
-
-
- -
- -
-
-
- -
-

محصولات پیشنهادی

-
- {products.slice(4, 7).map(p => ( -
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" - > -
- {p.name} -
-
-
{p.category}
-
{p.name}
-
-
- ))} -
+ if (selectedPost) { + return ( +
+
+ {/* Breadcrumbs */} +
+ router.push('/')}>خانه + + setSelectedPost(null)}>مجله سلامت + + {selectedPost.title}
-
-

محبوب‌ترین مقالات

-
- {blogs.map(p => ( -
router.push(`/blog/${p.slug}`)} - className="flex items-center gap-4 cursor-pointer group" - > -
- -
-
- {p.title} -
-
+
+
+ +
+ {selectedPost.title} +
+
+
+
تحقیق بالینی
+
+ + {selectedPost.date} +
+
+

+ {selectedPost.title} +

+
+

+ {selectedPost.excerpt} +

+
+ {selectedPost.content} +
+
+ +
+
+
+ +
+
+
{selectedPost.author}
+
تیم تحقیق و توسعه کانینو آلمان
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+

محصولات پیشنهادی

+
+ {products.slice(4, 7).map(p => ( +
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" + > +
+ {p.name} +
+
+
{p.category}
+
{p.name}
+
+
+ ))} +
+
+ +
+

محبوب‌ترین مقالات

+
+ {blogs.map(p => ( +
router.push(`/blog/${p.slug}`)} + className="flex items-center gap-4 cursor-pointer group" + > +
+ +
+
+ {p.title} +
+
+ ))} +
+
+
+
+
+
+ ); + } + + return ( +
+
+ {/* Header */} +
+
+
+ + Canino Science Blog +
+

+ مجله تخصصی سلامت پت‌ها +

+

+ آخرین یافته‌های علمی محققین کانینو آلمان در مورد تغذیه و سلامت پت‌ها. +

+
+ +
+ + {/* Featured Post */} + {blogs.length > 0 && ( +
+ router.push(`/blog/${blogs[0].slug}`)} + > +
+ {blogs[0].title} +
+
+
+
تخصصی
+
+ + {blogs[0].date} +
+
+

+ {blogs[0].title} +

+

+ {blogs[0].excerpt} +

+
+
+
+ +
+
+
{blogs[0].author}
+
نویسنده کانینو
+
+
+
+ ادامه مطلب + +
+
+
+
+
+ )} + + {/* Post Grid */} +
+ {blogs.slice(1).map((post, idx) => ( + router.push(`/blog/${post.slug}`)} + > +
+ {post.title} +
+
+
+
+ + {post.date} +
+
+

+ {post.title} +

+

+ {post.excerpt} +

+
+ مطالعه مقاله + +
+
+
+ ))} + + {/* Newsletter / CTA Box */} +
+
+ +
+

مشترک خبرنامه علمی شوید

+

+ ماهانه یک ایمیل حاوی مهم‌ترین نکات سلامت پت‌ها و کدهای تخفیف اختصاصی دریافت کنید. +

+
+ + +
+
+
+ + {/* Synergy Products Cross-sell */} +
+
+
+ {Array.from({ length: 36 }).map((_, i) => ( +
))}
-
-
-
-
- ); - } - - return ( -
-
- {/* Header */} -
-
-
- - Canino Science Blog -
-

- مجله تخصصی سلامت پت‌ها -

-

- آخرین یافته‌های علمی محققین کانی‌نو آلمان در مورد تغذیه و سلامت پت‌ها. -

-
- -
- - {/* Featured Post */} - {blogs.length > 0 && ( -
- router.push(`/blog/${blogs[0].slug}`)} - > -
- {blogs[0].title} -
-
-
-
تخصصی
-
- - {blogs[0].date} -
-
-

- {blogs[0].title} -

-

- {blogs[0].excerpt} -

-
-
-
- -
-
-
{blogs[0].author}
-
نویسنده کانینو
-
-
-
- ادامه مطلب - -
-
-
-
-
- )} - - {/* Post Grid */} -
- {blogs.slice(1).map((post, idx) => ( - router.push(`/blog/${post.slug}`)} - > -
- {post.title} -
-
-
-
- - {post.date} -
-
-

- {post.title} -

-

- {post.excerpt} -

-
- مطالعه مقاله - -
-
-
- ))} - - {/* Newsletter / CTA Box */} -
-
- -
-

مشترک خبرنامه علمی شوید

-

- ماهانه یک ایمیل حاوی مهم‌ترین نکات سلامت پت‌ها و کدهای تخفیف اختصاصی دریافت کنید. -

-
- - -
-
-
- - {/* Synergy Products Cross-sell */} -
-
-
- {Array.from({length: 36}).map((_, i) => ( -
- ))} -
-
-
-
-

علم آلمانی در خدمت سلامت پت شما

-

- تمامی مقالات این وبلاگ بر اساس کاتالوگ‌های رسمی و نتایج آزمایشگاهی کمپانی کانی‌نو آلمان تدوین شده است. -

- +
+
+

علم آلمانی در خدمت سلامت پت شما

+

+ تمامی مقالات این وبلاگ بر اساس کاتالوگ‌های رسمی و نتایج آزمایشگاهی کمپانی کانینو آلمان تدوین شده است. +

+ +
+
+ {products.slice(0, 2).map((p) => ( +
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" + > + {p.name} +
{p.name}
+
+ ))} +
-
- {products.slice(0, 2).map((p) => ( -
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" - > - {p.name} -
{p.name}
-
- ))} -
-
-
+ +
-
- ); + ); } diff --git a/frontend/application/components/Header.tsx b/frontend/application/components/Header.tsx index aa506804..8914161e 100644 --- a/frontend/application/components/Header.tsx +++ b/frontend/application/components/Header.tsx @@ -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(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 ( <> - setIsAuthModalOpen(false)} /> - -
- 🚚 - ارسال رایگان برای سفارش‌های بالای ۱۵۰ هزار تومان -
- -
-
-
- {/* Mobile Menu Toggle */} - + setIsAuthModalOpen(false)} /> - {/* Logo Section */} -
{ - onNavigate("home"); - setIsMobileMenuOpen(false); - }} - > -
C
-
- Canino ایران - نماینده رسمی Canina Pharma GmbH آلمان +
+ 🚚 + ارسال رایگان برای سفارش‌های بالای ۱۵۰ هزار تومان +
+ +
+
+
+ {/* Mobile Menu Toggle */} + + + {/* Logo Section */} +
{ + onNavigate("home"); + setIsMobileMenuOpen(false); + }} + > +
C
+
+ Canino ایران + نماینده رسمی Canina Pharma GmbH آلمان +
-
- {/* Navigation Items */} - -
- {isLoggedIn ? ( -
- {/* User Name (Direct link to dashboard) */} -
onNavigate("user-dashboard")} - > - - - {profile.firstName} - -
+ {/* Action Area */} +
- {/* Separator Line */} -
+ {/* Elastic Search */} +
+ + {isSearchFocused && ( + +
+ 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" + /> + +
+
+ )} +
- {/* Pet Name & Switcher */} -
-
setIsSearchFocused(!isSearchFocused)} + > + + +
+ +
+ {isLoggedIn ? ( +
+ {/* User Name (Direct link to dashboard) */} +
onNavigate("user-dashboard")} + > + + + {profile.firstName} + +
+ + {/* Separator Line */} +
+ + {/* Pet Name & Switcher */} +
+
-
{ setActivePet(pet.id); @@ -308,7 +308,7 @@ export default function Header({
{pet.name}
- +
{activePetId === pet.id && }
- +
- - -
)} -
-
- ) : ( - setIsAuthModalOpen(true)} - icon={} - > - ورود / ثبت‌نام - - )} +
+
+ ) : ( + setIsAuthModalOpen(true)} + icon={} + > + ورود / ثبت‌نام + + )} - } - > + >
سبد خرید
-
-
-
-
-
+ +
+
+
+
- {/* Mobile Drawer Menu */} - - {isMobileMenuOpen && ( - <> - {/* Backdrop */} - setIsMobileMenuOpen(false)} - className="fixed inset-0 bg-black z-40 lg:hidden" - /> - {/* Drawer */} - -
-
-
C
- Canino -
- -
+ {/* Mobile Drawer Menu */} + + {isMobileMenuOpen && ( + <> + {/* Backdrop */} + setIsMobileMenuOpen(false)} + className="fixed inset-0 bg-black z-40 lg:hidden" + /> + {/* Drawer */} + +
+
+
C
+ Canino +
+ +
- {/* Navigation Links */} - +
+ + )} +
+ + ); +} diff --git a/frontend/application/components/Hero.tsx b/frontend/application/components/Hero.tsx index 2e95af97..d403e584 100644 --- a/frontend/application/components/Hero.tsx +++ b/frontend/application/components/Hero.tsx @@ -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 ( - {toPersian(displayText)} - {getText('hero_badge', "تخصص دارویی از آلمان")}
- +

{titleParts[0]}
{titleParts[1] && {titleParts[1]}}

- -

- -

- ورود به کانی‌نو + ورود به کانینو

{isAdvisorContext ? (

@@ -167,7 +167,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso {/* Step-based Forms */} {step === "phone" ? ( - شماره موبایل

- setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))} disabled={isLoading} @@ -192,7 +192,7 @@ export default function LoginModal({ isOpen, onClose, onLogin, petName, isAdviso
-
- 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)} ثانیه ) : ( - +
+
+ +
+
+

جزئیات سفارش {toPersian(order.id)}

+

ثبت شده در {toPersian(orderDate.toLocaleDateString("fa-IR"))}

+
+
+
{/* Content Scrollable */}
- {/* Summary Stats */} -
-
-
وضعیت تحویل
-
- {getStatusIcon(order.status)} - {getStatusLabel(order.status)} -
+ {/* Summary Stats */} +
+
+
وضعیت تحویل
+
+ {getStatusIcon(order.status)} + {getStatusLabel(order.status)}
-
-
کد رهگیری
-
{toPersian(order.trackingNumber)}
+
+
+
کد رهگیری
+
{toPersian(order.trackingNumber)}
+
+
+
زمان ثبت
+
+ + {toPersian(orderDate.toLocaleTimeString("fa-IR", { hour: '2-digit', minute: '2-digit' }))}
-
-
زمان ثبت
-
- - {toPersian(orderDate.toLocaleTimeString("fa-IR", { hour: '2-digit', minute: '2-digit' }))} -
-
-
+
+
- {/* Items List */} -
-

- - سبد محصولات خریده شده + {/* Items List */} +
+

+ + سبد محصولات خریده شده +

+
+ {(order.items || []).map((item: any) => ( +
+
+
+ +
+
+
{item.product.name}
+
{toPersian(item.quantity)} عدد × {toPersian(item.product.priceValue.toLocaleString())} تومان
+
+
+
+
{toPersian((item.product.priceValue * item.quantity).toLocaleString())} تومان
+
+
+ ))} +
+
+ + {/* Shipping & Payment */} +
+
+

+ + اطلاعات ارسال

-
- {(order.items || []).map((item: any) => ( -
-
-
- -
-
-
{item.product.name}
-
{toPersian(item.quantity)} عدد × {toPersian(item.product.priceValue.toLocaleString())} تومان
-
-
-
-
{toPersian((item.product.priceValue * item.quantity).toLocaleString())} تومان
-
-
- ))} +

+ تهران، خیابان ولیعصر، بالاتر از میدان ونک، بن‌بست آفتاب، پلاک ۱۲، واحد ۳ +

+
+
+

+ + جزئیات پرداخت +

+
+
+ جمع ناخالص + {toPersian(order.total.toLocaleString())} تومان +
+
+ تخفیف هوشمند + {toPersian("۰")} تومان +
+
+ مبلغ نهایی + {toPersian(order.total.toLocaleString())} تومان +
-
- - {/* Shipping & Payment */} -
-
-

- - اطلاعات ارسال -

-

- تهران، خیابان ولیعصر، بالاتر از میدان ونک، بن‌بست آفتاب، پلاک ۱۲، واحد ۳ -

-
-
-

- - جزئیات پرداخت -

-
-
- جمع ناخالص - {toPersian(order.total.toLocaleString())} تومان -
-
- تخفیف هوشمند - {toPersian("۰")} تومان -
-
- مبلغ نهایی - {toPersian(order.total.toLocaleString())} تومان -
-
-
-
+
+

{/* Footer Actions */}
- - + +
diff --git a/frontend/application/components/PetProfile.tsx b/frontend/application/components/PetProfile.tsx index 85f55bdc..df6895ca 100644 --- a/frontend/application/components/PetProfile.tsx +++ b/frontend/application/components/PetProfile.tsx @@ -4,16 +4,16 @@ import { Product, PetType } from "../lib/data/products"; import { productService } from "../lib/services/productService"; import { motion, AnimatePresence } from "motion/react"; import { PetProfileSkeleton } from "./Skeleton"; -import { - Dog, - Cat, - ChevronRight, - ChevronLeft, - Heart, - Activity, - Weight, - Calendar, - ShieldCheck, +import { + Dog, + Cat, + ChevronRight, + ChevronLeft, + Heart, + Activity, + Weight, + Calendar, + ShieldCheck, Stethoscope, Plus, Clock, @@ -37,7 +37,7 @@ import { toPersian, cn } from "../lib/utils"; import { useRouter } from 'next/navigation'; -export default function PetProfile({ initialView, advisorNeed }: { +export default function PetProfile({ initialView, advisorNeed }: { initialView?: "index" | "detail" | "add" | "edit", advisorNeed?: string | null }) { @@ -70,7 +70,7 @@ export default function PetProfile({ initialView, advisorNeed }: { if (isLoading && view === "detail" && activePet) { return (
- +
); } @@ -101,7 +101,7 @@ export default function PetProfile({ initialView, advisorNeed }: { if (!activePet) return []; return orders.filter(o => o.petId === activePet.id); }, [activePet, orders]); - + const [step, setStep] = useState(1); const [formData, setFormData] = useState>({ name: "", @@ -152,7 +152,7 @@ export default function PetProfile({ initialView, advisorNeed }: { if (activePet) { const today = new Date().toISOString().split('T')[0]; toggleReminder(activePet.id, reminder.id, today); - + const isCompleting = !reminder.completedDates.includes(today); if (isCompleting) { toast.success(`دوز ${reminder.title} تایید شد`); @@ -162,9 +162,9 @@ export default function PetProfile({ initialView, advisorNeed }: { const recommendedProducts = useMemo(() => { if (!activePet || products.length === 0) return []; - + let picks: { product: Product, reason?: string }[] = []; - + // Priority: Medical Conditions if (activePet.medicalConditions.includes("جراحی مفاصل")) { const gag = products.find(p => p.id === "canhydrox-gag"); @@ -172,23 +172,23 @@ export default function PetProfile({ initialView, advisorNeed }: { } if (activePet.medicalConditions.includes("زایمان اخیر") || activePet.medicalConditions.includes("بارداری")) { - const booster = products.find(p => p.id === "immun-booster"); - if (booster) picks.push({ product: booster, reason: "حمایت حیاتی دوران بارداری و زایمان" }); + const booster = products.find(p => p.id === "immun-booster"); + if (booster) picks.push({ product: booster, reason: "حمایت حیاتی دوران بارداری و زایمان" }); } if (activePet.medicalConditions.includes("مشکلات گوارشی")) { - const moor = products.find(p => p.id === "moor-tranke"); - if (moor) picks.push({ product: moor, reason: "تنظیم تخصصی سیستم گوارش" }); + const moor = products.find(p => p.id === "moor-tranke"); + if (moor) picks.push({ product: moor, reason: "تنظیم تخصصی سیستم گوارش" }); } if (activePet.medicalConditions.includes("ریزش موی شدید")) { - const lachs = products.find(p => p.id === "lachs-ol"); - if (lachs) picks.push({ product: lachs, reason: "تقویت تارهای مو و کنترل ریزش" }); + const lachs = products.find(p => p.id === "lachs-ol"); + if (lachs) picks.push({ product: lachs, reason: "تقویت تارهای مو و کنترل ریزش" }); } if (activePet.medicalConditions.includes("بی‌اشتهایی")) { - const energy = products.find(p => p.id === "energy-gel"); - if (energy) picks.push({ product: energy, reason: "تامین فوری انرژی و تحریک اشتها" }); + const energy = products.find(p => p.id === "energy-gel"); + if (energy) picks.push({ product: energy, reason: "تامین فوری انرژی و تحریک اشتها" }); } // Biological factors @@ -268,22 +268,22 @@ export default function PetProfile({ initialView, advisorNeed }: {

همدم‌های من

مدیریت شناسنامه‌های سلامت و سوابق درمانی

- - - - + +
- setFormData({...formData, breed: e.target.value})} + onChange={e => setFormData({ ...formData, breed: e.target.value })} className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-bold" placeholder="آلمانی، پرشین، میکس و..." /> @@ -459,56 +459,56 @@ export default function PetProfile({ initialView, advisorNeed }: { )} {step === 2 && ( - -
-
- - setFormData({...formData, age: parseInt(e.target.value)})} - className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-black text-lg" - placeholder="۳" - /> -
-
- -
- setFormData({...formData, weight: parseFloat(e.target.value)})} - className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 pr-6 pl-12 focus:ring-2 focus:ring-canino-blue/20 outline-none font-black text-lg" - /> - -
-
-
+
+
+ + setFormData({ ...formData, age: parseInt(e.target.value) })} + className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-black text-lg" + placeholder="۳" + /> +
+
+ +
+ setFormData({ ...formData, weight: parseFloat(e.target.value) })} + className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 pr-6 pl-12 focus:ring-2 focus:ring-canino-blue/20 outline-none font-black text-lg" + /> + +
+
+
- {["کم", "متوسط", "زیاد"].map(level => ( - - ))} + {["کم", "متوسط", "زیاد"].map(level => ( + + ))}
)} {step === 3 && ( - سوابق درمانی و موارد خاص
{[ - "جراحی مفاصل", - "زایمان اخیر", - "بارداری", - "مشکلات گوارشی", - "ریزش موی شدید", - "بی‌اشتهایی" + "جراحی مفاصل", + "زایمان اخیر", + "بارداری", + "مشکلات گوارشی", + "ریزش موی شدید", + "بی‌اشتهایی" ].map(condition => ( - + ))}
@@ -550,33 +550,33 @@ export default function PetProfile({ initialView, advisorNeed }: {
- + {step > 1 && ( + - {step > 1 && ( - - )} - + )} +
@@ -590,520 +590,520 @@ export default function PetProfile({ initialView, advisorNeed }: { return (
- + {/* Navigation Bar */}
-
- setView("index")}>همدم‌های من - - پرونده سلامت {activePet?.name} -
+
+ setView("index")}>همدم‌های من + + پرونده سلامت {activePet?.name} +
-
- - -
+
+ + +
- + {/* Profile Card */}
-
-
- -
-
- {activePet.type === "سگ" ? : } -
-
+
+
-
-
-

{activePet.name}

- {activePet.breed} -
- -
- {[ - { icon: , label: "وزن", value: `${toPersian(activePet.weight)} کیلوگرم` }, - { icon: , label: "سن", value: `${toPersian(activePet.age)} سال` }, - { icon: , label: "فعالیت", value: activePet.activityLevel }, - { icon: , label: "وضعیت", value: "نرمال" }, - ].map((item, idx) => ( -
-
- {item.icon} - {item.label} -
-
{item.value}
-
- ))} -
- -
- {activePet.medicalConditions.map(c => ( -
- - {c} -
- ))} -
-
+
+
+ {activePet.type === "سگ" ? : } +
-
-
- -
-
-
امتیاز سلامت پایش شده
-
- {toPersian(88)} - /۱۰۰ -
-
-
-
- -
-

- بر اساس پایش هوشمند، وضعیت {activePet.name} در سطح «ایده‌آل» قرار دارد. -

-
-
+
+
+

{activePet.name}

+ {activePet.breed} +
- {/* Kindness Footprint Widget for Pet */} -
-
- -
-
-
- +
+ {[ + { icon: , label: "وزن", value: `${toPersian(activePet.weight)} کیلوگرم` }, + { icon: , label: "سن", value: `${toPersian(activePet.age)} سال` }, + { icon: , label: "فعالیت", value: activePet.activityLevel }, + { icon: , label: "وضعیت", value: "نرمال" }, + ].map((item, idx) => ( +
+
+ {item.icon} + {item.label}
-
-

ردپای مهربانی

-

سفیر مهربانی: {activePet.name}

-
-
-
-

- {activePet.name} با خریدهای مکمل خود، تا کنون به تامین هزینه‌های درمانی و تغذیه حیوانات پناهگاهی کمک کرده است. -

-
-
- سطح مشارکت - حامی وفادار -
-
-
+
{item.value}
+
+ ))} +
+ +
+ {activePet.medicalConditions.map(c => ( +
+ + {c} +
+ ))} +
+
+ +
+
+ +
+
+
امتیاز سلامت پایش شده
+
+ {toPersian(88)} + /۱۰۰ +
+
+
+
+ +
+

+ بر اساس پایش هوشمند، وضعیت {activePet.name} در سطح «ایده‌آل» قرار دارد. +

+
+
+ + {/* Kindness Footprint Widget for Pet */} +
+
+ +
+
+
+ +
+
+

ردپای مهربانی

+

سفیر مهربانی: {activePet.name}

+
+
+
+

+ {activePet.name} با خریدهای مکمل خود، تا کنون به تامین هزینه‌های درمانی و تغذیه حیوانات پناهگاهی کمک کرده است. +

+
+
+ سطح مشارکت + حامی وفادار +
+
+
+
{/* Refill & Stock Tracking */}
-
-
-
- -

پایش موجودی مکمل‌ها

-
-
بروزرسانی لحظه‌ای بر اساس مصرف
+
+
+
+ +

پایش موجودی مکمل‌ها

+
بروزرسانی لحظه‌ای بر اساس مصرف
+
-
- {(activePet?.consumptions || []).length === 0 ? ( -
-

هنوز محصولی برای پایش موجودی ثبت نشده است.

-

با ثبت اولین سفارش، پایش هوشمند فعال می‌شود.

+
+ {(activePet?.consumptions || []).length === 0 ? ( +
+

هنوز محصولی برای پایش موجودی ثبت نشده است.

+

با ثبت اولین سفارش، پایش هوشمند فعال می‌شود.

+
+ ) : ( + activePet.consumptions.map((consumption) => { + const product = products.find(p => p.id === consumption.productId); + if (!product) return null; + + const percentage = (consumption.remaining / (consumption.packageSize || 1)) * 100; + const isLow = percentage < 25; + + return ( +
+
+
+

{product.name}

+

باقیمانده: {toPersian(consumption.remaining)} واحد

+
+
+ {toPersian(Math.round(percentage))}% +
- ) : ( - activePet.consumptions.map((consumption) => { - const product = products.find(p => p.id === consumption.productId); - if (!product) return null; - - const percentage = (consumption.remaining / (consumption.packageSize || 1)) * 100; - const isLow = percentage < 25; - return ( -
-
-
-

{product.name}

-

باقیمانده: {toPersian(consumption.remaining)} واحد

-
-
- {toPersian(Math.round(percentage))}% -
-
- -
- -
+
+ +
- {isLow && ( - - )} -
- ); - }) - )} -
+ {isLow && ( + + )} +
+ ); + }) + )} +
{/* Tab Selection */}
- {[ - { id: "health", label: "داشبورد سلامت و یادآوری‌ها", icon: }, - { id: "orders", label: "سوابق خرید و تاریخچه تخصصی", icon: }, - ].map(tab => ( - - ))} + {[ + { id: "health", label: "داشبورد سلامت و یادآوری‌ها", icon: }, + { id: "orders", label: "سوابق خرید و تاریخچه تخصصی", icon: }, + ].map(tab => ( + + ))}
{activePetTab === "health" ? ( <> {/* Personalized Recommendations */}
-
-
-
- -
-

توصیه‌های درمانی اختصاصی

-
-

کاتالوگ ۲۰۲۴ آلمان

+
+
+
+ +
+

توصیه‌های درمانی اختصاصی

+

کاتالوگ ۲۰۲۴ آلمان

+
-
- {recommendedProducts.map(({ product: p, reason }) => ( - router.push(`/shop/${p.slug || p.id}`)} - className="bg-white rounded-[2.5rem] p-6 border border-medical-gray-200 hover:shadow-2xl transition-all cursor-pointer group flex flex-col justify-between relative overflow-hidden" - > - {reason && ( -
- {reason} -
- )} -
- -
-
-

{p.name}

-

{p.benefits}

- -
-
- ))} -
+
+ {recommendedProducts.map(({ product: p, reason }) => ( + router.push(`/shop/${p.slug || p.id}`)} + className="bg-white rounded-[2.5rem] p-6 border border-medical-gray-200 hover:shadow-2xl transition-all cursor-pointer group flex flex-col justify-between relative overflow-hidden" + > + {reason && ( +
+ {reason} +
+ )} +
+ +
+
+

{p.name}

+

{p.benefits}

+ +
+
+ ))} +
- {/* Reminders */} -
-
-
- -

یادآورهای فعال

+ {/* Reminders */} +
+
+
+ +

یادآورهای فعال

+
+ +
+ +
+ {(activePet?.reminders || []).length === 0 ? ( +
+

هنوز یادآوری ثبت نشده است

+
+ ) : ( + (activePet?.reminders || []).map((reminder) => { + const today = new Date().toISOString().split('T')[0]; + const isCompleted = reminder.completedDates.includes(today); + + return ( +
+
+ +
+
{reminder.title}
+

{toPersian(reminder.time)} - {reminder.frequency}

+
+
+ + {isCompleted ? "انجام شد" : "در انتظار"} +
- -
- -
- {(activePet?.reminders || []).length === 0 ? ( -
-

هنوز یادآوری ثبت نشده است

-
- ) : ( - (activePet?.reminders || []).map((reminder) => { - const today = new Date().toISOString().split('T')[0]; - const isCompleted = reminder.completedDates.includes(today); - - return ( -
-
- -
-
{reminder.title}
-

{toPersian(reminder.time)} - {reminder.frequency}

-
-
- - {isCompleted ? "انجام شد" : "در انتظار"} - -
- ); - }) - )} -
- - + ); + }) + )}
- {/* Health Logs */} -
-
- -

تایم‌لاین سلامت

-
+ +
-
- {(activePet?.logs || []).length === 0 ? ( -
-

هنوز گزارشی ثبت نشده است

-
- ) : ( - (activePet?.logs || []).map((log) => ( -
-
-
- {toPersian(new Date(log.date).toLocaleDateString("fa-IR"))} -
-
-
{log.appetite}
-
{log.energy}
-
-
-

- {log.note || "وضعیتی برای این روز ثبت نشده است."} -

-
- )) - )} -
- - + {/* Health Logs */} +
+
+ +

تایم‌لاین سلامت

+ +
+ {(activePet?.logs || []).length === 0 ? ( +
+

هنوز گزارشی ثبت نشده است

+
+ ) : ( + (activePet?.logs || []).map((log) => ( +
+
+
+ {toPersian(new Date(log.date).toLocaleDateString("fa-IR"))} +
+
+
{log.appetite}
+
{log.energy}
+
+
+

+ {log.note || "وضعیتی برای این روز ثبت نشده است."} +

+
+ )) + )} +
+ + +
) : ( - -
-
-
- -
-
-

تاریخچه خرید {activePet.name}

-

لیست محصولات خریداری شده ویژه این پرونده سلامت

-
+
+
+
+
-
-
مجموع هزینه درمانی
-
{toPersian(petOrders.reduce((a,b) => a + b.total, 0).toLocaleString())} تومان
+
+

تاریخچه خرید {activePet.name}

+

لیست محصولات خریداری شده ویژه این پرونده سلامت

-
+
+
+
مجموع هزینه درمانی
+
{toPersian(petOrders.reduce((a, b) => a + b.total, 0).toLocaleString())} تومان
+
+
- {petOrders.length === 0 ? ( -
-
- -
-

هنوز سفارشی برای {activePet.name} ثبت نکرده‌اید.

- -
- ) : ( -
- {petOrders.map(order => - order.items.map(item => ( - router.push(`/shop/${item.product.slug || item.product.id}`)} - > - {/* Info on Left (Text side) */} -
-

{item.product.name}

-
-
- - {toPersian(new Date(order.date).toLocaleDateString("fa-IR", { year: 'numeric', month: 'long', day: 'numeric' }))} -
-
- - تایید شده و تحویل شده -
-
- فاکتور: {toPersian(order.id)} -
-
-
+ {petOrders.length === 0 ? ( +
+
+ +
+

هنوز سفارشی برای {activePet.name} ثبت نکرده‌اید.

+ +
+ ) : ( +
+ {petOrders.map(order => + order.items.map(item => ( + router.push(`/shop/${item.product.slug || item.product.id}`)} + > + {/* Info on Left (Text side) */} +
+

{item.product.name}

+
+
+ + {toPersian(new Date(order.date).toLocaleDateString("fa-IR", { year: 'numeric', month: 'long', day: 'numeric' }))} +
+
+ + تایید شده و تحویل شده +
+
+ فاکتور: {toPersian(order.id)} +
+
+
- {/* Image on Right (Icon side) */} -
- -
-
- )) - )} -
- )} + {/* Image on Right (Icon side) */} +
+ +
+
+ )) + )} +
+ )} )} {/* Seal of Authenticity */}
-
-
آلمان
-
-

ضمانت اصالت و سلامت کانینو آلمان

-

- این گزارش توسط سیستم هوش مصنوعی کانی‌نو و با انطباق کامل بر پروتکل‌های درمانی Canina Pharma GmbH آلمان تولید شده است. تمامی مکمل‌های پیشنهادی دارای استاندارد دارویی (Pharmaceutical Grade) می‌باشند. -

+
+
آلمان
+
+

ضمانت اصالت و سلامت کانینو آلمان

+

+ این گزارش توسط سیستم هوش مصنوعی کانینو و با انطباق کامل بر پروتکل‌های درمانی Canina Pharma GmbH آلمان تولید شده است. تمامی مکمل‌های پیشنهادی دارای استاندارد دارویی (Pharmaceutical Grade) می‌باشند. +

{/* Add Reminder Modal */} {isAddingReminder && (
- setIsAddingReminder(false)} /> -
-

افزودن یادآور جدید

- +

افزودن یادآور جدید

+
- +
-
- - setReminderForm({...reminderForm, title: e.target.value})} - placeholder="مثلاً: قرص مفاصل، کانهیدروکس" - className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-bold" - /> -
-
-
- - setReminderForm({...reminderForm, time: e.target.value})} - className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-black" - /> -
-
- - -
-
-
- - setReminderForm({ ...reminderForm, title: e.target.value })} + placeholder="مثلاً: قرص مفاصل، کانهیدروکس" + className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-bold" + /> +
+
+
+ + setReminderForm({ ...reminderForm, time: e.target.value })} + className="w-full bg-medical-gray-50 border border-medical-gray-200 rounded-2xl py-4 px-6 focus:ring-2 focus:ring-canino-blue/20 outline-none font-black" + /> +
+
+ + -
+
+
+
+ + +
- + > + ثبت نهایی یادآور +
@@ -1114,78 +1114,78 @@ export default function PetProfile({ initialView, advisorNeed }: { {isAddingHealthLog && (
- setIsAddingHealthLog(false)} /> - -
-

ثبت گزارش روزانه سلامت

- +
+

ثبت گزارش روزانه سلامت

+
-
- -
- {["عالی", "متوسط", "کم"].map(opt => ( - - ))} -
+
+ +
+ {["عالی", "متوسط", "کم"].map(opt => ( + + ))}
+
-
- -
- {["زیاد", "نرمال", "بی‌حال"].map(opt => ( - - ))} -
+
+ +
+ {["زیاد", "نرمال", "بی‌حال"].map(opt => ( + + ))}
+
-
- -