diff --git a/frontend/src/views/ShareSecretPublicPage/components/SecretTable.tsx b/frontend/src/views/ShareSecretPublicPage/components/SecretTable.tsx index 2d405f118..f33f958af 100644 --- a/frontend/src/views/ShareSecretPublicPage/components/SecretTable.tsx +++ b/frontend/src/views/ShareSecretPublicPage/components/SecretTable.tsx @@ -1,7 +1,8 @@ -import { faCheck, faCopy, faKey } from "@fortawesome/free-solid-svg-icons"; +import { faCheck, faCopy, faEye, faEyeSlash, faKey } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { EmptyState, IconButton, Td, Tr } from "@app/components/v2"; +import { useToggle } from "@app/hooks"; type Props = { isLoading: boolean; @@ -10,39 +11,68 @@ type Props = { copyUrlToClipboard: () => void; }; +const replaceContentWithDot = (str: string) => { + let finalStr = ""; + for (let i = 0; i < str.length; i += 1) { + const char = str.at(i); + finalStr += char === "\n" ? "\n" : "*"; + } + return finalStr; +}; + export const SecretTable = ({ isLoading, decryptedSecret, isUrlCopied, copyUrlToClipboard -}: Props) => ( -
- {isLoading &&
Loading...
} - {!isLoading && !decryptedSecret && ( - - - - - - )} - {!isLoading && decryptedSecret && ( -
-
-
- {decryptedSecret} +}: Props) => { + const [isVisible, setIsVisible] = useToggle(false); + + return ( +
+ {isLoading &&
Loading...
} + {!isLoading && !decryptedSecret && ( + + + + + + )} + {!isLoading && decryptedSecret && ( +
+
+
+ {isVisible ? decryptedSecret : replaceContentWithDot(decryptedSecret)} +
+
+
+ + Copy + + setIsVisible.toggle()} + className="flex max-h-8 items-center rounded" + size="xs" + > + +
- - Copy - -
- )} -
-); + )} +
+ ); +};