brendmanager/public/opportunities.html
Peppa 57cbe48a45
All checks were successful
peppa/lint lint: success за 0с
peppa/test test: success за 0с
ci / checks (pull_request) Successful in 18s
deploy / deploy (pull_request) Successful in 2s
BRM-15: карточки PR-возможностей и воронка по стадиям
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 14:56:47 +05:00

39 lines
3.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="ru"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>PR-возможности</title>
<style>
body{font:15px system-ui,sans-serif;margin:0;padding:16px;max-width:1100px;margin:auto;color:#222}
h1{font-size:20px}table{border-collapse:collapse;width:100%}td,th{border:1px solid #ddd;padding:4px 8px;text-align:left}
tr.overdue{background:#ffe3e0}tr.row{cursor:pointer}form{display:grid;gap:6px;max-width:460px;margin-top:16px}#err{color:#b00}
</style></head><body>
<h1>PR-возможности</h1>
<p>Только возможности, которые Татьяна нашла и ведёт сама. Без рассылок, покупки баз контактов и продаж.</p>
<div>Стадия: <select id="filter"></select> <span id="err"></span></div>
<table id="list"></table>
<form id="f"><input type="hidden" id="id">
<input id="title" placeholder="Название мероприятия *"><input id="organizer" placeholder="Организатор">
<label>Дедлайн <input type="date" id="deadline"></label><input id="topic" placeholder="Тема выступления">
<select id="stage"></select><input id="nextStep" placeholder="Следующий шаг"><select id="type"></select>
<input id="url" placeholder="Ссылка на мероприятие"><textarea id="notes" placeholder="Заметки"></textarea>
<div><button>Сохранить</button> <button type="button" id="del" hidden>Удалить</button> <button type="button" id="new">Новая</button></div></form>
<script>
let META,ITEMS=[];const $=id=>document.getElementById(id);
const esc=s=>String(s??"").replace(/[&<>"']/g,c=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[c]));
const F=["title","organizer","deadline","topic","stage","nextStep","type","url","notes"];
async function api(m,u,b){const r=await fetch(u,{method:m,headers:{"content-type":"application/json"},body:b&&JSON.stringify(b)});
const d=await r.json();$("err").textContent=r.ok?"":d.error;return r.ok?d:null}
async function load(){const d=await api("GET","/api/opportunities?stage="+encodeURIComponent($("filter").value));if(d){ITEMS=d.items;render()}}
function render(){$("list").innerHTML="<tr><th>Название</th><th>Организатор</th><th>Дедлайн</th><th>Стадия</th><th>Следующий шаг</th></tr>"+
(ITEMS.map(o=>`<tr class="row ${o.overdue?"overdue":""}" data-id="${o.id}"><td>${esc(o.title)}</td><td>${esc(o.organizer)}</td><td>${esc(o.deadline||"—")}${o.overdue?" (просрочено)":""}</td><td>${esc(o.stage)}</td><td>${esc(o.nextStep)}</td></tr>`).join("")||"<tr><td colspan=5><i>пусто</i></td></tr>")}
function fill(o){$("id").value=o?o.id:"";for(const k of F)$(k).value=o?(o[k]??""):(k==="stage"?META.stages[0]:"");$("del").hidden=!o}
document.addEventListener("click",e=>{const r=e.target.closest("tr.row");if(r)fill(ITEMS.find(o=>o.id==r.dataset.id))});
$("new").onclick=()=>fill(null);$("filter").onchange=load;
$("del").onclick=async()=>{if(confirm("Удалить карточку окончательно?")&&await api("DELETE","/api/opportunities/"+$("id").value)){fill(null);load()}};
$("f").onsubmit=async e=>{e.preventDefault();const b={};for(const k of F)b[k]=$(k).value;b.deadline=b.deadline||null;
const id=$("id").value;if(await(id?api("PUT","/api/opportunities/"+id,b):api("POST","/api/opportunities",b))){fill(null);load()}};
api("GET","/api/opportunities/meta").then(m=>{META=m;
$("filter").innerHTML='<option value="">Все</option>'+m.stages.map(s=>`<option>${esc(s)}</option>`).join("");
$("stage").innerHTML=m.stages.map(s=>`<option>${esc(s)}</option>`).join("");
$("type").innerHTML='<option value="">—</option>'+m.types.map(s=>`<option>${esc(s)}</option>`).join("");fill(null);load()});
</script></body></html>