- ยอดรวมสินค้าก่อนลด
+ {t('shopeeShopCase.rowGross', 'ยอดรวมสินค้าก่อนลด')}
{fmt(simBeforeDiscount)}
- ส่วนลดจากร้านค้า (รวม)
+ {t('shopeeShopCase.rowShopDiscountTotal', 'ส่วนลดจากร้านค้า (รวม)')}
-{fmt(simDiscountAmount)}
{discounts.map((d, i) => d.value > 0 ? (
- - คูปอง #{i + 1} ({d.type === 'pct' ? `${d.value}%` : `฿${d.value}`})
+
+ {t('shopeeShopCase.rowCouponItem', {
+ index: i + 1,
+ val: d.type === 'pct' ? `${d.value}%` : `฿${d.value}`,
+ defaultValue: `- คูปอง #${i + 1} (${d.type === 'pct' ? `${d.value}%` : `฿${d.value}`})`
+ })}
+
-{fmt(d.type === 'pct' ? simBeforeDiscount * (d.value / 100) : d.value)}
) : null)}
- ยอดสินค้าสุทธิ (ฐานคิดคอม)
+ {t('shopeeShopCase.rowNetBase', 'ยอดสินค้าสุทธิ (ฐานคิดคอม)')}
{fmt(baseAmt)}
- - ค่าคอมมิชชั่น ({simCommPct.toFixed(2)}%)
+ {t('shopeeShopCase.rowFeeCommWithPct', { pct: simCommPct.toFixed(2), defaultValue: `- ค่าคอมมิชชั่น (${simCommPct.toFixed(2)}%)` })}
฿-{simCommAmt.toFixed(2)}
- - ค่าบริการ ({simServicePct.toFixed(2)}%)
+ {t('shopeeShopCase.rowFeeServiceWithPct', { pct: simServicePct.toFixed(2), defaultValue: `- ค่าบริการ (${simServicePct.toFixed(2)}%)` })}
฿-{simServiceAmt.toFixed(2)}
- - ค่าธุรกรรมการชำระเงิน ({simTransPct.toFixed(2)}%)
+ {t('shopeeShopCase.rowFeeTransWithPct', { pct: simTransPct.toFixed(2), defaultValue: `- ค่าธุรกรรมการชำระเงิน (${simTransPct.toFixed(2)}%)` })}
฿-{simTransAmt.toFixed(2)}
{simAmsPct > 0 && (
- - ค่าคอมมิชชั่น AMS ({simAmsPct.toFixed(2)}%)
+ {t('shopeeShopCase.rowFeeAmsWithPct', { pct: simAmsPct.toFixed(2), defaultValue: `- ค่าคอมมิชชั่น AMS (${simAmsPct.toFixed(2)}%)` })}
฿-{simAmsAmt.toFixed(2)}
)}
- รวมค่าธรรมเนียมโดนหัก
+ {t('shopeeShopCase.rowTotalFees', 'รวมค่าธรรมเนียมโดนหัก')}
฿-{simTotalAmt.toFixed(2)}
- ยอดเงินโอนเข้าบัญชีสุทธิ
+ {t('shopeeShopCase.rowNetPayout', 'ยอดเงินโอนเข้าบัญชีสุทธิ')}
฿{simPayout.toFixed(2)}
- - ต้นทุนสินค้า (Cost)
+ {t('shopeeShopCase.rowCost', '- ต้นทุนสินค้า (Cost)')}
฿-{simCost.toFixed(2)}
- กำไรสุทธิ (Net Profit)
+ {t('shopeeShopCase.rowNetProfit', 'กำไรสุทธิ (Net Profit)')}
= 0 ? 'text-green-400' : 'text-rose-400'}`}>
{simProfit >= 0 ? '' : '-'}฿{Math.abs(simProfit).toFixed(2)}
- กำไรต่อยอดขาย (Margin %)
+ {t('shopeeShopCase.rowMargin', 'กำไรต่อยอดขาย (Margin %)')}
= 0 ? 'text-green-400' : 'text-rose-400'}`}>
{simProfitMargin.toFixed(1)}%
- กำไรต่อทุน (ROI %)
+ {t('shopeeShopCase.rowRoi', 'กำไรต่อทุน (ROI %)')}
= 0 ? 'text-green-400' : 'text-rose-400'}`}>
{simROI.toFixed(1)}%
@@ -565,8 +580,8 @@ export default function ShopeeShopCasePage() {
{diffVal >= 0
- ? `ยอดรับเงินเพิ่มขึ้น ฿${diffVal.toFixed(2)} จากโครงสร้างธรรมเนียมใหม่`
- : `ยอดเงินโอนเข้าบัญชีสุทธิจะต่างไป ฿${diffVal.toFixed(2)} (${diffVal >= 0 ? '+' : ''}${diffPct.toFixed(1)}%) เมื่อเทียบกับบิลจริงดั้งเดิม`}
+ ? t('shopeeShopCase.diffProfitUp', { diff: diffVal.toFixed(2), defaultValue: `ยอดรับเงินเพิ่มขึ้น ฿${diffVal.toFixed(2)} จากโครงสร้างธรรมเนียมใหม่` })
+ : t('shopeeShopCase.diffPayoutChanged', { diff: diffVal.toFixed(2), sign: diffVal >= 0 ? '+' : '', pct: diffPct.toFixed(1), defaultValue: `ยอดเงินโอนเข้าบัญชีสุทธิจะต่างไป ฿${diffVal.toFixed(2)} (${diffVal >= 0 ? '+' : ''}${diffPct.toFixed(1)}%) เมื่อเทียบกับบิลจริงดั้งเดิม` })}
{diffVal >= 0 ? '+' : ''}฿{diffVal.toFixed(2)}
diff --git a/apps/admin/src/pages/TiktokAnalyticsPage.tsx b/apps/admin/src/pages/TiktokAnalyticsPage.tsx
index e1a5f16..7075068 100644
--- a/apps/admin/src/pages/TiktokAnalyticsPage.tsx
+++ b/apps/admin/src/pages/TiktokAnalyticsPage.tsx
@@ -9,6 +9,7 @@ import {
ArrowLeft, BadgePercent, ShoppingCart, XCircle, CheckCircle2, Loader2,
Calendar, Store,
} from 'lucide-react';
+import { useTranslation } from 'react-i18next';
import { TIKTOK_SHOPS } from './TiktokOrderPage';
const API_URL = (import.meta.env.VITE_API_URL || 'http://localhost:3000').replace(/\/api\/?$/, '');
@@ -68,18 +69,6 @@ function getPresetRange(preset: Preset): { from: string; to: string } {
return { from: '', to: '' };
}
-const PRESETS: { key: Preset; label: string }[] = [
- { key: '7d', label: '7 วัน' },
- { key: '30d', label: '30 วัน' },
- { key: '90d', label: '90 วัน' },
- { key: 'thisMonth', label: 'เดือนนี้' },
- { key: 'lastMonth', label: 'เดือนที่แล้ว' },
- { key: 'year', label: 'ปีนี้' },
- { key: 'lastYear', label: 'ปีที่แล้ว' },
- { key: 'last12m', label: '12 เดือนที่ผ่านมา' },
- { key: 'all', label: 'ทั้งหมด' },
-];
-
function StatCard({
label, value, sub, icon: Icon, color = 'text-white', bgColor = 'from-white/5',
}: { label: string; value: string | number; sub?: string; icon: any; color?: string; bgColor?: string }) {
@@ -112,6 +101,7 @@ const CustomTooltip = ({ active, payload, label }: any) => {
};
export default function TiktokAnalyticsPage() {
+ const { t } = useTranslation();
const [data, setData] = useState
(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
@@ -125,6 +115,18 @@ export default function TiktokAnalyticsPage() {
const [dateFrom, setDateFrom] = useState('');
const [dateTo, setDateTo] = useState('');
+ const PRESETS: { key: Preset; label: string }[] = [
+ { key: '7d', label: t('analytics.preset7d', '7 วัน') },
+ { key: '30d', label: t('analytics.preset30d', '30 วัน') },
+ { key: '90d', label: t('analytics.preset90d', '90 วัน') },
+ { key: 'thisMonth', label: t('analytics.presetThisMonth', 'เดือนนี้') },
+ { key: 'lastMonth', label: t('analytics.presetLastMonth', 'เดือนที่แล้ว') },
+ { key: 'year', label: t('analytics.presetThisYear', 'ปีนี้') },
+ { key: 'lastYear', label: t('analytics.presetLastYear', 'ปีที่แล้ว') },
+ { key: 'last12m', label: t('analytics.presetLast12m', '12 เดือนที่ผ่านมา') },
+ { key: 'all', label: t('analytics.presetAll', 'ทั้งหมด') },
+ ];
+
const buildUrl = useCallback((s: string, from: string, to: string) => {
const params = new URLSearchParams({ shop: s });
if (from) params.set('dateFrom', from);
@@ -166,7 +168,7 @@ export default function TiktokAnalyticsPage() {
return (
- กำลังคำนวณข้อมูลวิเคราะห์...
+ {t('tiktokAnalytics.loading')}
);
}
@@ -175,9 +177,9 @@ export default function TiktokAnalyticsPage() {
return (
-
{error || 'ไม่มีข้อมูล — กรุณา Import ไฟล์ TikTok ก่อน'}
+
{error || t('tiktokAnalytics.noData')}
-
กลับหน้า TikTok Orders
+
{t('tiktokAnalytics.backToOrders')}
);
@@ -205,12 +207,11 @@ export default function TiktokAnalyticsPage() {
TikTok
/
- Analytics
+ {t('tiktokAnalytics.breadcrumb', 'Analytics')}
- วิเคราะห์ยอดขาย —
- {shopCfg.label}
+ {t('tiktokAnalytics.title', { shop: shopCfg.label })}