refactor: enhance flow type safety and clean up unused code (#5669)

* 📝 (use-save-flow.ts): add AllNodeType and EdgeType imports to improve type safety in useSaveFlow hook
📝 (index.tsx): remove unused setNoticeData function to clean up code and improve readability

* refactor: Remove unused code in GeneralPage component

* refactor: Remove unused code in cardComponent/index.tsx

---------

Co-authored-by: anovazzi1 <otavio2204@gmail.com>
This commit is contained in:
Cristhian Zanforlin Lousa 2025-01-16 18:11:07 -03:00 committed by GitHub
commit e1b5c70fa3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 6 additions and 10 deletions

View file

@ -18,7 +18,6 @@ import {
} from "../../ui/card";
import { Checkbox } from "../../ui/checkbox";
import { FormControl, FormField } from "../../ui/form";
import Loading from "../../ui/loading";
import useDragStart from "./hooks/use-on-drag-start";
import { convertTestName } from "./utils/convert-test-name";

View file

@ -3,7 +3,7 @@ import { usePatchUpdateFlow } from "@/controllers/API/queries/flows/use-patch-up
import useAlertStore from "@/stores/alertStore";
import useFlowsManagerStore from "@/stores/flowsManagerStore";
import useFlowStore from "@/stores/flowStore";
import { FlowType } from "@/types/flow";
import { AllNodeType, EdgeType, FlowType } from "@/types/flow";
import { customStringify } from "@/utils/reactflowUtils";
import { ReactFlowJsonObject } from "@xyflow/react";
@ -52,7 +52,10 @@ const useSaveFlow = () => {
{ id: flow!.id },
{
onSuccess: (flowResponse) => {
flow!.data = flowResponse.data as ReactFlowJsonObject;
flow!.data = flowResponse.data as ReactFlowJsonObject<
AllNodeType,
EdgeType
>;
},
},
);

View file

@ -115,7 +115,6 @@ export default function Page({ view }: { view?: boolean }): JSX.Element {
);
const onConnect = useFlowStore((state) => state.onConnect);
const setErrorData = useAlertStore((state) => state.setErrorData);
const setNoticeData = useAlertStore((state) => state.setNoticeData);
const updateCurrentFlow = useFlowStore((state) => state.updateCurrentFlow);
const [selectionMenuVisible, setSelectionMenuVisible] = useState(false);
const edgeUpdateSuccessful = useRef(true);

View file

@ -24,7 +24,6 @@ import {
patchUserInputStateType,
} from "../../../../types/components";
import useScrollToElement from "../hooks/use-scroll-to-element";
import StoreApiKeyFormComponent from "../StoreApiKeyPage/components/StoreApiKeyForm";
import GeneralPageHeaderComponent from "./components/GeneralPageHeader";
import PasswordFormComponent from "./components/PasswordForm";
import ProfilePictureFormComponent from "./components/ProfilePictureForm";
@ -39,11 +38,7 @@ export const GeneralPage = () => {
const setSuccessData = useAlertStore((state) => state.setSuccessData);
const setErrorData = useAlertStore((state) => state.setErrorData);
const { userData, setUserData } = useContext(AuthContext);
const hasStore = useStoreStore((state) => state.hasStore);
const validApiKey = useStoreStore((state) => state.validApiKey);
const hasApiKey = useStoreStore((state) => state.hasApiKey);
const loadingApiKey = useStoreStore((state) => state.loadingApiKey);
const { password, cnfPassword, profilePicture, apikey } = inputState;
const { password, cnfPassword, profilePicture } = inputState;
const autoLogin = useAuthStore((state) => state.autoLogin);
const { storeApiKey } = useContext(AuthContext);