feat: purchase-plans global update
This commit is contained in:
@@ -38,6 +38,7 @@ interface CreatePlacementsDialogProps {
|
||||
projectId: string;
|
||||
existingPlacements: Placement[];
|
||||
prefilledCreativeId?: string | null;
|
||||
prefilledChannelIds?: string[] | null;
|
||||
open?: boolean;
|
||||
onOpenChange?: (open: boolean) => void;
|
||||
onSuccess: () => void;
|
||||
@@ -52,6 +53,7 @@ export function CreatePlacementsDialog({
|
||||
projectId,
|
||||
existingPlacements,
|
||||
prefilledCreativeId = null,
|
||||
prefilledChannelIds = null,
|
||||
open: controlledOpen,
|
||||
onOpenChange,
|
||||
onSuccess,
|
||||
@@ -120,8 +122,9 @@ export function CreatePlacementsDialog({
|
||||
if (isOpen) {
|
||||
loadCreatives();
|
||||
loadProjectChannels();
|
||||
loadPrefilledChannels();
|
||||
}
|
||||
}, [isOpen, workspaceId, projectId, prefilledCreativeId]);
|
||||
}, [isOpen, workspaceId, projectId, prefilledCreativeId, prefilledChannelIds]);
|
||||
|
||||
const loadCreatives = async () => {
|
||||
try {
|
||||
@@ -153,6 +156,24 @@ export function CreatePlacementsDialog({
|
||||
}
|
||||
};
|
||||
|
||||
const loadPrefilledChannels = async () => {
|
||||
if (!prefilledChannelIds || prefilledChannelIds.length === 0) return;
|
||||
|
||||
try {
|
||||
const projectPlacements = await placementsApi.getByProject(workspaceId, projectId);
|
||||
const prefilledChannels = projectPlacements
|
||||
.filter((p) => prefilledChannelIds.includes(p.channel.id))
|
||||
.map((p) => ({
|
||||
username: p.channel.username || p.channel.title,
|
||||
channelId: p.channel.id,
|
||||
}));
|
||||
|
||||
setSelectedChannels(prefilledChannels);
|
||||
} catch (err) {
|
||||
console.error("Failed to load prefilled channels:", err);
|
||||
}
|
||||
};
|
||||
|
||||
const addChannel = async () => {
|
||||
const username = parseChannelInput(newChannelInput);
|
||||
if (!username) {
|
||||
|
||||
Reference in New Issue
Block a user