forked from politics-rewired/Spoke
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(second-pass): implement as task
- Loading branch information
Showing
14 changed files
with
358 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import type { User } from "@spoke/spoke-codegen"; | ||
import { r } from "src/server/models"; | ||
|
||
import { accessRequired } from "../errors"; | ||
|
||
export const getSecondPassCampaign = async (campaignId: number, user: User) => { | ||
// verify permissions | ||
const campaign = await r | ||
.knex("campaign") | ||
.where({ id: campaignId }) | ||
.first(["organization_id", "is_archived", "autosend_status"]); | ||
|
||
const organizationId = campaign.organization_id; | ||
await accessRequired(user, organizationId, "ADMIN", true); | ||
return campaign; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import ReactDOMServer from "react-dom/server"; | ||
|
||
import { config } from "../../../config"; | ||
|
||
export interface MarkSecondPassProps { | ||
campaignId: number; | ||
organizationId: number; | ||
campaignTitle: string; | ||
unmark?: boolean; | ||
} | ||
|
||
const MarkSecondPass: React.FC<MarkSecondPassProps> = ({ | ||
campaignId, | ||
campaignTitle, | ||
organizationId, | ||
unmark | ||
}) => { | ||
const titleLink = ( | ||
<a | ||
href={`${config.BASE_URL}/admin/${organizationId}/campaigns/${campaignId}`} | ||
> | ||
{campaignTitle} | ||
</a> | ||
); | ||
return ( | ||
<> | ||
<p> | ||
Your second pass {unmark ? "un" : ""}marking for {titleLink} is | ||
complete! Navigate back to the campaign here: {titleLink} | ||
</p> | ||
<p>-- The Spoke Rewired Team</p> | ||
</> | ||
); | ||
}; | ||
|
||
export const getContent = async (props: MarkSecondPassProps) => { | ||
const template = <MarkSecondPass {...props} />; | ||
return ReactDOMServer.renderToStaticMarkup(template); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.