diff --git a/src/routes/admin.users.tsx b/src/routes/admin.users.tsx index af07c44..68fb4ef 100644 --- a/src/routes/admin.users.tsx +++ b/src/routes/admin.users.tsx @@ -189,7 +189,7 @@ function UsersPage() { Email Role Hourly rate - + Actions @@ -315,6 +315,69 @@ function RateInput({ } +function SetPasswordDialog({ userId, email }: { userId: string; email: string }) { + const [open, setOpen] = useState(false); + const [password, setPassword] = useState(""); + const [submitting, setSubmitting] = useState(false); + + const onSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setSubmitting(true); + const { error } = await supabase.functions.invoke("admin-set-password", { + body: { user_id: userId, password }, + }); + setSubmitting(false); + if (error) { + toast.error("Could not change password", { description: error.message }); + return; + } + toast.success("Password updated", { + description: "Share the new password securely with the user.", + }); + setPassword(""); + setOpen(false); + }; + + return ( + + + + + + + Change password + + Set a new password for {email}. Share it with them through a secure channel. + + +
+
+ + setPassword(e.target.value)} + minLength={10} + required + autoFocus + /> +

Min 10 characters.

+
+ + + +
+
+
+ ); +} + function InviteDialog({ onCreated }: { onCreated: () => void }) { const [email, setEmail] = useState(""); const [fullName, setFullName] = useState("");