@funhub/platform 0.1.70 → 0.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
"use client";import{Button as e}from"../../../ui/button.mjs";import{hashPassword as t}from"../../../../utils/common.mjs";import{useUserStore as n}from"../../../../store/modules/user-store.mjs";import{pUserResetPassword as
|
|
2
|
+
"use client";import{Button as e}from"../../../ui/button.mjs";import{hashPassword as t}from"../../../../utils/common.mjs";import{useUserStore as n}from"../../../../store/modules/user-store.mjs";import{pUserResetPassword as ee,pUserSendResetPasswordEmailCode as r,pUserVerifyResetPasswordEmailCode as i}from"../../../../service/generated/client.mjs";import{getPasswordValidationErrorText as a,validatePasswordPair as te}from"../../../../utils/password-validator.mjs";import{Box as o}from"../../../ui/box.mjs";import{Drawer as s,DrawerContent as c,DrawerDescription as l,DrawerHeader as u,DrawerTitle as d}from"../../../ui/drawer.mjs";import{Text as f}from"../../../ui/text.mjs";import p from"../../../ui/legacy/button.mjs";import{EyeIcon as m}from"../../../../assets/icons/eye-icon.mjs";import{EyeOffIcon as h}from"../../../../assets/icons/eye-off-icon.mjs";import{HeaderNav as g}from"../../../common/header-nav/client.mjs";import _ from"../../../ui/legacy/input.mjs";import{useEffect as v,useMemo as y,useRef as b,useState as x}from"react";import{jsx as S,jsxs as C}from"react/jsx-runtime";import{toast as w}from"sonner";import{useTranslations as T}from"next-intl";function E(E){let D=T(`components.pages.settings.components`),{open:O,onOpenChange:k}=E,A=n(e=>e.userInfo),[j,M]=x(``),ne=j.length!==6,N=b(null),[P,F]=x(60),[I,L]=x(!1);async function R(){if(I)return;let e=w.loading(D(`resetPasswordDrawer.sending`));try{let t=await r({user_id:A?.user_id});t.code===0?(w.success(D(`resetPasswordDrawer.codeSentSuccess`),{id:e}),L(!0),F(60)):w.error(t.message||D(`resetPasswordDrawer.sendFailed`),{id:e})}catch(t){console.error(t),w.error(D(`resetPasswordDrawer.sendFailed`),{id:e})}}function z(){H(e=>e===1?e:e+1)}async function B(){let e=w.loading(D(`resetPasswordDrawer.verifying`));try{let t=await i({user_id:A?.user_id,email_code:j});t.code===0?(w.success(D(`resetPasswordDrawer.verifySuccess`),{id:e}),z()):w.error(t.message||D(`resetPasswordDrawer.verifyFailed`),{id:e})}catch(t){console.error(t),w.error(D(`resetPasswordDrawer.verifyFailed`),{id:e})}}v(()=>{if(I)return N.current=setInterval(()=>{F(e=>e<=1?(N.current&&clearInterval(N.current),L(!1),60):e-1)},1e3),()=>{N.current&&clearInterval(N.current)}},[I]);let[V,H]=x(0),[U,W]=x({password:``,confirmPassword:``}),[G,K]=x(!1),[q,J]=x(!1),[Y,X]=x(!1),Z=y(()=>te(U.password,U.confirmPassword),[U.password,U.confirmPassword]),Q=y(()=>a(Z),[Z]),$=y(()=>G||U.password.length===0||U.confirmPassword.length===0||Z.type!==`none`,[G,U.password.length,U.confirmPassword.length,Z.type]);async function re(){if($)return;let e=w.loading(D(`resetPasswordDrawer.submitting`));try{K(!0);let n=await ee({user_id:A?.user_id,password:t(U.password)});n.code===0?(w.success(D(`resetPasswordDrawer.passwordResetSuccess`),{id:e}),W({password:``,confirmPassword:``}),M(``),k(!1)):w.error(n.message||D(`resetPasswordDrawer.resetFailed`),{id:e})}catch(t){console.error(t),w.error(D(`resetPasswordDrawer.resetFailed`),{id:e})}finally{K(!1)}}let ie=C(o,{className:`p-6`,children:[S(o,{children:C(f,{className:`text-text2`,children:[D(`resetPasswordDrawer.boundEmailNotice`),S(f,{className:`dark:text-white text-white`,children:A?.email}),D(`resetPasswordDrawer.verifyHint`)]})}),C(o,{className:`mt-6 space-y-6`,children:[C(o,{className:`flex relative items-center px-2 rounded-[50px] h-16.5 bg-line1 border border-line1`,children:[S(_,{value:j,onChange:e=>M(e)}),S(e,{variant:`link`,disabled:I,onClick:R,children:I?`${P}s ${D(`resetPasswordDrawer.resendAfter`)}`:D(`resetPasswordDrawer.sendCode`)})]}),S(p,{onClick:B,disabled:ne,className:`w-full h-15 !rounded-[30px] !text-[18px] font-bold leading-6.5 bg-theme6 disabled:bg-theme6/40 disabled:text-text3 active:opacity-90 !px-0 !py-0`,children:D(`resetPasswordDrawer.verifyEmailButton`)})]})]}),ae=C(o,{className:`p-6`,children:[S(o,{children:S(f,{className:`text-text2`,children:D(`resetPasswordDrawer.setNewPasswordHint`)})}),C(o,{className:`mt-6 space-y-6`,children:[C(o,{className:`flex relative items-center px-2 rounded-[50px] h-16.5 bg-line1 border ${Q?`border-theme5`:`border-line1`}`,children:[S(_,{value:U.password,onChange:e=>W(t=>({...t,password:e})),placeholder:D(`resetPasswordDrawer.passwordPlaceholder`),type:q?`text`:`password`,autoComplete:`new-password`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-form-type":`other`,className:`pr-10`}),S(`button`,{type:`button`,onClick:()=>J(!q),className:`absolute right-4 top-1/2 -translate-y-1/2 text-text2 hover:text-text1 transition-colors`,children:S(q?h:m,{className:`w-5 h-5`})})]}),C(o,{className:`flex relative items-center px-2 rounded-[50px] h-16.5 bg-line1 border ${Z.type===`not-match`?`border-theme5`:`border-line1`}`,children:[S(_,{value:U.confirmPassword,onChange:e=>W(t=>({...t,confirmPassword:e})),placeholder:D(`resetPasswordDrawer.confirmPasswordPlaceholder`),type:Y?`text`:`password`,autoComplete:`new-password`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,"data-lpignore":`true`,"data-1p-ignore":`true`,"data-form-type":`other`,className:`pr-10`}),S(`button`,{type:`button`,onClick:()=>X(!Y),className:`absolute right-4 top-1/2 -translate-y-1/2 text-text2 hover:text-text1 transition-colors`,children:S(Y?h:m,{className:`w-5 h-5`})})]}),Q?S(o,{children:S(f,{className:`min-h-[22px] text-[14px] text-theme5 px-[12px]`,children:Q})}):null,S(p,{onClick:re,disabled:$,className:`w-full h-15 !rounded-[30px] !text-[18px] font-bold leading-6.5 bg-theme6 disabled:bg-theme6/40 disabled:text-text3 active:opacity-90 !px-0 !py-0`,children:D(G?`resetPasswordDrawer.submitting`:`resetPasswordDrawer.resetPassword`)})]})]});return C(s,{open:O,onOpenChange:k,direction:`right`,handleOnly:!0,children:[C(u,{className:`hidden`,children:[S(d,{children:D(`resetPasswordDrawer.title`)}),S(l,{children:D(`resetPasswordDrawer.title`)})]}),C(c,{className:`!w-full`,children:[S(g,{onBack:()=>k(!1),title:D(`resetPasswordDrawer.title`)}),V===0&&ie,V===1&&ae]})]})}export{E as ResetPasswordDrawer};
|
|
@@ -8,7 +8,7 @@ import * as class_variance_authority_types0 from "class-variance-authority/types
|
|
|
8
8
|
/** buttonVariants 工具定义。 */
|
|
9
9
|
declare const buttonVariants: (props?: ({
|
|
10
10
|
variant?: "link" | "default" | "destructive" | "secondary" | "outline" | "ghost" | null | undefined;
|
|
11
|
-
size?: "default" | "
|
|
11
|
+
size?: "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
|
|
12
12
|
} & class_variance_authority_types0.ClassProp) | undefined) => string;
|
|
13
13
|
/** Button 组件属性。 */
|
|
14
14
|
type ButtonProps = Button.Props & VariantProps<typeof buttonVariants> & {
|