ALIEZ 1 周之前
父节点
当前提交
5842d73190
共有 2 个文件被更改,包括 20 次插入12 次删除
  1. 11 3
      src/app/[locale]/account/purchased-courses/page.tsx
  2. 9 9
      src/app/[locale]/checkout/checkout-form.tsx

+ 11 - 3
src/app/[locale]/account/purchased-courses/page.tsx

@@ -14,9 +14,10 @@ import {
   submitRewardQuestionAnswer,
   type RewardQuestion,
 } from "@/lib/reward-api";
+import { tryFetchCustomUserLabel } from "@/lib/user-label-api";
 
 export default function PurchasedCoursesPage() {
-  const { user, isReady } = useAuth();
+  const { user, isReady, updateProfile } = useAuth();
   const [courses, setCourses] = useState<PurchasedCourse[]>([]);
   const [loading, setLoading] = useState(false);
   const [error, setError] = useState<string | null>(null);
@@ -78,6 +79,13 @@ export default function PurchasedCoursesPage() {
       setRewardSubmitting(true);
       setRewardError(null);
       await submitRewardQuestionAnswer({ questionId: rewardQuestion.questionId, customAnswer });
+      const label = await tryFetchCustomUserLabel();
+      if (label) {
+        updateProfile({
+          levelLabel: label.levelLabel,
+          referralCode: label.referralCode,
+        });
+      }
       setShowRewardAnswer(false);
       setShowRewardThanks(true);
     } catch (e) {
@@ -183,8 +191,8 @@ export default function PurchasedCoursesPage() {
             {rewardError && <p className="mt-4 rounded-xl border border-rose-500/30 bg-rose-500/10 p-3 text-sm text-rose-400">{rewardError}</p>}
             
             <div className="mt-8 grid grid-cols-2 gap-4">
-              <button onClick={() => handleSubmitRewardAnswer(0)} disabled={rewardSubmitting} className="rounded-2xl border border-white/10 bg-white/5 py-4 text-sm font-bold text-slate-400 hover:bg-white/10 hover:text-white disabled:opacity-50">回答错误</button>
-              <button onClick={() => handleSubmitRewardAnswer(1)} disabled={rewardSubmitting} className="rounded-2xl bg-gradient-to-br from-[#f3deae] to-[#d9be88] py-4 text-sm font-bold text-[#5c461a] shadow-lg hover:opacity-90 disabled:opacity-50">回答正确</button>
+              <button onClick={() => handleSubmitRewardAnswer(0)} disabled={rewardSubmitting} className="rounded-2xl border border-white/10 bg-white/5 py-4 text-sm font-bold text-slate-400 hover:bg-white/10 hover:text-white disabled:opacity-50"></button>
+              <button onClick={() => handleSubmitRewardAnswer(1)} disabled={rewardSubmitting} className="rounded-2xl bg-gradient-to-br from-[#f3deae] to-[#d9be88] py-4 text-sm font-bold text-[#5c461a] shadow-lg hover:opacity-90 disabled:opacity-50"></button>
             </div>
             <button onClick={() => setShowRewardAnswer(false)} className="mt-4 w-full py-3 text-xs font-bold text-slate-500 hover:text-slate-300">放弃并关闭</button>
           </div>

+ 9 - 9
src/app/[locale]/checkout/checkout-form.tsx

@@ -280,13 +280,13 @@ export function CheckoutForm() {
                 </button>
                 {expandedGroups[group.groupName] ? (
                   <div className="overflow-x-auto rounded-xl border border-[var(--border)]">
-                    <table className="min-w-full text-sm">
+                    <table className="w-full table-fixed text-sm">
                       <thead className="bg-[var(--background)]">
                         <tr className="text-left text-[var(--muted)]">
-                          <th className="px-4 py-3 font-medium">付款方式</th>
-                          <th className="px-4 py-3 font-medium">描述</th>
-                          <th className="px-4 py-3 font-medium">处理时间</th>
-                          <th className="px-4 py-3 font-medium text-right">操作</th>
+                          <th className="w-[28%] px-4 py-3 font-medium">付款方式</th>
+                          <th className="w-[37%] px-4 py-3 font-medium">描述</th>
+                          <th className="w-[20%] px-4 py-3 font-medium">处理时间</th>
+                          <th className="w-[15%] px-4 py-3 pr-6 font-medium text-right">操作</th>
                         </tr>
                       </thead>
                       <tbody>
@@ -294,7 +294,7 @@ export function CheckoutForm() {
                           const selected = selectedChannelId === channel.id;
                           return (
                             <tr key={channel.id} className="border-t border-[var(--border)]">
-                              <td className="px-4 py-3">
+                              <td className="px-4 py-3 align-middle">
                                 {channel.icon ? (
                                   // eslint-disable-next-line @next/next/no-img-element
                                   <img
@@ -306,9 +306,9 @@ export function CheckoutForm() {
                                   <span className="text-[var(--muted)]">-</span>
                                 )}
                               </td>
-                              <td className="px-4 py-3 text-[var(--muted)]">{channel.description}</td>
-                              <td className="px-4 py-3">{channel.processingTime}</td>
-                              <td className="px-4 py-3 text-right">
+                              <td className="px-4 py-3 align-middle text-left text-[var(--muted)]">{channel.description}</td>
+                              <td className="px-4 py-3 align-middle text-left whitespace-nowrap">{channel.processingTime}</td>
+                              <td className="px-4 py-3 pr-6 align-middle text-right">
                                 <button
                                   type="button"
                                   onClick={() => {