import { h } from '/static/admin2/vendor/preact.module.js'; import { useState } from '/static/admin2/vendor/hooks.module.js'; import htm from '/static/admin2/vendor/htm.module.js'; import { api } from '/static/admin2/api.js'; const html = htm.bind(h); export const Task = ({ item, onDone, onError }) => { const [busy, setBusy] = useState(false); const run = async (path, body) => { setBusy(true); try { await api(path, body ? {method: 'POST', body: JSON.stringify(body)} : {method: 'POST'}); onDone(item.key); } catch (e) { onError(e.message || 'Не удалось выполнить'); } finally { setBusy(false); } }; return html`
${item.title}

${item.detail}

`; };