mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-15 19:29:54 +02:00
Add ability to view and manage DLC products with role-based access
Implement API endpoints for fetching DLC products, their statistics, and individual details, with filtering and permission checks based on user roles and group IDs. Update storage methods to support group-based filtering for customer orders, DLC products, and tasks. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7c468936-2a88-4686-ac0a-84921a45222d Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/7c468936-2a88-4686-ac0a-84921a45222d/KsafRhL
This commit is contained in:
1 parent
9fd0a9d26c
commit
5f5ea30c78
5 files changed
+524
-10
No files matched your search
+40
-8
@@ -1464,8 +1464,14 @@ export class MemStorage implements IStorage {
|
||||
async getPublicityParticipations(): Promise<PublicityParticipation[]> { return []; }
|
||||
async setPublicityParticipations(): Promise<void> {}
|
||||
|
||||
async getCustomerOrders(): Promise<CustomerOrderWithRelations[]> {
|
||||
return Array.from(this.customerOrders.values()).map(order => ({
|
||||
async getCustomerOrders(groupIds?: number[]): Promise<CustomerOrderWithRelations[]> {
|
||||
let orders = Array.from(this.customerOrders.values());
|
||||
|
||||
if (groupIds && groupIds.length > 0) {
|
||||
orders = orders.filter(order => groupIds.includes(order.groupId));
|
||||
}
|
||||
|
||||
return orders.map(order => ({
|
||||
...order,
|
||||
supplier: this.suppliers.get(order.supplierId)!,
|
||||
group: this.groups.get(order.groupId)!,
|
||||
@@ -1515,8 +1521,23 @@ export class MemStorage implements IStorage {
|
||||
this.customerOrders.delete(id);
|
||||
}
|
||||
|
||||
async getDlcProducts(): Promise<DlcProductWithRelations[]> {
|
||||
return Array.from(this.dlcProducts.values()).map(product => ({
|
||||
async getDlcProducts(groupIds?: number[], filters?: { status?: string; supplierId?: number; }): Promise<DlcProductWithRelations[]> {
|
||||
let products = Array.from(this.dlcProducts.values());
|
||||
|
||||
if (groupIds && groupIds.length > 0) {
|
||||
products = products.filter(product => groupIds.includes(product.groupId));
|
||||
}
|
||||
|
||||
if (filters) {
|
||||
if (filters.status) {
|
||||
products = products.filter(product => product.status === filters.status);
|
||||
}
|
||||
if (filters.supplierId) {
|
||||
products = products.filter(product => product.supplierId === filters.supplierId);
|
||||
}
|
||||
}
|
||||
|
||||
return products.map(product => ({
|
||||
...product,
|
||||
supplier: this.suppliers.get(product.supplierId)!,
|
||||
group: this.groups.get(product.groupId)!,
|
||||
@@ -1580,12 +1601,17 @@ export class MemStorage implements IStorage {
|
||||
return { ...updatedProduct, dlcDate: new Date(updatedProduct.expiryDate) } as DlcProductFrontend;
|
||||
}
|
||||
|
||||
async getDlcStats(): Promise<{ active: number; expiringSoon: number; expired: number; }> {
|
||||
async getDlcStats(groupIds?: number[]): Promise<{ active: number; expiringSoon: number; expired: number; }> {
|
||||
const today = new Date();
|
||||
const alertDate = new Date();
|
||||
alertDate.setDate(today.getDate() + 15);
|
||||
|
||||
const products = Array.from(this.dlcProducts.values());
|
||||
let products = Array.from(this.dlcProducts.values());
|
||||
|
||||
if (groupIds && groupIds.length > 0) {
|
||||
products = products.filter(product => groupIds.includes(product.groupId));
|
||||
}
|
||||
|
||||
return {
|
||||
active: products.filter(p => new Date(p.expiryDate) > today).length,
|
||||
expiringSoon: products.filter(p => {
|
||||
@@ -1596,8 +1622,14 @@ export class MemStorage implements IStorage {
|
||||
};
|
||||
}
|
||||
|
||||
async getTasks(): Promise<TaskWithRelations[]> {
|
||||
return Array.from(this.tasks.values()).map(task => ({
|
||||
async getTasks(groupIds?: number[]): Promise<TaskWithRelations[]> {
|
||||
let tasks = Array.from(this.tasks.values());
|
||||
|
||||
if (groupIds && groupIds.length > 0) {
|
||||
tasks = tasks.filter(task => groupIds.includes(task.groupId));
|
||||
}
|
||||
|
||||
return tasks.map(task => ({
|
||||
...task,
|
||||
group: this.groups.get(task.groupId)!,
|
||||
creator: this.users.get(task.createdBy)!
|
||||
|
||||
Reference in new issue
Block a user