feat: add header channel selector & adding channel modal menu
This commit is contained in:
@@ -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 || "Ошибка загрузки креативов");
|
||||
|
||||
Reference in New Issue
Block a user