working leantime widget 84
This commit is contained in:
parent
0ba915bddb
commit
b038d48e7e
@ -72,7 +72,7 @@ export function Flow() {
|
|||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Failed to fetch tasks');
|
throw new Error('Failed to fetch tasks');
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
const data: ApiResponse = await response.json();
|
||||||
|
|
||||||
// Extract tasks from the result property
|
// Extract tasks from the result property
|
||||||
const tasksList = data.result || [];
|
const tasksList = data.result || [];
|
||||||
@ -83,9 +83,8 @@ export function Flow() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter tasks with status 3 and sort by date
|
// Sort tasks by date and limit to 4
|
||||||
const filteredAndSortedTasks = tasksList
|
const sortedTasks = tasksList
|
||||||
.filter((task: Task) => task.status === 3 && task.userId === 2)
|
|
||||||
.sort((a: Task, b: Task) => {
|
.sort((a: Task, b: Task) => {
|
||||||
const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() :
|
const dateA = a.dateToFinish ? new Date(a.dateToFinish).getTime() :
|
||||||
a.date ? new Date(a.date).getTime() : Date.now();
|
a.date ? new Date(a.date).getTime() : Date.now();
|
||||||
@ -95,8 +94,7 @@ export function Flow() {
|
|||||||
})
|
})
|
||||||
.slice(0, 4); // Limit to 4 tasks
|
.slice(0, 4); // Limit to 4 tasks
|
||||||
|
|
||||||
console.log('Filtered tasks:', filteredAndSortedTasks); // Debug log
|
setTasks(sortedTasks);
|
||||||
setTasks(filteredAndSortedTasks);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching tasks:', error);
|
console.error('Error fetching tasks:', error);
|
||||||
setError('Failed to fetch tasks');
|
setError('Failed to fetch tasks');
|
||||||
@ -112,7 +110,7 @@ export function Flow() {
|
|||||||
return (
|
return (
|
||||||
<Card className="transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/80 backdrop-blur-sm">
|
<Card className="transition-transform duration-500 ease-in-out transform hover:scale-105 bg-white/80 backdrop-blur-sm">
|
||||||
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
<CardHeader className="flex flex-row items-center justify-between pb-2">
|
||||||
<CardTitle className="text-2xl font-bold">Flow</CardTitle>
|
<CardTitle className="text-lg font-medium">Flow</CardTitle>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
@ -132,18 +130,18 @@ export function Flow() {
|
|||||||
) : tasks.length === 0 ? (
|
) : tasks.length === 0 ? (
|
||||||
<div className="text-sm text-muted-foreground text-center">No tasks found</div>
|
<div className="text-sm text-muted-foreground text-center">No tasks found</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="space-y-3 max-h-[400px] overflow-y-auto pr-2">
|
<div className="space-y-2 max-h-[400px] overflow-y-auto pr-2">
|
||||||
{tasks.map((task) => (
|
{tasks.map((task) => (
|
||||||
<div
|
<div
|
||||||
key={task.id}
|
key={task.id}
|
||||||
className="p-3 rounded-xl bg-white/90 shadow-sm hover:shadow-md transition-all duration-200"
|
className="p-3 rounded-lg bg-white/90 shadow-sm hover:shadow-md transition-all duration-200"
|
||||||
>
|
>
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<a
|
<a
|
||||||
href={`https://agilite.slm-lab.net/tickets/showTicket/${task.id}`}
|
href={`https://agilite.slm-lab.net/tickets/showTicket/${task.id}`}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
className="text-blue-500 hover:text-blue-600 font-medium block text-sm"
|
className="text-sm text-blue-500 hover:text-blue-600 font-medium block truncate"
|
||||||
>
|
>
|
||||||
{task.headline}
|
{task.headline}
|
||||||
</a>
|
</a>
|
||||||
@ -151,7 +149,7 @@ export function Flow() {
|
|||||||
{task.projectName && (
|
{task.projectName && (
|
||||||
<>
|
<>
|
||||||
<Folder className="h-3 w-3 mr-1 opacity-70" />
|
<Folder className="h-3 w-3 mr-1 opacity-70" />
|
||||||
<span>{task.projectName}</span>
|
<span className="truncate">{task.projectName}</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00' && (
|
{task.dateToFinish && task.dateToFinish !== '0000-00-00 00:00:00' && (
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user