Skip to content

Commit 88a0ffd

Browse files
committed
feat(console): add eye close/open for auth key field
Signed-off-by: Praveen Yadav <pyadav9678@gmail.com>
1 parent 3b821b9 commit 88a0ffd

2 files changed

Lines changed: 29 additions & 9 deletions

File tree

frontend/apps/console/app/(llm)/providers/[providerId]/page.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client";
22

3+
import { EyeClosedIcon, EyeOpenIcon } from "@radix-ui/react-icons";
4+
35
import { Button } from "@missingstudio/ui/button";
46
import { Input } from "@missingstudio/ui/input";
57
import { Loader } from "lucide-react";
@@ -14,7 +16,7 @@ import { toast } from "sonner";
1416
import * as z from "zod";
1517

1618
import { Label } from "@missingstudio/ui/label";
17-
import { useEffect } from "react";
19+
import { HTMLInputTypeAttribute, useEffect, useState } from "react";
1820
import ProvidersIcon from "~/public/providers-icon.svg";
1921
import ProvidersImg from "~/public/providers-image.png";
2022
import Star from "~/public/star.svg";
@@ -37,6 +39,8 @@ const formSchema = z.object({
3739
type FormValues = z.infer<typeof formSchema>;
3840

3941
export default function SingleProvider() {
42+
const [authInputType, setAuthInputType] =
43+
useState<HTMLInputTypeAttribute>("password");
4044
const params = useParams<{ providerId: string }>();
4145
const { config, provider } = useProviderFetch(params.providerId);
4246

@@ -181,18 +185,34 @@ export default function SingleProvider() {
181185
{Object.keys(headersProperties).map((hp: string) => {
182186
const { title, description } = headersProperties[hp];
183187
return (
184-
<div key="hp">
188+
<div key="hp" className="relative">
185189
<Label>{title}</Label>
186190
<Controller
187191
key={hp}
188192
render={({ field: { value, onChange } }) => (
189-
<Input
190-
className="col-span-2"
191-
// @ts-ignore
192-
value={value}
193-
onChange={onChange}
194-
placeholder={description}
195-
/>
193+
<>
194+
<Input
195+
className="col-span-2"
196+
type={authInputType}
197+
// @ts-ignore
198+
value={value}
199+
onChange={onChange}
200+
placeholder={description}
201+
/>
202+
{authInputType == "password" ? (
203+
<EyeOpenIcon
204+
className="absolute bottom-3 right-2 bg-white p-[2px] w-4 cursor-pointer"
205+
onClick={() => setAuthInputType("text")}
206+
/>
207+
) : (
208+
<EyeClosedIcon
209+
className="absolute bottom-3 right-2 bg-white p-[2px] w-4 cursor-pointer"
210+
onClick={() =>
211+
setAuthInputType("password")
212+
}
213+
/>
214+
)}
215+
</>
196216
)}
197217
// @ts-ignore
198218
name={`config.headers.${hp}`}
6.97 KB
Binary file not shown.

0 commit comments

Comments
 (0)