mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
3 files changed
+35
-4
No files matched your search
@@ -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 |
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user