Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: segment config is unavailable for news #965

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@ import { Typography } from "@mui/material";
import { SegmentPicker } from "components/Segment/SegmentPicker";
import { PlatformPicker } from "components/Platform/PlatformPicker";
import { CardContainer } from "components/Card/CardContainer";
import { useField } from "formik";
import { CampaignFormat } from "graphql/types";

interface Props {
index: number;
}

export function PickerFields({ index }: Props) {
const [, format] = useField<CampaignFormat>("format");

return (
<>
<CardContainer header="Categories">
<Typography variant="body2" sx={{ mb: 2 }}>
Select the audience you would like to advertise to by interests.
</Typography>
<SegmentPicker idx={index} />
</CardContainer>
{format.value !== CampaignFormat.NewsDisplayAd && (
<CardContainer header="Categories">
<Typography variant="body2" sx={{ mb: 2 }}>
Select the audience you would like to advertise to by interests.
</Typography>
<SegmentPicker idx={index} />
</CardContainer>
)}

<CardContainer header="Platforms">
<Typography variant="body2" sx={{ mb: 2 }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
errors?: string | FormikErrors<AdSetForm>;
}

export function AdSetReview({ adSet, idx, errors }: Props) {
export function AdSetReview({ adSet, idx, errors, format }: Props) {
const included = adSet.creatives.filter((c) => c.included);
const hasErrors = !!errors;
if (typeof errors === "string") {
Expand All @@ -37,11 +37,13 @@ export function AdSetReview({ adSet, idx, errors }: Props) {
value={adSet.name || `Ad Set ${idx + 1}`}
error={hasErrors ? adSetError?.name : ""}
/>
<ReviewField
caption="Audiences"
value={segmentValue(mapToString(adSet.segments))}
error={hasErrors ? (adSetError?.segments as string) : ""}
/>
{format !== CampaignFormat.NewsDisplayAd && (
<ReviewField
caption="Audiences"
value={segmentValue(mapToString(adSet.segments))}
error={hasErrors ? (adSetError?.segments as string) : ""}
/>
)}
<ReviewField
caption="Platforms"
value={mapToString(adSet.oses)}
Expand Down