feat(dashboard): upgrade promotion

This commit is contained in:
Aaron Liu 2025-08-12 13:27:05 +08:00
parent a15906f3fb
commit ce3c8b624a
5 changed files with 60 additions and 7 deletions

View File

@ -1587,7 +1587,9 @@
"sso": "SSO single sign-on",
"more": "......",
"later": "Maybe later",
"learnMore": "Learn more"
"learnMore": "Learn more",
"promotionTitle": "Community edition upgrade special discount",
"promotion": "Use the promotion code <0>{{code}}</0> when purchasing to apply a <1>-{{discount}}%</1> discount."
},
"abuseReport": {
"deleteXAbuseReports": "Delete {{num}} abuse reports",

View File

@ -1574,7 +1574,9 @@
"sso": "SSOシングルサインオン",
"more": "......",
"later": "後で",
"learnMore": "Pro版の詳細を見る"
"learnMore": "Pro版の詳細を見る",
"promotionTitle": "コミュニティ版アップグレード特別割引",
"promotion": "購入時に<0>{{code}}</0>を使用すると、<1>-{{discount}}%</1>の割引が適用されます。"
},
"abuseReport": {
"deleteXAbuseReports": "{{num}} 個の舉報を削除",

View File

@ -1573,7 +1573,9 @@
"sso": "SSO 单点登录",
"more": "......",
"later": "稍后再说",
"learnMore": "了解 Pro 版本详情"
"learnMore": "了解 Pro 版本详情",
"promotionTitle": "社区版升级特别优惠",
"promotion": "购买时使用优惠码 <0>{{code}}</0>,获得 <1>-{{discount}}%</1> 折扣。"
},
"abuseReport": {
"deleteXAbuseReports": "删除 {{num}} 个举报",

View File

@ -1570,7 +1570,9 @@
"sso": "SSO 單點登入",
"more": "......",
"later": "稍後再說",
"learnMore": "了解 Pro 版本詳情"
"learnMore": "了解 Pro 版本詳情",
"promotionTitle": "社區版升級特別優惠",
"promotion": "購買時使用優惠碼 <0>{{code}}</0>,獲得 <1>-{{discount}}%</1> 折扣。"
},
"abuseReport": {
"deleteXAbuseReports": "刪除 {{num}} 個舉報",

View File

@ -1,8 +1,22 @@
import { Button, DialogContent, List, ListItem, ListItemIcon, ListItemText, Typography, styled } from "@mui/material";
import { useCallback } from "react";
import { useTranslation } from "react-i18next";
import {
Alert,
AlertTitle,
Button,
DialogContent,
List,
ListItem,
ListItemIcon,
ListItemText,
Typography,
styled,
} from "@mui/material";
import dayjs from "dayjs";
import { useCallback, useMemo } from "react";
import { Trans, useTranslation } from "react-i18next";
import DraggableDialog, { StyledDialogActions } from "../../Dialogs/DraggableDialog";
import CheckmarkCircleFilled from "../../Icons/CheckmarkCircleFilled";
import Gift from "../../Icons/Gift";
import { Code } from "./Code";
export interface ProDialogProps {
open: boolean;
@ -28,12 +42,24 @@ const StyledButton = styled(Button)(({ theme }) => ({
transition: "all 300ms cubic-bezier(0.4, 0, 0.2, 1) !important",
}));
// TODO: fetch from cloudreve.org
const currentPromotion = {
code: "FI5Q9668YV",
discount: 15,
start: "2025-08-12T00:00:00Z",
end: "2025-10-12T23:59:59Z",
};
const ProDialog = ({ open, onClose }: ProDialogProps) => {
const { t } = useTranslation("dashboard");
const openMore = useCallback((e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation();
window.open("https://cloudreve.org/pro", "_blank");
}, []);
const showPromotion = useMemo(() => {
const now = dayjs();
return now >= dayjs(currentPromotion.start) && now <= dayjs(currentPromotion.end);
}, []);
return (
<DraggableDialog
title={t("pro.title")}
@ -76,6 +102,25 @@ const ProDialog = ({ open, onClose }: ProDialogProps) => {
</ListItem>
))}
</List>
{showPromotion && (
<Alert
iconMapping={{
info: <Gift fontSize="inherit" />,
}}
severity="info"
sx={{ mt: 2 }}
>
<AlertTitle>{t("pro.promotionTitle")}</AlertTitle>
<Trans
i18nKey="dashboard:pro.promotion"
values={{
code: currentPromotion.code,
discount: currentPromotion.discount,
}}
components={[<Code />, <Typography component={"span"} fontWeight={600} />]}
/>
</Alert>
)}
</DialogContent>
<StyledDialogActions
sx={{