mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-22 14:38:19 +02:00
Merge pull request #268 from R0m1k3/1.1
Improve task feedback and show scheduled tasks to directors
This commit is contained in:
2 files changed
+38
-7
No files matched your search
@@ -40,6 +40,7 @@ type TaskWithRelations = Task & {
|
|||||||
|
|
||||||
// Composant TaskForm inline - Version production ultra-simple
|
// Composant TaskForm inline - Version production ultra-simple
|
||||||
function TaskFormInline({ task, onClose }: any) {
|
function TaskFormInline({ task, onClose }: any) {
|
||||||
|
const { toast } = useToast();
|
||||||
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -53,12 +54,20 @@ function TaskFormInline({ task, onClose }: any) {
|
|||||||
const dueDate = formData.get('dueDate') as string;
|
const dueDate = formData.get('dueDate') as string;
|
||||||
|
|
||||||
if (!title?.trim()) {
|
if (!title?.trim()) {
|
||||||
alert("Le titre est requis");
|
toast({
|
||||||
|
title: "Erreur",
|
||||||
|
description: "Le titre est requis",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!assignedTo?.trim()) {
|
if (!assignedTo?.trim()) {
|
||||||
alert("L'assignation est requise");
|
toast({
|
||||||
|
title: "Erreur",
|
||||||
|
description: "L'assignation est requise",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,12 +110,19 @@ function TaskFormInline({ task, onClose }: any) {
|
|||||||
throw new Error(`Erreur ${response.status}: ${errorText}`);
|
throw new Error(`Erreur ${response.status}: ${errorText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
alert(task ? "Tâche modifiée avec succès" : "Tâche créée avec succès");
|
toast({
|
||||||
|
title: "Succès",
|
||||||
|
description: task ? "Tâche modifiée avec succès" : "Tâche créée avec succès",
|
||||||
|
});
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Erreur:', error);
|
console.error('Erreur:', error);
|
||||||
alert("Erreur lors de l'opération");
|
toast({
|
||||||
|
title: "Erreur",
|
||||||
|
description: "Erreur lors de l'opération",
|
||||||
|
variant: "destructive",
|
||||||
|
});
|
||||||
submitBtn.disabled = false;
|
submitBtn.disabled = false;
|
||||||
submitBtn.textContent = task ? "Modifier" : "Créer";
|
submitBtn.textContent = task ? "Modifier" : "Créer";
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-3
@@ -1612,7 +1612,7 @@ export class DatabaseStorage implements IStorage {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Admin et directeur voient toutes les tâches (pas de filtre additionnel)
|
// Admin et directeur voient toutes les tâches, y compris les tâches programmées
|
||||||
|
|
||||||
if (whereConditions.length > 0) {
|
if (whereConditions.length > 0) {
|
||||||
query = query.where(and(...whereConditions));
|
query = query.where(and(...whereConditions));
|
||||||
@@ -2950,17 +2950,32 @@ export class MemStorage implements IStorage {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTasks(groupIds?: number[]): Promise<TaskWithRelations[]> {
|
async getTasks(groupIds?: number[], userRole?: string): Promise<TaskWithRelations[]> {
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
let tasks = Array.from(this.tasks.values());
|
let tasks = Array.from(this.tasks.values());
|
||||||
|
|
||||||
if (groupIds && groupIds.length > 0) {
|
if (groupIds && groupIds.length > 0) {
|
||||||
tasks = tasks.filter(task => groupIds.includes(task.groupId));
|
tasks = tasks.filter(task => groupIds.includes(task.groupId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filtrage par rôle pour la date de départ
|
||||||
|
if (userRole === 'manager' || userRole === 'employee') {
|
||||||
|
// Managers et employés : seulement les tâches dont la date de départ est atteinte ou passée
|
||||||
|
tasks = tasks.filter(task => {
|
||||||
|
if (!task.startDate) return true; // Tâches sans date de départ (toujours visibles)
|
||||||
|
const startDate = new Date(task.startDate);
|
||||||
|
return startDate <= today; // Tâches dont la date de départ est arrivée
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// Admin et directeur voient toutes les tâches, y compris les tâches programmées
|
||||||
|
|
||||||
return tasks.map(task => ({
|
return tasks.map(task => ({
|
||||||
...task,
|
...task,
|
||||||
group: this.groups.get(task.groupId)!,
|
group: this.groups.get(task.groupId)!,
|
||||||
creator: this.users.get(task.createdBy)!
|
creator: this.users.get(task.createdBy)!,
|
||||||
|
isFutureTask: task.startDate ? new Date(task.startDate) > today : false
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user