feat: reorganize admin settings with tabbed interface and documentation
- Reorganized admin settings into tabbed interface (General, Security, Payment Methods) - Vertical tabs on desktop, horizontal scrollable on mobile - Moved Payment Methods from separate menu to Settings tab - Fixed admin profile reuse and dashboard blocking - Fixed maintenance mode guard to use AppConfig model - Added admin auto-redirect after login (admins → /admin, users → /) - Reorganized documentation into docs/ folder structure - Created comprehensive README and documentation index - Added PWA and Web Push notifications to to-do list
This commit is contained in:
104
apps/api/dist/admin/admin-users.service.js
vendored
104
apps/api/dist/admin/admin-users.service.js
vendored
@@ -1,10 +1,43 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
@@ -12,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AdminUsersService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const prisma_service_1 = require("../prisma/prisma.service");
|
||||
const bcrypt = __importStar(require("bcrypt"));
|
||||
let AdminUsersService = class AdminUsersService {
|
||||
prisma;
|
||||
constructor(prisma) {
|
||||
@@ -139,6 +173,76 @@ let AdminUsersService = class AdminUsersService {
|
||||
suspendedUsers,
|
||||
};
|
||||
}
|
||||
async create(data) {
|
||||
const existing = await this.prisma.user.findUnique({
|
||||
where: { email: data.email },
|
||||
});
|
||||
if (existing) {
|
||||
throw new common_1.ConflictException('User with this email already exists');
|
||||
}
|
||||
const hashedPassword = await bcrypt.hash(data.password, 10);
|
||||
return this.prisma.user.create({
|
||||
data: {
|
||||
email: data.email,
|
||||
passwordHash: hashedPassword,
|
||||
name: data.name || null,
|
||||
role: data.role || 'user',
|
||||
emailVerified: true,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
name: true,
|
||||
role: true,
|
||||
emailVerified: true,
|
||||
createdAt: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
async update(id, data) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
if (!user) {
|
||||
throw new common_1.NotFoundException('User not found');
|
||||
}
|
||||
if (data.email && data.email !== user.email) {
|
||||
const existing = await this.prisma.user.findUnique({
|
||||
where: { email: data.email },
|
||||
});
|
||||
if (existing) {
|
||||
throw new common_1.ConflictException('Email already in use');
|
||||
}
|
||||
}
|
||||
return this.prisma.user.update({
|
||||
where: { id },
|
||||
data: {
|
||||
...(data.email && { email: data.email }),
|
||||
...(data.name !== undefined && { name: data.name }),
|
||||
...(data.role && { role: data.role }),
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
email: true,
|
||||
name: true,
|
||||
role: true,
|
||||
emailVerified: true,
|
||||
createdAt: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
async delete(id) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
if (!user) {
|
||||
throw new common_1.NotFoundException('User not found');
|
||||
}
|
||||
await this.prisma.user.delete({
|
||||
where: { id },
|
||||
});
|
||||
return { message: 'User deleted successfully' };
|
||||
}
|
||||
};
|
||||
exports.AdminUsersService = AdminUsersService;
|
||||
exports.AdminUsersService = AdminUsersService = __decorate([
|
||||
|
||||
Reference in New Issue
Block a user