Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/leadin/scripts/shared/Form/hooks
File: useCreateFormFromTemplate.ts
import { useState } from 'react';
[0] Fix | Delete
import {
[1] Fix | Delete
usePostAsyncBackgroundMessage,
[2] Fix | Delete
usePostBackgroundMessage,
[3] Fix | Delete
} from '../../../iframe/useBackgroundApp';
[4] Fix | Delete
import { FormType } from '../../../constants/defaultFormOptions';
[5] Fix | Delete
import LoadState, { LoadStateType } from '../../enums/loadState';
[6] Fix | Delete
import { ProxyMessages } from '../../../iframe/integratedMessages';
[7] Fix | Delete
[8] Fix | Delete
export default function useCreateFormFromTemplate(origin = 'gutenberg') {
[9] Fix | Delete
const proxy = usePostAsyncBackgroundMessage();
[10] Fix | Delete
const track = usePostBackgroundMessage();
[11] Fix | Delete
const [loadState, setLoadState] = useState<LoadStateType>(LoadState.Idle);
[12] Fix | Delete
const [formApiError, setFormApiError] = useState<any>(null);
[13] Fix | Delete
[14] Fix | Delete
const createFormByTemplate = (type: FormType) => {
[15] Fix | Delete
setLoadState(LoadState.Loading);
[16] Fix | Delete
track({
[17] Fix | Delete
key: ProxyMessages.TrackFormCreatedFromTemplate,
[18] Fix | Delete
payload: {
[19] Fix | Delete
type,
[20] Fix | Delete
origin,
[21] Fix | Delete
},
[22] Fix | Delete
});
[23] Fix | Delete
[24] Fix | Delete
return proxy({
[25] Fix | Delete
key: ProxyMessages.CreateFormFromTemplate,
[26] Fix | Delete
payload: type,
[27] Fix | Delete
})
[28] Fix | Delete
.then(form => {
[29] Fix | Delete
setLoadState(LoadState.Idle);
[30] Fix | Delete
return form;
[31] Fix | Delete
})
[32] Fix | Delete
.catch(err => {
[33] Fix | Delete
setFormApiError(err);
[34] Fix | Delete
track({
[35] Fix | Delete
key: ProxyMessages.TrackFormCreationFailed,
[36] Fix | Delete
payload: {
[37] Fix | Delete
origin,
[38] Fix | Delete
},
[39] Fix | Delete
});
[40] Fix | Delete
setLoadState(LoadState.Failed);
[41] Fix | Delete
});
[42] Fix | Delete
};
[43] Fix | Delete
[44] Fix | Delete
return {
[45] Fix | Delete
isCreating: loadState === LoadState.Loading,
[46] Fix | Delete
hasError: loadState === LoadState.Failed,
[47] Fix | Delete
formApiError,
[48] Fix | Delete
createFormByTemplate,
[49] Fix | Delete
reset: () => setLoadState(LoadState.Idle),
[50] Fix | Delete
};
[51] Fix | Delete
}
[52] Fix | Delete
[53] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function