diff --git a/apps/user/app/(main)/(user)/affiliate/page.tsx b/apps/user/app/(main)/(user)/affiliate/page.tsx new file mode 100644 index 0000000..3515168 --- /dev/null +++ b/apps/user/app/(main)/(user)/affiliate/page.tsx @@ -0,0 +1,76 @@ +'use client'; +import { Display } from '@/components/display'; +import { ProList } from '@/components/pro-list'; +import useGlobalStore from '@/config/use-global'; +import { queryUserAffiliate } from '@/services/user/user'; +import { formatDate } from '@repo/ui/utils'; +import { Button } from '@shadcn/ui/button'; +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@shadcn/ui/card'; +import { toast } from '@shadcn/ui/lib/sonner'; +import { useTranslations } from 'next-intl'; +import { useState } from 'react'; + +export default function Page() { + const t = useTranslations('affiliate'); + const { user } = useGlobalStore(); + const [sum, setSum] = useState(); + + return ( +
+ + + {t('totalCommission')} + {t('commissionInfo')} + + + + + + + + {t('inviteCode')} + + + {user?.refer_code} + + > + request={async (pagination, filter) => { + const response = await queryUserAffiliate({ ...pagination, ...filter }); + setSum(response.data.data?.sum); + return { + list: response.data.data?.list || [], + total: response.data.data?.total || 0, + }; + }} + header={{ + title: t('inviteRecords'), + }} + renderItem={(item) => { + return ( + + +
    +
  • + {t('userEmail')} + {item.email} +
  • +
  • + {t('registrationTime')} + +
  • +
+
+
+ ); + }} + /> +
+ ); +} diff --git a/apps/user/app/(main)/(user)/sidebar-right.tsx b/apps/user/app/(main)/(user)/sidebar-right.tsx index 6e23024..1e241c9 100644 --- a/apps/user/app/(main)/(user)/sidebar-right.tsx +++ b/apps/user/app/(main)/(user)/sidebar-right.tsx @@ -25,20 +25,6 @@ export function SidebarRight({ ...props }: React.ComponentProps) - - - {t('totalCommission')} - - - 0.00 - - - - {t('invitees')} - - - 0 - {t('inviteCode')} diff --git a/apps/user/config/navs.ts b/apps/user/config/navs.ts index 193f78c..941f74a 100644 --- a/apps/user/config/navs.ts +++ b/apps/user/config/navs.ts @@ -37,6 +37,11 @@ export const navs = [ icon: 'uil:wallet', title: 'wallet', }, + { + url: '/affiliate', + icon: 'uil:users-alt', + title: 'affiliate', + }, ], }, { diff --git a/apps/user/locales/en-US/affiliate.json b/apps/user/locales/en-US/affiliate.json new file mode 100644 index 0000000..4ac82c9 --- /dev/null +++ b/apps/user/locales/en-US/affiliate.json @@ -0,0 +1,10 @@ +{ + "commissionInfo": "Statistics of the commission, automatically transferred to balance", + "copyInviteLink": "Copy Invite Link", + "copySuccess": "Copied Successfully", + "inviteCode": "Invite Code", + "inviteRecords": "Invite Records", + "registrationTime": "Registration Time", + "totalCommission": "Total Commission", + "userEmail": "User Email" +} diff --git a/apps/user/locales/en-US/layout.json b/apps/user/locales/en-US/layout.json index f06d84d..e61bd74 100644 --- a/apps/user/locales/en-US/layout.json +++ b/apps/user/locales/en-US/layout.json @@ -3,7 +3,5 @@ "copyInviteLink": "Copy Invite Link", "copySuccess": "Invite Link Copied Successfully", "inviteCode": "Invite Code", - "invitees": "Invitees", - "recharge": "Recharge", - "totalCommission": "Total Commission" + "recharge": "Recharge" } diff --git a/apps/user/locales/en-US/menu.json b/apps/user/locales/en-US/menu.json index d0c127a..4c8cb36 100644 --- a/apps/user/locales/en-US/menu.json +++ b/apps/user/locales/en-US/menu.json @@ -1,4 +1,5 @@ { + "affiliate": "My Invitation", "announcement": "Announcement List", "dashboard": "Dashboard", "document": "Documentation", diff --git a/apps/user/locales/request.ts b/apps/user/locales/request.ts index 0e02edd..e27e18c 100644 --- a/apps/user/locales/request.ts +++ b/apps/user/locales/request.ts @@ -23,6 +23,7 @@ export default getRequestConfig(async () => { wallet: (await import(`./${locale}/wallet.json`)).default, ticket: (await import(`./${locale}/ticket.json`)).default, document: (await import(`./${locale}/document.json`)).default, + affiliate: (await import(`./${locale}/affiliate.json`)).default, }; return { diff --git a/apps/user/locales/zh-CN/affiliate.json b/apps/user/locales/zh-CN/affiliate.json new file mode 100644 index 0000000..51fcf42 --- /dev/null +++ b/apps/user/locales/zh-CN/affiliate.json @@ -0,0 +1,10 @@ +{ + "commissionInfo": "统计金额,邀请佣金自动转入余额", + "copyInviteLink": "复制邀请链接", + "copySuccess": "复制成功", + "inviteCode": "邀请码", + "inviteRecords": "邀请记录", + "registrationTime": "注册时间", + "totalCommission": "佣金总额", + "userEmail": "用户邮箱" +} diff --git a/apps/user/locales/zh-CN/layout.json b/apps/user/locales/zh-CN/layout.json index 7611eea..af163cb 100644 --- a/apps/user/locales/zh-CN/layout.json +++ b/apps/user/locales/zh-CN/layout.json @@ -3,7 +3,5 @@ "copyInviteLink": "复制邀请链接", "copySuccess": "邀请链接复制成功", "inviteCode": "邀请码", - "invitees": "邀请人数", - "recharge": "充值", - "totalCommission": "佣金总额" + "recharge": "充值" } diff --git a/apps/user/locales/zh-CN/menu.json b/apps/user/locales/zh-CN/menu.json index 6f798f9..83dfd85 100644 --- a/apps/user/locales/zh-CN/menu.json +++ b/apps/user/locales/zh-CN/menu.json @@ -1,4 +1,5 @@ { + "affiliate": "我的邀请", "announcement": "公告列表", "dashboard": "主页", "document": "使用文档", diff --git a/apps/user/services/common/common.ts b/apps/user/services/common/common.ts index e836b7a..e138af7 100644 --- a/apps/user/services/common/common.ts +++ b/apps/user/services/common/common.ts @@ -21,3 +21,11 @@ export async function getGlobalConfig(options?: { [key: string]: any }) { ...(options || {}), }); } + +/** Get Tos Content GET /v1/common/site/tos */ +export async function getTos(options?: { [key: string]: any }) { + return request('/v1/common/site/tos', { + method: 'GET', + ...(options || {}), + }); +} diff --git a/apps/user/services/common/typings.d.ts b/apps/user/services/common/typings.d.ts index ed7bf4c..826480f 100644 --- a/apps/user/services/common/typings.d.ts +++ b/apps/user/services/common/typings.d.ts @@ -25,6 +25,10 @@ declare namespace API { subscribe: SubscribeConfig; }; + type GetTosResponse = { + tos_content: string; + }; + type InviteConfig = { forced_invite: boolean; }; diff --git a/apps/user/services/user/typings.d.ts b/apps/user/services/user/typings.d.ts index ac7ff8c..59f43ec 100644 --- a/apps/user/services/user/typings.d.ts +++ b/apps/user/services/user/typings.d.ts @@ -212,6 +212,7 @@ declare namespace API { }; type QueryUserAffiliateResponse = { + sum: number; list: UserAffiliate[]; total: number; }; @@ -353,7 +354,6 @@ declare namespace API { type UserAffiliate = { email: string; avatar: string; - telegram: number; registered_at: number; enable: boolean; }; diff --git a/packages/ui/src/pro-list/pro-list.tsx b/packages/ui/src/pro-list/pro-list.tsx index 70539c5..1aaec91 100644 --- a/packages/ui/src/pro-list/pro-list.tsx +++ b/packages/ui/src/pro-list/pro-list.tsx @@ -3,6 +3,7 @@ import { Alert, AlertDescription, AlertTitle } from '@shadcn/ui/alert'; import { Button } from '@shadcn/ui/button'; import { Checkbox } from '@shadcn/ui/checkbox'; +import { cn } from '@shadcn/ui/lib/utils'; import { ColumnFiltersState, getCoreRowModel, @@ -142,12 +143,16 @@ export function ProList>({ )}
- - + {params && params?.length > 0 && ( + <> + + + + )} {header?.toolbar}
@@ -161,7 +166,11 @@ export function ProList>({ )} -
+
{data.length ? ( data.map((item, index) => {