/** * Jira Tasks page — loads from /api/jira-tasks. * Разработчик: АО «REFLY» */ 'use client'; import { useState, useEffect } from 'react'; import { PageLayout, FilterBar, StatusBadge, EmptyState } from '@/components/ui'; interface JiraTask { issueId: string; summary: string; description?: string; priority: string; status?: string; components?: string[]; labels?: string[]; stories?: JiraTask[]; createdAt?: string; } export default function JiraTasksPage() { const [epics, setEpics] = useState([]); const [loading, setLoading] = useState(true); const [expanded, setExpanded] = useState(null); const [priorityFilter, setPriorityFilter] = useState(); useEffect(() => { (async () => { try { const r = await fetch('/api/jira-tasks'); const data = await r.json(); setEpics(data.epics || data || []); } catch { setEpics([]); } finally { setLoading(false); } })(); }, []); const filtered = priorityFilter ? epics.filter(e => e.priority === priorityFilter) : epics; const priorities = Array.from(new Set(epics.map(e => e.priority).filter(Boolean))); return ( ({ value: p, label: p }))]} /> {loading ?
Загрузка...
: filtered.length > 0 ? (
{filtered.map(epic => (
setExpanded(expanded === epic.issueId ? null : epic.issueId)}>
{epic.issueId}
{epic.summary}
{epic.components && epic.components.length > 0 && (
{epic.components.map(c => {c})}
)}
{epic.stories && {epic.stories.length} задач} {expanded === epic.issueId ? '▼' : '▶'}
{expanded === epic.issueId && (
{epic.description &&
{epic.description}
} {epic.stories && epic.stories.length > 0 ? (
{epic.stories.map(story => (
{story.issueId}
{story.summary}
{story.labels && story.labels.length > 0 && (
{story.labels.map(l => {l})}
)}
))}
) :
Нет подзадач
}
)}
))}
) : }
); }