Skip to content

Commit 83ac5c5

Browse files
authored
STUD-424: Update NEWM Studio distribution pricing modal copy. (#914)
* feat: Add Distribution Pricing Modal component This commit introduces the Distribution Pricing Modal component to the project. It will continue to inform new users of the distribution pricing plan. The modal is integrated into the Basic Song Details page, replacing the existing Pricing Plans Dialog when the new payment enhancement flag is triggered. * chore: Update index export order Will reorder exports in index.ts to be in alphabetical order. Leave AppleLogin out of order to not cause Reference error. * feat: Update Distribution Pricing Modal Update the Distribution Pricing Modal to use the Modal component instead of Dialog. Update the component to match the Figma design. * test: Add tests for Distribution Pricing Modal * style: Fix spacing method in discount text * refactor: Move test for DistributionPricingModal * refactor: Distribution Pricing Dialog from Modal This commit refactors the Distribution Pricing Dialog component along with its corresponding tests from a Modal component. It also updates the theme to include a responsive H2 text size variant.
1 parent cd499b6 commit 83ac5c5

File tree

5 files changed

+503
-26
lines changed

5 files changed

+503
-26
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
import { Button, Dialog } from "@newm-web/elements";
2+
import theme from "@newm-web/theme";
3+
import { LocalStorage, formatUsdAmount } from "@newm-web/utils";
4+
import {
5+
Box,
6+
DialogActions,
7+
DialogContent,
8+
Divider,
9+
Stack,
10+
Typography,
11+
} from "@mui/material";
12+
import { Check } from "@mui/icons-material";
13+
import { LocalStorageKey, PaymentType } from "@newm-web/types";
14+
import { FunctionComponent } from "react";
15+
import { useUpdateProfileThunk } from "../../modules/session";
16+
import { useGetMintSongEstimateQuery } from "../../modules/song";
17+
18+
interface DistributionPricingDialogProps {
19+
readonly onCancel: () => void;
20+
readonly onConfirm: () => void;
21+
readonly open: boolean;
22+
}
23+
24+
/**
25+
* Allows users to select a pricing plan for music distribution.
26+
*/
27+
const DistributionPricingDialog: FunctionComponent<
28+
DistributionPricingDialogProps
29+
> = ({ onCancel, onConfirm, open }) => {
30+
const [updateProfile, { isLoading }] = useUpdateProfileThunk();
31+
32+
const handleOptionClick = () => {
33+
updateProfile({ dspPlanSubscribed: true }).then(() => {
34+
LocalStorage.setItem(LocalStorageKey.isStudioPricingPlanAccepted, "true");
35+
onConfirm();
36+
});
37+
};
38+
39+
const { data: { mintPaymentOptions } = {} } = useGetMintSongEstimateQuery({
40+
collaborators: 1,
41+
});
42+
43+
const dspPriceUsd = mintPaymentOptions?.find(
44+
(option) => option.paymentType === PaymentType.PAYPAL
45+
)?.dspPriceUsd;
46+
47+
const dspFormattedPricingUsd = formatUsdAmount(Number(dspPriceUsd), {
48+
precision: 2,
49+
returnZeroValue: false,
50+
});
51+
52+
const pricingPlanCriteria = [
53+
{ text: "Distribute your music to 130+ global platforms" },
54+
{
55+
highlight: "20% discount",
56+
highlightColor: theme.colors.baseGreen,
57+
text: "for paying in $NEWM Tokens",
58+
},
59+
{ text: "Automate royalty splits" },
60+
{ text: "Free EAN Release Code & ISRC generation" },
61+
{ text: "Add and manage release collaborators" },
62+
{ text: "Customize your artist profile" },
63+
{ text: "Track catalog status" },
64+
{ text: "Sell music rights to your fans on the NEWM Marketplace!" },
65+
];
66+
67+
return (
68+
<Dialog
69+
maxWidth="xs"
70+
open={ open }
71+
sx={ {
72+
"& .MuiPaper-root": {
73+
backgroundColor: theme.colors.grey600,
74+
border: `1px solid ${theme.colors.grey400}`,
75+
borderRadius: "12px",
76+
gap: 3.75,
77+
maxWidth: "430px",
78+
padding: [2, 4],
79+
},
80+
} }
81+
fullWidth
82+
onClose={ onCancel }
83+
>
84+
<DialogContent sx={ { p: 0 } }>
85+
<Stack
86+
sx={ {
87+
alignItems: "center",
88+
display: "flex",
89+
flex: 1,
90+
gap: 3.75,
91+
} }
92+
>
93+
<Stack sx={ { gap: 2 } } textAlign="center">
94+
<Typography
95+
sx={ {
96+
display: "flex",
97+
flexDirection: "column",
98+
fontWeight: 700,
99+
gap: 0.5,
100+
} }
101+
variant="h4"
102+
>
103+
<Box> { dspFormattedPricingUsd } / RELEASE</Box>
104+
</Typography>
105+
106+
<Stack>
107+
<Typography variant="h2">Your music, your way</Typography>
108+
<Typography
109+
sx={ {
110+
color: theme.colors.grey100,
111+
fontWeight: 500,
112+
maxWidth: "420px",
113+
} }
114+
variant="subtitle1"
115+
>
116+
Pay once to distribute and keep 100% of your future royalties!
117+
</Typography>
118+
</Stack>
119+
</Stack>
120+
121+
<Stack gap={ 1 } sx={ { maxWidth: "420px", width: "100%" } }>
122+
{ pricingPlanCriteria.map((criterion, index) => (
123+
<Box
124+
key={ index }
125+
sx={ {
126+
display: "flex",
127+
flexDirection: "row",
128+
gap: 1.5,
129+
} }
130+
>
131+
<Check sx={ { color: theme.colors.baseGreen } } />
132+
133+
<Typography
134+
alignSelf={ "center" }
135+
fontWeight={ 500 }
136+
variant="body1"
137+
>
138+
{ criterion.highlight ? (
139+
<>
140+
<Box
141+
component="span"
142+
sx={ { color: criterion.highlightColor } }
143+
>
144+
{ criterion.highlight }
145+
</Box>
146+
{ " " + criterion.text }
147+
</>
148+
) : (
149+
criterion.text
150+
) }
151+
</Typography>
152+
</Box>
153+
)) }
154+
</Stack>
155+
156+
<Divider color={ theme.colors.grey400 } sx={ { width: "70%" } } />
157+
</Stack>
158+
</DialogContent>
159+
<DialogActions
160+
sx={ {
161+
// Override MUI default DialogActions gap/margin on last button
162+
"& > :not(:first-of-type)": {
163+
marginLeft: 0,
164+
},
165+
flexDirection: "column",
166+
gap: 3.75,
167+
justifyContent: "center",
168+
p: 0,
169+
} }
170+
>
171+
<Button isLoading={ isLoading } onClick={ handleOptionClick }>
172+
Get started
173+
</Button>
174+
<Button
175+
color="music"
176+
isLoading={ isLoading }
177+
variant="secondary"
178+
onClick={ onCancel }
179+
>
180+
Cancel
181+
</Button>
182+
</DialogActions>
183+
</Dialog>
184+
);
185+
};
186+
187+
export default DistributionPricingDialog;

0 commit comments

Comments
 (0)