Merge pull request #480 from R0m1k3/1.1

1.1
This commit is contained in:
LogiFlow authored and GitHub committed 2025-10-10 18:28:18 +02:00
commit 5b136cb821
3 files changed
+35 -4

No files matched your search

-4
View File
@@ -31,10 +31,6 @@ externalPort = 3003
localPort = 34203
externalPort = 8080
[[ports]]
localPort = 35937
externalPort = 8099
[[ports]]
localPort = 38343
externalPort = 3000
Binary file not shown.

After

Width:  |  Height:  |  Size: 242 KiB

+35
View File
@@ -3573,6 +3573,41 @@ export async function registerRoutes(app: Express): Promise<Server> {
}
});
// Get all publicities (with optional year and store filtering)
app.get('/api/publicities', isAuthenticated, async (req: any, res) => {
try {
const user = await storage.getUserWithGroups(req.user.claims ? req.user.claims.sub : req.user.id);
if (!user) {
return res.status(404).json({ message: "User not found" });
}
const { year, storeId } = req.query;
let groupIds: number[] | undefined;
// Determine which groups to filter by
if (user.role === 'admin') {
// Admins can filter by specific store or see all
groupIds = storeId ? [parseInt(storeId as string)] : undefined;
} else {
// Non-admins see only their assigned groups
const userGroupIds = user.userGroups.map(ug => ug.groupId);
if (storeId && userGroupIds.includes(parseInt(storeId as string))) {
groupIds = [parseInt(storeId as string)];
} else {
groupIds = userGroupIds;
}
}
const yearNum = year ? parseInt(year as string) : undefined;
const publicities = await storage.getPublicities(yearNum, groupIds);
res.json(publicities);
} catch (error) {
console.error("Error fetching publicities:", error);
res.status(500).json([]);
}
});
app.post('/api/publicities', isAuthenticated, async (req: any, res) => {
try {
const user = await storage.getUserWithGroups(req.user.claims ? req.user.claims.sub : req.user.id);