Campaign stats in admin, user posts via new route, safer ad creation
- Admin: campaign stats panel (impressions, clicks, CTR per campaign and ad) with date range
- My posts: GET /api/v1/users/{id}/posts with paging, fallback to the legacy route
- Ad creation: retry after a failed video upload reuses the created ad; show backend 400 text
- Fullscreen ad form: only absolute http(s) target URLs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { toSafeHttpUrl } from "../utils/safeUrl";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CloseIcon from "./icons/CloseIcon";
|
||||
import {
|
||||
@@ -106,14 +107,15 @@ export default function UploadAdModal({ onClose }) {
|
||||
if (creating) return;
|
||||
let targetUrl = newTargetUrl.trim();
|
||||
if (targetUrl) {
|
||||
if (!/^https?:\/\//i.test(targetUrl)) targetUrl = `https://${targetUrl}`;
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new URL(targetUrl);
|
||||
} catch {
|
||||
if (!/^[a-z][a-z0-9+.-]*:/i.test(targetUrl)) targetUrl = `https://${targetUrl}`;
|
||||
// Бэкенд принимает только абсолютный http(s) — проверяем так же,
|
||||
// иначе "javascript:..." дошёл бы до сервера и вернулся бы 400
|
||||
const safe = toSafeHttpUrl(targetUrl);
|
||||
if (!safe) {
|
||||
setCreateError(t("adminPanel.urlInvalid"));
|
||||
return;
|
||||
}
|
||||
targetUrl = safe;
|
||||
}
|
||||
setCreating(true);
|
||||
setCreateError("");
|
||||
|
||||
Reference in New Issue
Block a user