diff --git a/apps/admin/public/assets/locales/en-US/redemption.json b/apps/admin/public/assets/locales/en-US/redemption.json index c862059..1abed9d 100644 --- a/apps/admin/public/assets/locales/en-US/redemption.json +++ b/apps/admin/public/assets/locales/en-US/redemption.json @@ -26,14 +26,19 @@ "halfYear": "Half Year", "month": "Month", "quarter": "Quarter", + "quantityRequired": "Quantity is required", "selectPlan": "Select Redemption Plan", "selectUnitTime": "Select Redemption Duration Unit", "subscribePlan": "Redemption Plan", + "subscribePlanRequired": "Subscribe plan is required", "totalCount": "Available Uses", "totalCountPlaceholder": "Available Uses", + "totalCountRequired": "Total count is required", "unitTime": "Redemption Duration Unit", + "unitTimeRequired": "Unit time is required", "year": "Year" }, + "id": "ID", "loading": "Loading...", "next": "Next", "noRecords": "No records found", diff --git a/apps/admin/public/assets/locales/zh-CN/redemption.json b/apps/admin/public/assets/locales/zh-CN/redemption.json index f03a724..4752261 100644 --- a/apps/admin/public/assets/locales/zh-CN/redemption.json +++ b/apps/admin/public/assets/locales/zh-CN/redemption.json @@ -26,14 +26,19 @@ "halfYear": "半年", "month": "月", "quarter": "季度", + "quantityRequired": "数量为必填项", "selectPlan": "选择兑换套餐", "selectUnitTime": "选择兑换时长单位", "subscribePlan": "兑换套餐", + "subscribePlanRequired": "兑换套餐为必填项", "totalCount": "兑换码可用次数", "totalCountPlaceholder": "兑换码可用次数", + "totalCountRequired": "兑换码可用次数为必填项", "unitTime": "兑换时长单位", + "unitTimeRequired": "兑换时长单位为必填项", "year": "年" }, + "id": "ID", "loading": "加载中...", "next": "下一页", "noRecords": "暂无兑换记录", diff --git a/apps/admin/src/sections/redemption/index.tsx b/apps/admin/src/sections/redemption/index.tsx index 0ad6bb1..c96f038 100644 --- a/apps/admin/src/sections/redemption/index.tsx +++ b/apps/admin/src/sections/redemption/index.tsx @@ -1,4 +1,3 @@ -import { Badge } from "@workspace/ui/components/badge"; import { Button } from "@workspace/ui/components/button"; import { Switch } from "@workspace/ui/components/switch"; import { ConfirmButton } from "@workspace/ui/composed/confirm-button"; diff --git a/apps/admin/src/sections/redemption/redemption-form.tsx b/apps/admin/src/sections/redemption/redemption-form.tsx index 07e7202..dcb5e91 100644 --- a/apps/admin/src/sections/redemption/redemption-form.tsx +++ b/apps/admin/src/sections/redemption/redemption-form.tsx @@ -26,14 +26,14 @@ import { useTranslation } from "react-i18next"; import { z } from "zod"; import { useSubscribe } from "@/stores/subscribe"; -const formSchema = z.object({ +const getFormSchema = (t: (key: string, defaultValue: string) => string) => z.object({ id: z.number().optional(), code: z.string().optional(), batch_count: z.number().optional(), - total_count: z.number().min(1, "Total count is required"), - subscribe_plan: z.number().min(1, "Subscribe plan is required"), - unit_time: z.string().min(1, "Unit time is required"), - quantity: z.number().min(1, "Quantity is required"), + total_count: z.number().min(1, t("form.totalCountRequired", "Total count is required")), + subscribe_plan: z.number().min(1, t("form.subscribePlanRequired", "Subscribe plan is required")), + unit_time: z.string().min(1, t("form.unitTimeRequired", "Unit time is required")), + quantity: z.number().min(1, t("form.quantityRequired", "Quantity is required")), }); interface RedemptionFormProps { @@ -52,6 +52,7 @@ export default function RedemptionForm>({ title, }: RedemptionFormProps) { const { t } = useTranslation("redemption"); + const formSchema = getFormSchema(t); const [open, setOpen] = useState(false); const form = useForm({ diff --git a/apps/admin/src/sections/redemption/redemption-records.tsx b/apps/admin/src/sections/redemption/redemption-records.tsx index b1a677d..22a2adc 100644 --- a/apps/admin/src/sections/redemption/redemption-records.tsx +++ b/apps/admin/src/sections/redemption/redemption-records.tsx @@ -1,4 +1,3 @@ -import { Badge } from "@workspace/ui/components/badge"; import { Dialog, DialogContent, @@ -81,7 +80,7 @@ export default function RedemptionRecords({ - ID + {t("id", "ID")} {t("userId", "User ID")} {t("subscribeId", "Subscribe ID")} {t("unitTime", "Unit Time")} @@ -90,20 +89,29 @@ export default function RedemptionRecords({ - {records.map((record) => ( - - {record.id} - {record.user_id} - {record.subscribe_id} - {record.unit_time} - {record.quantity} - - {record.redeemed_at - ? formatDate(record.redeemed_at) - : "--"} - - - ))} + {records.map((record) => { + const unitTimeMap: Record = { + day: t("form.day", "Day"), + month: t("form.month", "Month"), + quarter: t("form.quarter", "Quarter"), + half_year: t("form.halfYear", "Half Year"), + year: t("form.year", "Year"), + }; + return ( + + {record.id} + {record.user_id} + {record.subscribe_id} + {unitTimeMap[record.unit_time] || record.unit_time} + {record.quantity} + + {record.redeemed_at + ? formatDate(record.redeemed_at) + : "--"} + + + ); + })}
{total > pagination.size && ( diff --git a/apps/user/public/assets/locales/en-US/components.json b/apps/user/public/assets/locales/en-US/components.json index dab173d..c473195 100644 --- a/apps/user/public/assets/locales/en-US/components.json +++ b/apps/user/public/assets/locales/en-US/components.json @@ -40,6 +40,7 @@ "40005": "You do not have access permission, please contact the administrator if you have any questions.", "50001": "Corresponding coupon information not found, please check and try again.", "50002": "The coupon has been used, cannot be used again.", + "50003": "This coupon code is not supported by the current purchase plan.", "60001": "Subscription has expired, please renew before using.", "60002": "Unable to use the subscription at the moment, please try again later.", "60003": "An existing subscription is detected. Please cancel it before proceeding.", diff --git a/apps/user/public/assets/locales/zh-CN/components.json b/apps/user/public/assets/locales/zh-CN/components.json index dcfd96b..3c1b2be 100644 --- a/apps/user/public/assets/locales/zh-CN/components.json +++ b/apps/user/public/assets/locales/zh-CN/components.json @@ -40,6 +40,7 @@ "40005": "您没有访问权限,如有疑问请联系管理员。", "50001": "找不到对应的优惠券信息,请检查后重试。", "50002": "该优惠券已被使用,无法再次使用。", + "50003": "该优惠码不被当前购买套餐支持。", "60001": "订阅已过期,请续费后使用。", "60002": "暂时无法使用该订阅,请稍后再试。", "60003": "检测到现有订阅,请先取消后再继续。", diff --git a/packages/ui/src/lib/request.ts b/packages/ui/src/lib/request.ts index a8f9442..af2586d 100644 --- a/packages/ui/src/lib/request.ts +++ b/packages/ui/src/lib/request.ts @@ -119,6 +119,10 @@ function handleError(response: { "components:error.50002", "The coupon has been used, cannot be used again." ), + 50003: t( + "components:error.50003", + "This coupon code is not supported by the current purchase plan." + ), 60001: t( "components:error.60001", "Subscription has expired, please renew before using."