File size: 1,208 Bytes
be99f83 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
import { useSetModalState } from '@/hooks/commonHooks';
import { useFetchFlowList, useSetFlow } from '@/hooks/flow-hooks';
import { useCallback, useState } from 'react';
import { dsl } from '../mock';
export const useFetchDataOnMount = () => {
const { data, loading } = useFetchFlowList();
return { list: data, loading };
};
export const useSaveFlow = () => {
const [currentFlow, setCurrentFlow] = useState({});
const {
visible: flowSettingVisible,
hideModal: hideFlowSettingModal,
showModal: showFileRenameModal,
} = useSetModalState();
const { loading, setFlow } = useSetFlow();
const onFlowOk = useCallback(
async (title: string) => {
const ret = await setFlow({ title, dsl });
if (ret === 0) {
hideFlowSettingModal();
}
},
[setFlow, hideFlowSettingModal],
);
const handleShowFlowSettingModal = useCallback(
async (record: any) => {
setCurrentFlow(record);
showFileRenameModal();
},
[showFileRenameModal],
);
return {
flowSettingLoading: loading,
initialFlowName: '',
onFlowOk,
flowSettingVisible,
hideFlowSettingModal,
showFlowSettingModal: handleShowFlowSettingModal,
};
};
|