Merge pull request #320 from R0m1k3/1.1

1.1
This commit is contained in:
LogiFlow authored and GitHub committed 2025-09-02 11:33:37 +02:00
commit 641e924f14
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

+7 -1
View File
@@ -87,7 +87,13 @@ function TaskFormInline({ task, onClose, selectedStoreId, user }: any) {
(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, {
method,
+11 -1
View File
@@ -80,11 +80,20 @@ export default function TasksSimplified() {
// Création d'une tâche
const handleCreateTask = async (taskData: any) => {
try {
await apiRequest('/api/tasks', 'POST', {
const finalData = {
...taskData,
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"] });
setShowCreateModal(false);
toast({
@@ -92,6 +101,7 @@ export default function TasksSimplified() {
description: "Tâche créée avec succès",
});
} catch (error) {
console.error('❌ TasksSimplified - Error creating task:', error);
toast({
title: "Erreur",
description: "Impossible de créer la tâche",
+18 -2
View File
@@ -1671,10 +1671,26 @@ export async function registerRoutes(app: Express): Promise<Server> {
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
if (user.role !== 'admin') {
const userGroupIds = user.userGroups.map(ug => ug.groupId);
if (!userGroupIds.includes(data.groupId)) {
const userGroupIds = user.userGroups?.map(ug => ug.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" });
}
}