🚀 Final: Fix stats, staff list, settings profile, and logout redirect
This commit is contained in:
@@ -62,6 +62,16 @@ export class AuthController {
|
||||
return this.authService.logout(user.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* الملف الشخصي الحالي والبيانات الأساسية
|
||||
*/
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get('me')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
async me(@CurrentUser() user: any) {
|
||||
return this.authService.getMe(user.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* الملف الشخصي
|
||||
*/
|
||||
|
||||
@@ -179,6 +179,29 @@ export class AuthService {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* الحصول على بيانات المستخدم والاشتراك الحالي
|
||||
*/
|
||||
async getMe(userId: string) {
|
||||
const user = await this.dataSource.getRepository(User).findOne({
|
||||
where: { id: userId },
|
||||
relations: ['tenant'],
|
||||
});
|
||||
|
||||
if (!user) throw new UnauthorizedException();
|
||||
|
||||
return {
|
||||
user: {
|
||||
id: user.id,
|
||||
name: user.name,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
tenantId: user.tenant_id,
|
||||
},
|
||||
tenant: user.tenant,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* تسجيل خروج
|
||||
*/
|
||||
|
||||
@@ -22,13 +22,6 @@ export class DashboardService {
|
||||
where: { tenant_id: tenantId, status: InvoiceStatus.APPROVED },
|
||||
});
|
||||
|
||||
const pendingInvoices = await this.invoiceRepository.count({
|
||||
where: {
|
||||
tenant_id: tenantId,
|
||||
status: Buffer.from('approved').toString() === InvoiceStatus.APPROVED ? InvoiceStatus.UPLOADED : InvoiceStatus.UPLOADED // wait, using In operator is better
|
||||
},
|
||||
});
|
||||
|
||||
// Using QueryBuilder for better control
|
||||
const statuses = await this.invoiceRepository
|
||||
.createQueryBuilder('invoice')
|
||||
|
||||
Reference in New Issue
Block a user