Skip to content

Commit

Permalink
fix: segment config is unavailable for news (#965)
Browse files Browse the repository at this point in the history
* fix: hide segment config in news

* fix: hide in review
  • Loading branch information
IanKrieger authored Nov 6, 2023
1 parent 1399a88 commit 5788339
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
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

0 comments on commit 5788339

Please sign in to comment.