feat: add header channel selector & adding channel modal menu

This commit is contained in:
ivannoskov
2025-12-01 05:57:28 +03:00
parent d4672ea32b
commit d2cc1c39b3
22 changed files with 3473 additions and 892 deletions

View File

@@ -36,8 +36,10 @@ import {
} from "lucide-react";
import type { Creative } from "@/lib/types/api";
import { Alert, AlertDescription } from "@/components/ui/alert";
import { useTargetChannel } from "@/components/providers/target-channel-provider";
export default function CreativesPage() {
const { selectedChannel } = useTargetChannel();
const [creatives, setCreatives] = useState<Creative[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<string | null>(null);
@@ -46,13 +48,21 @@ export default function CreativesPage() {
);
useEffect(() => {
loadCreatives();
}, []);
if (selectedChannel) {
loadCreatives();
} else {
setLoading(false);
}
}, [selectedChannel]);
const loadCreatives = async () => {
if (!selectedChannel) return;
try {
setLoading(true);
const response = await creativesApi.list();
const response = await creativesApi.list({
target_channel_id: selectedChannel.id,
});
setCreatives(response.creatives);
} catch (err: any) {
setError(err?.error?.message || "Ошибка загрузки креативов");