refactor[modals]: Remove any types

This commit is contained in:
Igor Carvalho 2023-07-24 14:10:38 -03:00
commit 53a20ecccf
6 changed files with 26 additions and 17 deletions

View file

@ -26,7 +26,7 @@ export default function ExportModal(): JSX.Element {
const { flows, tabId, updateFlow, downloadFlow, saveFlow } =
useContext(TabsContext);
const [isMaxLength, setIsMaxLength] = useState(false);
function setModalOpen(x: boolean) {
function setModalOpen(x: boolean): void {
setOpen(x);
if (x === false) {
setTimeout(() => {
@ -67,7 +67,7 @@ export default function ExportModal(): JSX.Element {
<div className="flex items-center space-x-2">
<Checkbox
id="terms"
onCheckedChange={(event: boolean) => {
onCheckedChange={(event: boolean): void => {
setChecked(event);
}}
/>

View file

@ -27,7 +27,7 @@ export default function ChatInput({
return (
<div className="relative">
<textarea
onKeyDown={(event) => {
onKeyDown={(event): void => {
if (event.key === "Enter" && !lockChat && !event.shiftKey) {
sendMessage();
}
@ -46,7 +46,7 @@ export default function ChatInput({
}`,
}}
value={lockChat ? "Thinking..." : chatValue}
onChange={(e) => {
onChange={(e): void => {
setChatValue(e.target.value);
}}
className={classNames(
@ -75,7 +75,7 @@ export default function ChatInput({
: "bg-emerald-600 text-background"
)}
disabled={lockChat}
onClick={() => sendMessage()}
onClick={(): void => sendMessage()}
>
{lockChat ? (
<IconComponent

View file

@ -3,16 +3,12 @@ import { useState } from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { oneDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
import { programmingLanguages } from "../../../../constants/constants";
interface Props {
language: string;
value: string;
}
import { Props } from "../../../../types/components";
export function CodeBlock({ language, value }: Props): JSX.Element {
const [isCopied, setIsCopied] = useState<Boolean>(false);
const copyToClipboard = () => {
const copyToClipboard = (): void => {
if (!navigator.clipboard || !navigator.clipboard.writeText) {
return;
}
@ -25,7 +21,7 @@ export function CodeBlock({ language, value }: Props): JSX.Element {
}, 2000);
});
};
const downloadAsFile = () => {
const downloadAsFile = (): void => {
const fileExtension = programmingLanguages[language] || ".file";
const suggestedFileName = `${"generated-code"}${fileExtension}`;
const fileName = window.prompt("enter file name", suggestedFileName);

View file

@ -57,7 +57,7 @@ export default function ChatMessage({
<div className="form-modal-chat-text">
{hidden && chat.thought && chat.thought !== "" && (
<div
onClick={() => setHidden((prev) => !prev)}
onClick={(): void => setHidden((prev) => !prev)}
className="form-modal-chat-icon-div"
>
<IconComponent

View file

@ -1,9 +1,10 @@
import * as base64js from "base64-js";
import { useState } from "react";
import IconComponent from "../../../components/genericIconComponent";
import { fileCardPropsType } from "../../../types/components";
export default function FileCard({ fileName, content, fileType }) {
const handleDownload = () => {
export default function FileCard({ fileName, content, fileType }: fileCardPropsType): JSX.Element {
const handleDownload = (): void => {
const byteArray = new Uint8Array(base64js.toByteArray(content));
const blob = new Blob([byteArray], { type: "application/octet-stream" });
const url = URL.createObjectURL(blob);
@ -16,10 +17,10 @@ export default function FileCard({ fileName, content, fileType }) {
URL.revokeObjectURL(url);
};
const [isHovered, setIsHovered] = useState(false);
function handleMouseEnter() {
function handleMouseEnter(): void {
setIsHovered(true);
}
function handleMouseLeave() {
function handleMouseLeave(): void {
setIsHovered(false);
}
@ -55,6 +56,7 @@ export default function FileCard({ fileName, content, fileType }) {
return (
<button onClick={handleDownload} className="file-card-modal-button">
<div className="file-card-modal-div">
ooooooooooooooo
{" "}
{fileType === "image" ? (
<img

View file

@ -477,3 +477,14 @@ export type editNodeToggleType = {
show: boolean;
type: string;
};
export interface Props {
language: string;
value: string;
};
export type fileCardPropsType = {
fileName: string;
content: string;
fileType: string;
};