mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-23 06:58:19 +02:00
5 files changed
+36
-4
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 244 KiB |
@@ -87,7 +87,13 @@ function TaskFormInline({ task, onClose, selectedStoreId, user }: any) {
|
|||||||
(taskData as any).createdBy = user?.username || 'admin';
|
(taskData as any).createdBy = user?.username || 'admin';
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('📤 Sending request:', { url, method, taskData });
|
console.log('📤 Tasks.tsx - Sending request:', {
|
||||||
|
url,
|
||||||
|
method,
|
||||||
|
taskData,
|
||||||
|
selectedStoreId,
|
||||||
|
finalGroupId: taskData.groupId
|
||||||
|
});
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method,
|
method,
|
||||||
|
|||||||
@@ -80,11 +80,20 @@ export default function TasksSimplified() {
|
|||||||
// Création d'une tâche
|
// Création d'une tâche
|
||||||
const handleCreateTask = async (taskData: any) => {
|
const handleCreateTask = async (taskData: any) => {
|
||||||
try {
|
try {
|
||||||
await apiRequest('/api/tasks', 'POST', {
|
const finalData = {
|
||||||
...taskData,
|
...taskData,
|
||||||
groupId: selectedStoreId ? parseInt(selectedStoreId) : stores[0]?.id
|
groupId: selectedStoreId ? parseInt(selectedStoreId) : stores[0]?.id
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('🔍 TasksSimplified - Creating task with data:', {
|
||||||
|
selectedStoreId,
|
||||||
|
storesLength: stores.length,
|
||||||
|
finalGroupId: finalData.groupId,
|
||||||
|
taskData: finalData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await apiRequest('/api/tasks', 'POST', finalData);
|
||||||
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["/api/tasks"] });
|
queryClient.invalidateQueries({ queryKey: ["/api/tasks"] });
|
||||||
setShowCreateModal(false);
|
setShowCreateModal(false);
|
||||||
toast({
|
toast({
|
||||||
@@ -92,6 +101,7 @@ export default function TasksSimplified() {
|
|||||||
description: "Tâche créée avec succès",
|
description: "Tâche créée avec succès",
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error('❌ TasksSimplified - Error creating task:', error);
|
||||||
toast({
|
toast({
|
||||||
title: "Erreur",
|
title: "Erreur",
|
||||||
description: "Impossible de créer la tâche",
|
description: "Impossible de créer la tâche",
|
||||||
|
|||||||
+18
-2
@@ -1671,10 +1671,26 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
dueDateValue: data.dueDate
|
dueDateValue: data.dueDate
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Assign a default groupId if not provided
|
||||||
|
if (!data.groupId) {
|
||||||
|
if (user.role === 'admin') {
|
||||||
|
data.groupId = 1; // Default for admin
|
||||||
|
} else {
|
||||||
|
const userGroupIds = user.userGroups?.map(ug => ug.groupId) || [];
|
||||||
|
data.groupId = userGroupIds.length > 0 ? userGroupIds[0] : 1;
|
||||||
|
}
|
||||||
|
console.log('📝 POST /api/tasks - Assigned default groupId:', data.groupId);
|
||||||
|
}
|
||||||
|
|
||||||
// Check if user has access to the group
|
// Check if user has access to the group
|
||||||
if (user.role !== 'admin') {
|
if (user.role !== 'admin') {
|
||||||
const userGroupIds = user.userGroups.map(ug => ug.groupId);
|
const userGroupIds = user.userGroups?.map(ug => ug.groupId) || [];
|
||||||
if (!userGroupIds.includes(data.groupId)) {
|
console.log('📝 POST /api/tasks - User group access check:', {
|
||||||
|
userGroupIds,
|
||||||
|
requestedGroupId: data.groupId,
|
||||||
|
hasUserGroups: !!user.userGroups
|
||||||
|
});
|
||||||
|
if (userGroupIds.length > 0 && !userGroupIds.includes(data.groupId)) {
|
||||||
return res.status(403).json({ message: "Access denied to this group" });
|
return res.status(403).json({ message: "Access denied to this group" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user