Skip to content

Commit

Permalink
Merge pull request #567 from guardian/support-plus-default-promo
Browse files Browse the repository at this point in the history
feat: add supporter plus default promo code
  • Loading branch information
jamesgorrie authored Apr 11, 2024
2 parents 10f22b8 + 6fa9e9b commit 6303f4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/models/DefaultPromos.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import io.circe.{Decoder, Encoder}
case class DefaultPromos(
guardianWeekly: Seq[String],
paper: Seq[String],
digital: Seq[String]
digital: Seq[String],
supporterPlus: Option[Seq[String]],
)

object DefaultPromos {
Expand Down
22 changes: 21 additions & 1 deletion public/src/components/defaultPromos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
SupportFrontendSettingsType,
} from '../utils/requests';

type ProductName = 'guardianWeekly' | 'paper' | 'digital';
type ProductName = 'guardianWeekly' | 'paper' | 'digital' | 'supporterPlus';

type DefaultPromos = {
[key in ProductName]: string[];
Expand All @@ -36,6 +36,9 @@ const DefaultPromos: React.FC<InnerProps<DefaultPromos>> = ({
const [gwPromosString, setGwPromosString] = useState<string>(data.guardianWeekly.join(', '));
const [paperPromosString, setpaperPromosString] = useState<string>(data.paper.join(', '));
const [digitalPromoString, setdigitalPromosString] = useState<string>(data.digital.join(', '));
const [supporterPlusPromoString, setSupporterPlusPromosString] = useState<string>(
(data.supporterPlus ?? []).join(', '),
);

const classes = useStyles();

Expand Down Expand Up @@ -92,6 +95,23 @@ const DefaultPromos: React.FC<InnerProps<DefaultPromos>> = ({
type="text"
label="Digital"
/>
<TextField
value={supporterPlusPromoString}
name="supporterPlusDefaultPromos"
fullWidth={true}
onChange={e => {
const inputValue = e.target.value;
setSupporterPlusPromosString(inputValue);

const parsedInputValue = parsePromoInput(inputValue);
update({
...data,
supporterPlus: parsedInputValue,
});
}}
type="text"
label="Supporter Plus"
/>
<Button
onClick={sendToS3}
color="primary"
Expand Down

0 comments on commit 6303f4c

Please sign in to comment.