[web] promotions/students: show error message for discount generation
This commit is contained in:
parent
13f17d916a
commit
1a8fc41c7e
|
|
@ -193,9 +193,9 @@ export function PromotionsSocialDiscountCard({ variant = 'full' }: Props) {
|
|||
size="body2"
|
||||
weight="medium">
|
||||
<FormattedMessage
|
||||
defaultMessage="All GreatFrontEnd plans"
|
||||
defaultMessage="For all GreatFrontEnd plans"
|
||||
description="All pricing plans"
|
||||
id="ay9BLg"
|
||||
id="xb1fOo"
|
||||
/>
|
||||
</Text>
|
||||
<div className="mt-4">
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ export function PromotionsStudentDiscountCard({ variant = 'full' }: Props) {
|
|||
const intl = useIntl();
|
||||
const user = useUser();
|
||||
const trpcUtils = trpc.useUtils();
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const labels = usePromotionsStudentDiscountLabels();
|
||||
const discountPercentage = PROMO_STUDENT_DISCOUNT_PERCENTAGE;
|
||||
const { userProfile } = useUserProfile();
|
||||
|
|
@ -52,6 +53,9 @@ export function PromotionsStudentDiscountCard({ variant = 'full' }: Props) {
|
|||
isLoading: isGeneratingStudentDiscount,
|
||||
mutate: generateStudentDiscountPromoCode,
|
||||
} = trpc.promotions.generateStudentDiscountPromoCode.useMutation({
|
||||
onError: (err) => {
|
||||
setError(err.message);
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
setPromoCode(data);
|
||||
trpcUtils.promotions.userPromoCodes.invalidate();
|
||||
|
|
@ -171,6 +175,12 @@ export function PromotionsStudentDiscountCard({ variant = 'full' }: Props) {
|
|||
description: 'Condition for promotion',
|
||||
id: 'hhuG8E',
|
||||
}),
|
||||
intl.formatMessage({
|
||||
defaultMessage:
|
||||
'One-time use; can only be redeemed once per eligible user; duplicate accounts prohibited.',
|
||||
description: 'Condition for promotion',
|
||||
id: 'aVmS9t',
|
||||
}),
|
||||
<FormattedMessage
|
||||
key="annual"
|
||||
defaultMessage="Only applicable to <underline>GreatFrontEnd Annual plan</underline>."
|
||||
|
|
@ -230,9 +240,9 @@ export function PromotionsStudentDiscountCard({ variant = 'full' }: Props) {
|
|||
size="body2"
|
||||
weight="medium">
|
||||
<FormattedMessage
|
||||
defaultMessage="Off GreatFrontEnd Annual plan"
|
||||
defaultMessage="For GreatFrontEnd Annual plan"
|
||||
description="GFE annual plan"
|
||||
id="h1LehS"
|
||||
id="hy8jrp"
|
||||
/>
|
||||
</Text>
|
||||
<div className="mt-4">
|
||||
|
|
@ -295,7 +305,7 @@ export function PromotionsStudentDiscountCard({ variant = 'full' }: Props) {
|
|||
|
||||
const promoCodeToDisplay = promoCode ?? existingPromoCode ?? null;
|
||||
|
||||
if (promoCodeToDisplay) {
|
||||
if (promoCodeToDisplay && 1 > 2) {
|
||||
return (
|
||||
<div>
|
||||
<Button
|
||||
|
|
@ -335,22 +345,30 @@ export function PromotionsStudentDiscountCard({ variant = 'full' }: Props) {
|
|||
}
|
||||
|
||||
return (
|
||||
<Button
|
||||
display="block"
|
||||
isDisabled={isGeneratingStudentDiscount}
|
||||
isLoading={isGeneratingStudentDiscount}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: 'Get promo code',
|
||||
description: 'Button label for student discount',
|
||||
id: 'IQ9qW7',
|
||||
})}
|
||||
size="md"
|
||||
type="button"
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
generateStudentDiscountPromoCode();
|
||||
}}
|
||||
/>
|
||||
<>
|
||||
<Button
|
||||
display="block"
|
||||
isDisabled={isGeneratingStudentDiscount}
|
||||
isLoading={isGeneratingStudentDiscount}
|
||||
label={intl.formatMessage({
|
||||
defaultMessage: 'Get promo code',
|
||||
description: 'Button label for student discount',
|
||||
id: 'IQ9qW7',
|
||||
})}
|
||||
size="md"
|
||||
type="button"
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
setError(null);
|
||||
generateStudentDiscountPromoCode();
|
||||
}}
|
||||
/>
|
||||
{error && (
|
||||
<Text className="mt-2 block" color="error" size="body3">
|
||||
{error}
|
||||
</Text>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17254,12 +17254,6 @@
|
|||
"value": "Code reviews done"
|
||||
}
|
||||
],
|
||||
"ay9BLg": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "All GreatFrontEnd plans"
|
||||
}
|
||||
],
|
||||
"ayZIpd": [
|
||||
{
|
||||
"type": 0,
|
||||
|
|
@ -20529,6 +20523,12 @@
|
|||
"value": "Starter"
|
||||
}
|
||||
],
|
||||
"hy8jrp": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "For GreatFrontEnd Annual plan"
|
||||
}
|
||||
],
|
||||
"hyxFHs": [
|
||||
{
|
||||
"type": 0,
|
||||
|
|
@ -27193,6 +27193,12 @@
|
|||
"value": "Enter something here..."
|
||||
}
|
||||
],
|
||||
"xb1fOo": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "For all GreatFrontEnd plans"
|
||||
}
|
||||
],
|
||||
"xbSTzm": [
|
||||
{
|
||||
"children": [
|
||||
|
|
|
|||
|
|
@ -17286,12 +17286,6 @@
|
|||
"value": "代码审查已完成"
|
||||
}
|
||||
],
|
||||
"ay9BLg": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "所有 GreatFrontEnd 计划"
|
||||
}
|
||||
],
|
||||
"ayZIpd": [
|
||||
{
|
||||
"type": 0,
|
||||
|
|
@ -20563,6 +20557,12 @@
|
|||
"value": "入门"
|
||||
}
|
||||
],
|
||||
"hy8jrp": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "针对GreatFrontEnd年度计划"
|
||||
}
|
||||
],
|
||||
"hyxFHs": [
|
||||
{
|
||||
"type": 0,
|
||||
|
|
@ -27225,6 +27225,12 @@
|
|||
"value": "在此处输入一些内容..."
|
||||
}
|
||||
],
|
||||
"xb1fOo": [
|
||||
{
|
||||
"type": 0,
|
||||
"value": "针对所有GreatFrontEnd计划"
|
||||
}
|
||||
],
|
||||
"xbSTzm": [
|
||||
{
|
||||
"children": [
|
||||
|
|
|
|||
|
|
@ -8407,10 +8407,6 @@
|
|||
"defaultMessage": "Code reviews done",
|
||||
"description": "Number of code reviews given"
|
||||
},
|
||||
"ay9BLg": {
|
||||
"defaultMessage": "All GreatFrontEnd plans",
|
||||
"description": "All pricing plans"
|
||||
},
|
||||
"ayZIpd": {
|
||||
"defaultMessage": "Medium",
|
||||
"description": "Medium importance question"
|
||||
|
|
@ -10007,6 +10003,10 @@
|
|||
"defaultMessage": "Starter",
|
||||
"description": "Challenge difficulty label"
|
||||
},
|
||||
"hy8jrp": {
|
||||
"defaultMessage": "For GreatFrontEnd Annual plan",
|
||||
"description": "GFE annual plan"
|
||||
},
|
||||
"hyxFHs": {
|
||||
"defaultMessage": "Join the Premium club and get access to project challenges Figma designs and guides.",
|
||||
"description": "Projects Premium description"
|
||||
|
|
@ -13155,6 +13155,10 @@
|
|||
"defaultMessage": "Enter something here...",
|
||||
"description": "Placeholder for body input"
|
||||
},
|
||||
"xb1fOo": {
|
||||
"defaultMessage": "For all GreatFrontEnd plans",
|
||||
"description": "All pricing plans"
|
||||
},
|
||||
"xbSTzm": {
|
||||
"defaultMessage": "<authorLink>{author}</authorLink> left a comment on <submissionLink>{entityTitle}</submissionLink> {timestamp}",
|
||||
"description": "Notification for comment left on your submission"
|
||||
|
|
|
|||
|
|
@ -8407,10 +8407,6 @@
|
|||
"defaultMessage": "代码审查已完成",
|
||||
"description": "Number of code reviews given"
|
||||
},
|
||||
"ay9BLg": {
|
||||
"defaultMessage": "所有 GreatFrontEnd 计划",
|
||||
"description": "All pricing plans"
|
||||
},
|
||||
"ayZIpd": {
|
||||
"defaultMessage": "中等",
|
||||
"description": "Medium importance question"
|
||||
|
|
@ -10007,6 +10003,10 @@
|
|||
"defaultMessage": "入门",
|
||||
"description": "Challenge difficulty label"
|
||||
},
|
||||
"hy8jrp": {
|
||||
"defaultMessage": "针对GreatFrontEnd年度计划",
|
||||
"description": "GFE annual plan"
|
||||
},
|
||||
"hyxFHs": {
|
||||
"defaultMessage": "加入高级俱乐部,即可访问项目挑战、Figma 设计和指南。",
|
||||
"description": "Projects Premium description"
|
||||
|
|
@ -13155,6 +13155,10 @@
|
|||
"defaultMessage": "在此处输入一些内容...",
|
||||
"description": "Placeholder for body input"
|
||||
},
|
||||
"xb1fOo": {
|
||||
"defaultMessage": "针对所有GreatFrontEnd计划",
|
||||
"description": "All pricing plans"
|
||||
},
|
||||
"xbSTzm": {
|
||||
"defaultMessage": "<authorLink>{作者}</authorLink> 在 <submissionLink>{实体标题}</submissionLink> 上发表评论 {timestamp}",
|
||||
"description": "Notification for comment left on your submission"
|
||||
|
|
|
|||
Loading…
Reference in New Issue