feat: complete settings sync, standard UI inputs, prescriptions flow, pet profile and checkout enhancements
Deploy Canina / deploy (push) Failing after 51s

This commit is contained in:
parsa aghaei committed 2026-08-17 11:46:49 +03:30
1 parent b3c60a1a7d
commit 6df92f03d7
32 files changed
+61750 -59151

No files matched your search

@@ -2,11 +2,12 @@ import { Module } from '@nestjs/common';
import { PrescriptionsController } from './prescriptions.controller';
import { PrescriptionsService } from './prescriptions.service';
import { PrismaModule } from '../prisma/prisma.module';
import { SmsService } from '../common/services/sms.service';
@Module({
imports: [PrismaModule],
controllers: [PrescriptionsController],
providers: [PrescriptionsService],
providers: [PrescriptionsService, SmsService],
exports: [PrescriptionsService],
})
export class PrescriptionsModule {}
@@ -2,18 +2,29 @@ import {
Injectable,
NotFoundException,
ForbiddenException,
Logger,
} from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { SmsService } from '../common/services/sms.service';
@Injectable()
export class PrescriptionsService {
constructor(private prisma: PrismaService) {}
private readonly logger = new Logger(PrescriptionsService.name);
constructor(
private prisma: PrismaService,
private smsService: SmsService,
) {}
async create(
userId: string | null,
data: {
petId?: string;
petName?: string;
petType?: string;
petBreed?: string;
petAge?: number;
petWeight?: number;
phone?: string;
fileUrl: string;
notes?: string;
@@ -30,7 +41,6 @@ export class PrescriptionsService {
});
if (!user) {
// Create user with default role Customer
user = await this.prisma.user.create({
data: {
mobile: cleanPhone,
@@ -57,10 +67,10 @@ export class PrescriptionsService {
data: {
userId: user.id,
name: cleanPetName,
type: 'سگ', // Default pet type for prescription consultation
breed: 'نامشخص',
age: 1,
weight: 5.0,
type: data.petType || 'سگ',
breed: data.petBreed || 'نامشخص',
age: data.petAge !== undefined ? data.petAge : 0,
weight: data.petWeight !== undefined ? data.petWeight : 0,
activityLevel: 'متوسط',
},
});
@@ -119,11 +129,15 @@ export class PrescriptionsService {
adminNotes?: string;
},
) {
const item = await this.prisma.prescription.findUnique({ where: { id } });
const item = await this.prisma.prescription.findUnique({
where: { id },
include: { user: true, pet: true },
});
if (!item) {
throw new NotFoundException(`Prescription with ID ${id} not found`);
}
return this.prisma.prescription.update({
const updated = await this.prisma.prescription.update({
where: { id },
data: {
status: reviewData.status,
@@ -131,5 +145,18 @@ export class PrescriptionsService {
},
include: { user: true, pet: true },
});
// Send SMS notification if prescription was reviewed/approved and user has mobile
if (item.user?.mobile && reviewData.status === 'APPROVED') {
const petTitle = item.pet?.name ? ` برای «${item.pet.name}»` : '';
const smsText = `کنینا: نسخه پزشکی شما${petTitle} توسط تیم تخصصی بررسی و تایید شد. جهت مشاهده تجویز پزشک و سفارش مکمل‌ها به پنل کاربری خود در canina.ir مراجعه کنید.`;
try {
await this.smsService.sendSms(item.user.mobile, smsText);
} catch (smsErr) {
this.logger.warn(`Failed to send prescription SMS to ${item.user.mobile}:`, smsErr);
}
}
return updated;
}
}