1 line
7.0 KiB
JavaScript
1 line
7.0 KiB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,27180,e=>{"use strict";var t=e.i(43476),s=e.i(22016),r=e.i(71645),n=e.i(18566),o=e.i(56322),a=e.i(87849),i=e.i(94327);function d({embedded:e=!1}){let{language:a}=(0,o.useDashboardI18n)(),c={en:{title:"Set new password",subtitle:"Choose a strong password for your workspace account.",newPassword:"New password",confirmPassword:"Confirm password",submit:"Reset password",submitting:"Resetting…",backToLogin:"Back to sign in",successTitle:"Password updated",successBody:"Your password has been reset. You can now sign in with your new password.",signIn:"Sign in",errorMismatch:"Passwords do not match.",errorShort:"Password must be at least 8 characters.",errorInvalidToken:"This reset link is invalid or has expired. Please request a new one.",errorGeneric:"Something went wrong. Please try again.",noToken:"No reset token found. Please request a new password reset.",requestNew:"Request new reset link"},fr:{title:"Nouveau mot de passe",subtitle:"Choisissez un mot de passe fort pour votre compte.",newPassword:"Nouveau mot de passe",confirmPassword:"Confirmer le mot de passe",submit:"Réinitialiser",submitting:"Traitement…",backToLogin:"Retour à la connexion",successTitle:"Mot de passe mis à jour",successBody:"Votre mot de passe a été réinitialisé. Vous pouvez maintenant vous connecter.",signIn:"Se connecter",errorMismatch:"Les mots de passe ne correspondent pas.",errorShort:"Le mot de passe doit contenir au moins 8 caractères.",errorInvalidToken:"Ce lien est invalide ou a expiré. Veuillez en demander un nouveau.",errorGeneric:"Une erreur est survenue. Veuillez réessayer.",noToken:"Aucun jeton de réinitialisation trouvé. Veuillez demander un nouveau lien.",requestNew:"Demander un nouveau lien"},ar:{title:"تعيين كلمة مرور جديدة",subtitle:"اختر كلمة مرور قوية لحساب مساحة العمل.",newPassword:"كلمة المرور الجديدة",confirmPassword:"تأكيد كلمة المرور",submit:"إعادة تعيين",submitting:"جارٍ المعالجة…",backToLogin:"العودة إلى تسجيل الدخول",successTitle:"تم تحديث كلمة المرور",successBody:"تم إعادة تعيين كلمة المرور. يمكنك الآن تسجيل الدخول.",signIn:"تسجيل الدخول",errorMismatch:"كلمتا المرور غير متطابقتين.",errorShort:"يجب أن تتكون كلمة المرور من 8 أحرف على الأقل.",errorInvalidToken:"رابط إعادة التعيين غير صالح أو منتهي الصلاحية.",errorGeneric:"حدث خطأ ما. يرجى المحاولة مرة أخرى.",noToken:"لم يتم العثور على رمز إعادة التعيين. يرجى طلب رابط جديد.",requestNew:"طلب رابط جديد"}}[a],u=(0,n.useSearchParams)().get("token"),[m,x]=(0,r.useState)(""),[h,p]=(0,r.useState)(""),[b,f]=(0,r.useState)(!1),[w,k]=(0,r.useState)(!1),[g,j]=(0,r.useState)(null);async function v(e){if(e.preventDefault(),m.length<8)return void j(c.errorShort);if(m!==h)return void j(c.errorMismatch);f(!0),j(null);try{let e=await fetch(`${i.API_BASE}/auth/employee/reset-password`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:u,password:m})}),t=await e.json();if(!e.ok){if(t?.error==="invalid_token")throw Error(c.errorInvalidToken);throw Error(c.errorGeneric)}k(!0)}catch(e){j(e.message??c.errorGeneric)}finally{f(!1)}}return u?w?(0,t.jsx)(l,{embedded:e,title:c.title,children:(0,t.jsxs)("div",{className:"space-y-4 text-center",children:[(0,t.jsx)("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-emerald-100 dark:bg-emerald-950/50",children:(0,t.jsx)("svg",{className:"h-7 w-7 text-emerald-600 dark:text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),(0,t.jsx)("h2",{className:"text-xl font-bold text-stone-900 dark:text-stone-100",children:c.successTitle}),(0,t.jsx)("p",{className:"text-sm text-stone-500 dark:text-stone-400",children:c.successBody}),(0,t.jsx)(s.default,{href:"/sign-in",className:"btn-primary inline-flex justify-center",children:c.signIn})]})}):(0,t.jsxs)(l,{embedded:e,title:c.title,subtitle:c.subtitle,children:[(0,t.jsxs)("form",{onSubmit:v,className:"space-y-5",children:[g&&(0,t.jsx)("div",{className:"rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700 dark:border-rose-800 dark:bg-rose-950/40 dark:text-rose-400",children:g}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-stone-700 dark:text-stone-300",children:c.newPassword}),(0,t.jsx)("input",{type:"password",required:!0,minLength:8,value:m,onChange:e=>x(e.target.value),placeholder:"••••••••",className:"input-field"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"mb-1.5 block text-sm font-medium text-stone-700 dark:text-stone-300",children:c.confirmPassword}),(0,t.jsx)("input",{type:"password",required:!0,minLength:8,value:h,onChange:e=>p(e.target.value),placeholder:"••••••••",className:"input-field"})]}),(0,t.jsx)("button",{type:"submit",disabled:b,className:"btn-primary w-full justify-center disabled:cursor-not-allowed disabled:opacity-60",children:b?c.submitting:c.submit})]}),(0,t.jsx)("div",{className:"mt-6 border-t border-stone-200 pt-6 text-center text-sm text-stone-500 dark:border-blue-900 dark:text-stone-400",children:(0,t.jsx)(s.default,{href:"/sign-in",className:"font-semibold text-stone-900 underline decoration-stone-300 underline-offset-4 dark:text-stone-100 dark:decoration-stone-700",children:c.backToLogin})})]}):(0,t.jsxs)(l,{embedded:e,title:c.title,children:[(0,t.jsx)("p",{className:"text-center text-sm text-stone-500 dark:text-stone-400",children:c.noToken}),(0,t.jsx)("div",{className:"mt-4 text-center",children:(0,t.jsx)(s.default,{href:"/forgot-password",className:"btn-primary inline-flex",children:c.requestNew})})]})}function l({embedded:e=!1,title:s,subtitle:r,children:n}){return(0,t.jsx)(a.default,{embedded:e,children:(0,t.jsx)("main",{className:"flex min-h-[calc(100vh-80px)] items-center justify-center px-4 py-12",children:(0,t.jsxs)("div",{className:"w-full max-w-md",children:[(0,t.jsxs)("div",{className:"mb-8 text-center",children:[(0,t.jsx)("span",{className:"text-xs font-semibold uppercase tracking-[0.24em] text-orange-700 dark:text-orange-400",children:"RentalDriveGo"}),(0,t.jsx)("h1",{className:"mt-3 text-3xl font-black tracking-tight text-stone-900 dark:text-stone-100",children:s}),r&&(0,t.jsx)("p",{className:"mt-2 text-sm text-stone-500 dark:text-stone-400",children:r})]}),(0,t.jsx)("section",{className:"rounded-[2rem] border border-stone-200 bg-white p-8 shadow-sm transition-colors dark:border-blue-900 dark:bg-blue-950",children:n})]})})})}e.s(["default",0,function({embedded:e=!1}){return(0,t.jsx)(r.Suspense,{children:(0,t.jsx)(d,{embedded:e})})}])}]); |