feat: add password visibility toggle in Admin Settings and Add New Users
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
import { Eye, EyeOff } from "lucide-react";
|
||||||
import { useQuery, useMutation } from "@tanstack/react-query";
|
import { useQuery, useMutation } from "@tanstack/react-query";
|
||||||
import { StaffTable } from "@/components/staffs/staff-table";
|
import { StaffTable } from "@/components/staffs/staff-table";
|
||||||
import { useToast } from "@/hooks/use-toast";
|
import { useToast } from "@/hooks/use-toast";
|
||||||
@@ -219,6 +220,8 @@ export default function SettingsPage() {
|
|||||||
// MANAGE USERS (admin only)
|
// MANAGE USERS (admin only)
|
||||||
const [newUsername, setNewUsername] = useState("");
|
const [newUsername, setNewUsername] = useState("");
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
|
const [showNewUserPassword, setShowNewUserPassword] = useState(false);
|
||||||
|
const [showAdminPassword, setShowAdminPassword] = useState(false);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: allUsers = [],
|
data: allUsers = [],
|
||||||
@@ -410,14 +413,24 @@ export default function SettingsPage() {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium">Password</label>
|
<label className="block text-sm font-medium">Password</label>
|
||||||
|
<div className="relative mt-1">
|
||||||
<input
|
<input
|
||||||
type="password"
|
type={showNewUserPassword ? "text" : "password"}
|
||||||
value={newPassword}
|
value={newPassword}
|
||||||
onChange={(e) => setNewPassword(e.target.value)}
|
onChange={(e) => setNewPassword(e.target.value)}
|
||||||
className="mt-1 p-2 border rounded w-full"
|
className="p-2 border rounded w-full pr-10"
|
||||||
placeholder="••••••••"
|
placeholder="••••••••"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowNewUserPassword((v) => !v)}
|
||||||
|
className="absolute inset-y-0 right-2 flex items-center text-gray-500 hover:text-gray-700"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
|
{showNewUserPassword ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
@@ -466,12 +479,22 @@ export default function SettingsPage() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium">New Password</label>
|
<label className="block text-sm font-medium">New Password</label>
|
||||||
|
<div className="relative mt-1">
|
||||||
<input
|
<input
|
||||||
type="password"
|
type={showAdminPassword ? "text" : "password"}
|
||||||
name="password"
|
name="password"
|
||||||
className="mt-1 p-2 border rounded w-full"
|
className="p-2 border rounded w-full pr-10"
|
||||||
placeholder="••••••••"
|
placeholder="••••••••"
|
||||||
/>
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowAdminPassword((v) => !v)}
|
||||||
|
className="absolute inset-y-0 right-2 flex items-center text-gray-500 hover:text-gray-700"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
|
{showAdminPassword ? <EyeOff size={16} /> : <Eye size={16} />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<p className="text-xs text-gray-500 mt-1">
|
<p className="text-xs text-gray-500 mt-1">
|
||||||
Leave blank to keep current password.
|
Leave blank to keep current password.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user