Skip to content

Commit

Permalink
Merge pull request #531 from guardian/pd-default-promos-digital
Browse files Browse the repository at this point in the history
Write to default-promos.json for Digital Checkout via RRCP
  • Loading branch information
paul-daniel-dempsey authored Nov 20, 2023
2 parents 0e044da + e2f8b05 commit 758813f
Show file tree
Hide file tree
Showing 2 changed files with 21 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 @@ -5,7 +5,8 @@ import io.circe.{Decoder, Encoder}

case class DefaultPromos(
guardianWeekly: Seq[String],
paper: Seq[String]
paper: Seq[String],
digital: Seq[String]
)

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

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

type DefaultPromos = {
[key in ProductName]: string[];
Expand All @@ -34,6 +34,7 @@ const DefaultPromos: React.FC<InnerProps<DefaultPromos>> = ({
}: 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 classes = useStyles();

Expand Down Expand Up @@ -73,6 +74,23 @@ const DefaultPromos: React.FC<InnerProps<DefaultPromos>> = ({
type="text"
label="Paper"
/>
<TextField
value={digitalPromoString}
name="digitalDefaultPromos"
fullWidth={true}
onChange={e => {
const inputValue = e.target.value;
setdigitalPromosString(inputValue);

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

0 comments on commit 758813f

Please sign in to comment.