refactor: Change types to types folder

This commit is contained in:
Igor Carvalho 2023-07-25 20:43:11 -03:00
commit 91e0bf7a01
6 changed files with 61 additions and 37 deletions

View file

@ -10,7 +10,7 @@ import {
DialogTrigger, DialogTrigger,
} from "../../components/ui/dialog"; } from "../../components/ui/dialog";
import { PopUpContext } from "../../contexts/popUpContext"; import { PopUpContext } from "../../contexts/popUpContext";
import { ContentProps, HeaderProps } from "../../types/components"; import { ContentProps, HeaderProps, headerConstType } from "../../types/components";
const Content: React.FC<ContentProps> = ({ children }) => { const Content: React.FC<ContentProps> = ({ children }) => {
return <div className="h-full w-full">{children}</div>; return <div className="h-full w-full">{children}</div>;
@ -19,7 +19,7 @@ const Content: React.FC<ContentProps> = ({ children }) => {
const Header: React.FC<{ children: ReactNode; description: string }> = ({ const Header: React.FC<{ children: ReactNode; description: string }> = ({
children, children,
description, description,
}) => { }: headerConstType): JSX.Element => {
return ( return (
<DialogHeader> <DialogHeader>
<DialogTitle className="flex items-center">{children}</DialogTitle> <DialogTitle className="flex items-center">{children}</DialogTitle>
@ -32,10 +32,10 @@ interface BaseModalProps {
open: boolean; open: boolean;
setOpen: (open: boolean) => void; setOpen: (open: boolean) => void;
} }
function BaseModal({ open, setOpen, children }: BaseModalProps) { function BaseModal({ open, setOpen, children }: BaseModalProps): JSX.Element {
const { closePopUp, setCloseEdit } = useContext(PopUpContext); const { closePopUp, setCloseEdit } = useContext(PopUpContext);
function setModalOpen(x: boolean) { function setModalOpen(x: boolean): void {
setOpen(x); setOpen(x);
if (x === false) { if (x === false) {
setTimeout(() => { setTimeout(() => {

View file

@ -15,18 +15,14 @@ import { PopUpContext } from "../../contexts/popUpContext";
import { postValidateCode } from "../../controllers/API"; import { postValidateCode } from "../../controllers/API";
import { APIClassType } from "../../types/api"; import { APIClassType } from "../../types/api";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import { codeAreaModalPropsType } from "../../types/components";
export default function CodeAreaModal({ export default function CodeAreaModal({
value, value,
setValue, setValue,
nodeClass, nodeClass,
setNodeClass, setNodeClass,
}: { }: codeAreaModalPropsType): JSX.Element {
setValue: (value: string) => void;
value: string;
nodeClass: APIClassType;
setNodeClass: (Class: APIClassType) => void;
}): JSX.Element {
const [code, setCode] = useState(value); const [code, setCode] = useState(value);
const { dark } = useContext(darkContext); const { dark } = useContext(darkContext);
const { closePopUp, setCloseEdit } = useContext(PopUpContext); const { closePopUp, setCloseEdit } = useContext(PopUpContext);

View file

@ -12,15 +12,12 @@ import { ChatMessageType } from "../../../types/chat";
import { classNames } from "../../../utils/utils"; import { classNames } from "../../../utils/utils";
import FileCard from "../fileComponent"; import FileCard from "../fileComponent";
import { CodeBlock } from "./codeBlock"; import { CodeBlock } from "./codeBlock";
import { chatMessagePropsType } from "../../../types/components";
export default function ChatMessage({ export default function ChatMessage({
chat, chat,
lockChat, lockChat,
lastMessage, lastMessage,
}: { }: chatMessagePropsType): JSX.Element {
chat: ChatMessageType;
lockChat: boolean;
lastMessage: boolean;
}): JSX.Element {
const convert = new Convert({ newline: true }); const convert = new Convert({ newline: true });
const [hidden, setHidden] = useState(true); const [hidden, setHidden] = useState(true);
const template = chat.template; const template = chat.template;

View file

@ -25,6 +25,7 @@ import {
varHighlightHTML, varHighlightHTML,
} from "../../utils/utils"; } from "../../utils/utils";
import BaseModal from "../baseModal"; import BaseModal from "../baseModal";
import { genericModalPropsType } from "../../types/components";
export default function GenericModal({ export default function GenericModal({
field_name = "", field_name = "",
@ -35,16 +36,7 @@ export default function GenericModal({
type, type,
nodeClass, nodeClass,
setNodeClass, setNodeClass,
}: { }: genericModalPropsType): JSX.Element {
field_name?: string;
setValue: (value: string) => void;
value: string;
buttonText: string;
modalTitle: string;
type: number;
nodeClass?: APIClassType;
setNodeClass?: (Class: APIClassType) => void;
}): JSX.Element {
const [myButtonText] = useState(buttonText); const [myButtonText] = useState(buttonText);
const [myModalTitle] = useState(modalTitle); const [myModalTitle] = useState(modalTitle);
const [myModalType] = useState(type); const [myModalType] = useState(type);

View file

@ -1,5 +1,6 @@
import { ReactNode } from "react"; import { ReactNode } from "react";
import { classNames } from "../../../utils/utils"; import { classNames } from "../../../utils/utils";
import { buttonBoxPropsType } from "../../../types/components";
export default function ButtonBox({ export default function ButtonBox({
onClick, onClick,
@ -10,16 +11,7 @@ export default function ButtonBox({
textColor, textColor,
deactivate, deactivate,
size, size,
}: { }: buttonBoxPropsType): JSX.Element {
onClick: () => void;
title: string;
description: string;
icon: ReactNode;
bgColor: string;
textColor: string;
deactivate?: boolean;
size: "small" | "medium" | "big";
}): JSX.Element {
let bigCircle: string; let bigCircle: string;
let smallCircle: string; let smallCircle: string;
let titleFontSize: string; let titleFontSize: string;

View file

@ -1,7 +1,8 @@
import { ForwardRefExoticComponent, ReactElement, ReactNode, RefAttributes, SVGProps } from "react"; import { ForwardRefExoticComponent, ReactElement, ReactNode, RefAttributes, SVGProps } from "react";
import { APIClassType } from "../api"; import { APIClassType } from "../api";
import { FlowStyleType, NodeDataType } from "../flow/index"; import { FlowStyleType, FlowType, NodeDataType } from "../flow/index";
import { typesContextType } from "../typesContext"; import { typesContextType } from "../typesContext";
import { ChatMessageType } from "../chat";
export type InputComponentType = { export type InputComponentType = {
value: string; value: string;
@ -303,9 +304,55 @@ export type SanitizedHTMLWrapperType = {
className: string; className: string;
content: string; content: string;
onClick: () => void; onClick: () => void;
suppressWarning: boolean; suppressWarning?: boolean;
}; };
export type iconsType = { export type iconsType = {
[key: string]: React.ElementType; [key: string]: React.ElementType;
}; };
export type headerConstType = {
children: ReactNode;
description: string;
};
export type codeAreaModalPropsType = {
setValue: (value: string) => void;
value: string;
nodeClass: APIClassType;
setNodeClass: (Class: APIClassType) => void;
};
export type chatMessagePropsType = {
chat: ChatMessageType;
lockChat: boolean;
lastMessage: boolean;
};
export type formModalPropsType = {
open: boolean;
setOpen: Function;
flow: FlowType;
};
export type genericModalPropsType = {
field_name?: string;
setValue: (value: string) => void;
value: string;
buttonText: string;
modalTitle: string;
type: number;
nodeClass?: APIClassType;
setNodeClass?: (Class: APIClassType) => void;
};
export type buttonBoxPropsType = {
onClick: () => void;
title: string;
description: string;
icon: ReactNode;
bgColor: string;
textColor: string;
deactivate?: boolean;
size: "small" | "medium" | "big";
};