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: make sure campaign creation is not exposed accidentally #865

Merged
merged 5 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
18 changes: 18 additions & 0 deletions src/user/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Navbar } from "components/Navigation/Navbar";
import { CampaignView } from "user/views/user/CampaignView";
import { CampaignReportView } from "user/views/user/CampaignReportView";
import { Profile } from "user/views/user/Profile";
import { IAdvertiser } from "auth/context/auth.interface";

const buildApolloClient = () => {
const httpLink = createHttpLink({
Expand Down Expand Up @@ -50,11 +51,19 @@ export function User() {
<ProtectedRoute
path="/user/main/adsmanager/advanced/new/:draftId"
authedComponent={NewCampaign}
validateAdvertiserProperty={{
key: "selfServiceCreate",
val: true,
}}
/>

<ProtectedRoute
path="/user/main/adsmanager/advanced/:campaignId"
authedComponent={EditCampaign}
validateAdvertiserProperty={{
key: "selfServiceEdit",
val: true,
}}
/>

<ProtectedRoute
Expand Down Expand Up @@ -92,19 +101,28 @@ interface ProtectedProps {
authedComponent?: ComponentType;
unauthedComponent?: ComponentType;
path?: string;
validateAdvertiserProperty?: { key: keyof IAdvertiser; val: any };
IanKrieger marked this conversation as resolved.
Show resolved Hide resolved
}

const ProtectedRoute = ({
authedComponent,
unauthedComponent,
path,
validateAdvertiserProperty,
}: ProtectedProps) => {
const { advertiser } = useAdvertiser();

if (!advertiser.agreed && unauthedComponent === undefined) {
return <Redirect to="/user/main" />;
}

if (
validateAdvertiserProperty &&
advertiser[validateAdvertiserProperty.key] != validateAdvertiserProperty.val
IanKrieger marked this conversation as resolved.
Show resolved Hide resolved
) {
return <Redirect to="/user/main" />;
}

return (
<Route
path={path}
Expand Down
1 change: 0 additions & 1 deletion src/user/campaignList/CampaignList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ interface CheckBoxProps {
onCampaignSelect: (c: string, insert: boolean) => void;
}
const CampaignCheckBox = (props: CheckBoxProps) => {
console.log(props.selectedCampaigns);
const campaignSelected = props.selectedCampaigns.some(
(c) => c === props.campaign.id,
);
Expand Down