/* global React, L, MZ */ const { useState, useEffect, useRef } = React; function VoteWidget({ video, onVote, userVote, disabled }) { const score = (video.up || 0) - (video.down || 0); return (
{score > 0 ? '+' : ''}{score}
); } function VideoMap({ video, theme }) { const ref = useRef(null); const inst = useRef(null); const tile = useRef(null); useEffect(() => { if (inst.current) return; const map = L.map(ref.current, { zoomControl: false, scrollWheelZoom: false, dragging: true }).setView([video.lat, video.lng], 14); inst.current = map; const icon = L.divIcon({ className: '', html: `
`, iconSize: [14,14], iconAnchor: [7,7] }); L.marker([video.lat, video.lng], { icon }).addTo(map); return () => { map.remove(); inst.current = null; }; }, [video.id]); useEffect(() => { if (!inst.current) return; if (tile.current) inst.current.removeLayer(tile.current); const t = TILES[theme === 'dark' ? 'dark' : 'light']; tile.current = L.tileLayer(t.url, { attribution: t.attr, subdomains: 'abcd' }).addTo(inst.current); }, [theme]); return
; } function Comment({ c }) { const u = c.author_profile || {}; return (
{initials(u.name || u.handle)}
{u.handle || 'anon'}
{c.body}
); } function VideoPage({ videoId, setRoute, theme, user, profile, onLogin, onToast }) { const [v, setV] = useState(null); const [userVote, setUserVote] = useState(0); const [comments, setComments] = useState([]); const [related, setRelated] = useState([]); const [loading, setLoading] = useState(true); const [commentBody, setCommentBody] = useState(''); const [reportOpen, setReportOpen] = useState(false); useEffect(() => { (async () => { setLoading(true); try { const video = await MZ.getVideo(videoId); setV(video); const [cmts, mv, rel] = await Promise.all([ MZ.listComments(videoId), user ? MZ.myVote(videoId) : Promise.resolve(0), MZ.listVideos({ severity: video.severity, limit: 5 }), ]); setComments(cmts); setUserVote(mv || 0); setRelated(rel.filter(x => x.id !== videoId).slice(0, 4)); MZ.incViews(videoId); } catch (e) { console.error(e); } setLoading(false); })(); }, [videoId, user]); const vote = async (val) => { if (!user) { onLogin(); return; } try { await MZ.castVote(videoId, val); setUserVote(val); const updated = await MZ.getVideo(videoId); setV(updated); } catch (e) { onToast('Błąd głosowania'); } }; const submitComment = async (e) => { e.preventDefault(); if (!commentBody.trim()) return; try { const nc = await MZ.addComment({ videoId, body: commentBody.trim() }); setComments([...comments, nc]); setCommentBody(''); } catch (err) { onToast(err.message || 'Błąd'); } }; if (loading) return

Ładowanie nagrania…

; if (!v) return

Nie znaleziono nagrania.

; const author = v.author_profile || {}; return (
{ e.preventDefault(); setRoute({name:'home'}); }}>START / {(v.city || 'POLSKA').toUpperCase()}
{v.youtube_id ? (