diff --git a/apps/admin/src/routeTree.gen.ts b/apps/admin/src/routeTree.gen.ts index fe38819..5de5f84 100644 --- a/apps/admin/src/routeTree.gen.ts +++ b/apps/admin/src/routeTree.gen.ts @@ -138,9 +138,9 @@ const DashboardNodesLazyRoute = DashboardNodesLazyRouteImport.update({ ) const DashboardWithdrawalIndexLazyRoute = DashboardWithdrawalIndexLazyRouteImport.update({ - id: '/withdrawal/', - path: '/withdrawal/', - getParentRoute: () => DashboardRouteLazyRoute, + id: '/', + path: '/', + getParentRoute: () => DashboardWithdrawalLazyRoute, } as any).lazy(() => import('./routes/dashboard/withdrawal/index.lazy').then((d) => d.Route), ) @@ -367,7 +367,7 @@ export interface FileRoutesByFullPath { '/dashboard': typeof DashboardRouteLazyRouteWithChildren '/dashboard/nodes': typeof DashboardNodesLazyRoute '/dashboard/servers': typeof DashboardServersLazyRoute - '/dashboard/withdrawal': typeof DashboardWithdrawalLazyRoute + '/dashboard/withdrawal': typeof DashboardWithdrawalLazyRouteWithChildren '/dashboard/': typeof DashboardIndexLazyRoute '/dashboard/log/balance': typeof DashboardLogBalanceLazyRoute '/dashboard/log/commission': typeof DashboardLogCommissionLazyRoute @@ -397,13 +397,12 @@ export interface FileRoutesByFullPath { '/dashboard/system': typeof DashboardSystemIndexLazyRoute '/dashboard/ticket': typeof DashboardTicketIndexLazyRoute '/dashboard/user': typeof DashboardUserIndexLazyRoute - '/dashboard/withdrawal': typeof DashboardWithdrawalIndexLazyRoute + '/dashboard/withdrawal/': typeof DashboardWithdrawalIndexLazyRoute } export interface FileRoutesByTo { '/': typeof IndexLazyRoute '/dashboard/nodes': typeof DashboardNodesLazyRoute '/dashboard/servers': typeof DashboardServersLazyRoute - '/dashboard/withdrawal': typeof DashboardWithdrawalLazyRoute '/dashboard': typeof DashboardIndexLazyRoute '/dashboard/log/balance': typeof DashboardLogBalanceLazyRoute '/dashboard/log/commission': typeof DashboardLogCommissionLazyRoute @@ -441,7 +440,7 @@ export interface FileRoutesById { '/dashboard': typeof DashboardRouteLazyRouteWithChildren '/dashboard/nodes': typeof DashboardNodesLazyRoute '/dashboard/servers': typeof DashboardServersLazyRoute - '/dashboard/withdrawal': typeof DashboardWithdrawalLazyRoute + '/dashboard/withdrawal': typeof DashboardWithdrawalLazyRouteWithChildren '/dashboard/': typeof DashboardIndexLazyRoute '/dashboard/log/balance': typeof DashboardLogBalanceLazyRoute '/dashboard/log/commission': typeof DashboardLogCommissionLazyRoute @@ -510,13 +509,12 @@ export interface FileRouteTypes { | '/dashboard/system' | '/dashboard/ticket' | '/dashboard/user' - | '/dashboard/withdrawal' + | '/dashboard/withdrawal/' fileRoutesByTo: FileRoutesByTo to: | '/' | '/dashboard/nodes' | '/dashboard/servers' - | '/dashboard/withdrawal' | '/dashboard' | '/dashboard/log/balance' | '/dashboard/log/commission' @@ -637,10 +635,10 @@ declare module '@tanstack/react-router' { } '/dashboard/withdrawal/': { id: '/dashboard/withdrawal/' - path: '/withdrawal' - fullPath: '/dashboard/withdrawal' + path: '/' + fullPath: '/dashboard/withdrawal/' preLoaderRoute: typeof DashboardWithdrawalIndexLazyRouteImport - parentRoute: typeof DashboardRouteLazyRoute + parentRoute: typeof DashboardWithdrawalLazyRoute } '/dashboard/user/': { id: '/dashboard/user/' @@ -841,10 +839,24 @@ declare module '@tanstack/react-router' { } } +interface DashboardWithdrawalLazyRouteChildren { + DashboardWithdrawalIndexLazyRoute: typeof DashboardWithdrawalIndexLazyRoute +} + +const DashboardWithdrawalLazyRouteChildren: DashboardWithdrawalLazyRouteChildren = + { + DashboardWithdrawalIndexLazyRoute: DashboardWithdrawalIndexLazyRoute, + } + +const DashboardWithdrawalLazyRouteWithChildren = + DashboardWithdrawalLazyRoute._addFileChildren( + DashboardWithdrawalLazyRouteChildren, + ) + interface DashboardRouteLazyRouteChildren { DashboardNodesLazyRoute: typeof DashboardNodesLazyRoute DashboardServersLazyRoute: typeof DashboardServersLazyRoute - DashboardWithdrawalLazyRoute: typeof DashboardWithdrawalLazyRoute + DashboardWithdrawalLazyRoute: typeof DashboardWithdrawalLazyRouteWithChildren DashboardIndexLazyRoute: typeof DashboardIndexLazyRoute DashboardLogBalanceLazyRoute: typeof DashboardLogBalanceLazyRoute DashboardLogCommissionLazyRoute: typeof DashboardLogCommissionLazyRoute @@ -874,13 +886,12 @@ interface DashboardRouteLazyRouteChildren { DashboardSystemIndexLazyRoute: typeof DashboardSystemIndexLazyRoute DashboardTicketIndexLazyRoute: typeof DashboardTicketIndexLazyRoute DashboardUserIndexLazyRoute: typeof DashboardUserIndexLazyRoute - DashboardWithdrawalIndexLazyRoute: typeof DashboardWithdrawalIndexLazyRoute } const DashboardRouteLazyRouteChildren: DashboardRouteLazyRouteChildren = { DashboardNodesLazyRoute: DashboardNodesLazyRoute, DashboardServersLazyRoute: DashboardServersLazyRoute, - DashboardWithdrawalLazyRoute: DashboardWithdrawalLazyRoute, + DashboardWithdrawalLazyRoute: DashboardWithdrawalLazyRouteWithChildren, DashboardIndexLazyRoute: DashboardIndexLazyRoute, DashboardLogBalanceLazyRoute: DashboardLogBalanceLazyRoute, DashboardLogCommissionLazyRoute: DashboardLogCommissionLazyRoute, @@ -910,7 +921,6 @@ const DashboardRouteLazyRouteChildren: DashboardRouteLazyRouteChildren = { DashboardSystemIndexLazyRoute: DashboardSystemIndexLazyRoute, DashboardTicketIndexLazyRoute: DashboardTicketIndexLazyRoute, DashboardUserIndexLazyRoute: DashboardUserIndexLazyRoute, - DashboardWithdrawalIndexLazyRoute: DashboardWithdrawalIndexLazyRoute, } const DashboardRouteLazyRouteWithChildren = diff --git a/apps/user/src/sections/auth/local-captcha.tsx b/apps/user/src/sections/auth/local-captcha.tsx index 9da60d1..8a22678 100644 --- a/apps/user/src/sections/auth/local-captcha.tsx +++ b/apps/user/src/sections/auth/local-captcha.tsx @@ -2,7 +2,12 @@ import { Button } from "@workspace/ui/components/button"; import { Input } from "@workspace/ui/components/input"; import { Icon } from "@workspace/ui/composed/icon"; import { generateCaptcha } from "@workspace/ui/services/common/auth"; -import { useEffect, useImperativeHandle, useState } from "react"; +import { + type RefObject, + useEffect, + useImperativeHandle, + useState, +} from "react"; import { useTranslation } from "react-i18next"; export interface LocalCaptchaRef { diff --git a/apps/user/src/sections/auth/slider-captcha.tsx b/apps/user/src/sections/auth/slider-captcha.tsx index 9bf5a40..c639955 100644 --- a/apps/user/src/sections/auth/slider-captcha.tsx +++ b/apps/user/src/sections/auth/slider-captcha.tsx @@ -10,7 +10,13 @@ import { generateCaptcha, verifyCaptchaSlider, } from "@workspace/ui/services/common/auth"; -import { useCallback, useImperativeHandle, useRef, useState } from "react"; +import { + type RefObject, + useCallback, + useImperativeHandle, + useRef, + useState, +} from "react"; import { useTranslation } from "react-i18next"; export interface SliderCaptchaRef { diff --git a/apps/user/src/sections/user/profile/notify-settings.tsx b/apps/user/src/sections/user/profile/notify-settings.tsx index 8c711a2..d8899c4 100644 --- a/apps/user/src/sections/user/profile/notify-settings.tsx +++ b/apps/user/src/sections/user/profile/notify-settings.tsx @@ -27,23 +27,52 @@ const FormSchema = z.object({ enable_balance_notify: z.boolean(), enable_login_notify: z.boolean(), enable_subscribe_notify: z.boolean(), - // enable_trade_notify: z.boolean(), + enable_trade_notify: z.boolean(), }); +type NotifyFormValues = z.infer; + +const notificationFields = [ + { + name: "enable_balance_notify", + labelKey: "notify.balanceChange", + fallbackLabel: "Balance Change", + }, + { + name: "enable_login_notify", + labelKey: "notify.login", + fallbackLabel: "Login", + }, + { + name: "enable_subscribe_notify", + labelKey: "notify.subscribe", + fallbackLabel: "Subscribe", + }, + { + name: "enable_trade_notify", + labelKey: "notify.finance", + fallbackLabel: "Finance", + }, +] satisfies Array<{ + name: keyof NotifyFormValues; + labelKey: string; + fallbackLabel: string; +}>; + export default function NotifySettings() { const { t } = useTranslation("profile"); const { user, getUserInfo } = useGlobalStore(); - const form = useForm>({ + const form = useForm({ resolver: zodResolver(FormSchema), defaultValues: { enable_balance_notify: user?.enable_balance_notify ?? false, enable_login_notify: user?.enable_login_notify ?? false, enable_subscribe_notify: user?.enable_subscribe_notify ?? false, - // enable_trade_notify: user?.enable_trade_notify ?? false, + enable_trade_notify: user?.enable_trade_notify ?? false, }, }); - async function onSubmit(data: z.infer) { + async function onSubmit(data: NotifyFormValues) { await updateUserNotify(data); toast.success(t("notify.updateSuccess", "Update Successful")); await getUserInfo(); @@ -67,32 +96,15 @@ export default function NotifySettings() { onSubmit={form.handleSubmit(onSubmit)} >
- {[ - { - name: "enable_balance_notify", - label: t("notify.balanceChange", "Balance Change"), - }, - { - name: "enable_login_notify", - label: t("notify.login", "Login"), - }, - { - name: "enable_subscribe_notify", - label: t("notify.subscribe", "Subscribe"), - }, - // { - // name: "enable_trade_notify", - // label: t("notify.finance", "Finance"), - // }, - ].map(({ name, label }) => ( + {notificationFields.map(({ fallbackLabel, labelKey, name }) => ( ( - {label} + {t(labelKey, fallbackLabel)}