({ id, onBack, onDeleted }: Props)
| 10 | } |
| 11 | |
| 12 | export function QueryView({ id, onBack, onDeleted }: Props) { |
| 13 | const [query, setQuery] = useState<(Query & { members: Session[] }) | null>(null); |
| 14 | |
| 15 | useEffect(() => { |
| 16 | api.getQuery(id).then(setQuery).catch(console.error); |
| 17 | }, [id]); |
| 18 | |
| 19 | if (!query) |
| 20 | return ( |
| 21 | <div className="work-body"> |
| 22 | <div className="empty">Loading...</div> |
| 23 | </div> |
| 24 | ); |
| 25 | |
| 26 | const del = async () => { |
| 27 | if (!confirm(`Delete query "${query.name}"?`)) return; |
| 28 | await api.deleteQuery(id); |
| 29 | onDeleted(); |
| 30 | }; |
| 31 | |
| 32 | const run = async () => { |
| 33 | await api.runQuery(id); |
| 34 | setQuery(await api.getQuery(id)); |
| 35 | }; |
| 36 | |
| 37 | return ( |
| 38 | <> |
| 39 | <div className="work-header"> |
| 40 | <button className="back-btn" onClick={onBack}> |
| 41 | Back |
| 42 | </button> |
| 43 | <div style={{ flex: 1 }}> |
| 44 | <div className="work-title">{query.name}</div> |
| 45 | <div className="work-sub">{query.members.length} sessions</div> |
| 46 | </div> |
| 47 | <button className="btn secondary" onClick={run}> |
| 48 | Run |
| 49 | </button> |
| 50 | <button className="btn secondary" onClick={del}> |
| 51 | Delete |
| 52 | </button> |
| 53 | </div> |
| 54 | <div className="work-body"> |
| 55 | <h3 |
| 56 | style={{ |
| 57 | fontSize: 12, |
| 58 | color: 'var(--text-muted)', |
| 59 | margin: '0 0 10px', |
| 60 | textTransform: 'uppercase', |
| 61 | letterSpacing: '0.06em', |
| 62 | }} |
| 63 | > |
| 64 | Query |
| 65 | </h3> |
| 66 | <pre |
| 67 | className="mono" |
| 68 | style={{ |
| 69 | fontSize: 12, |
nothing calls this directly
no test coverage detected