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
File: FormSelect.tsx
import React from 'react';
[0] Fix | Delete
import FormSelector from './FormSelector';
[1] Fix | Delete
import LoadingBlock from '../Common/LoadingBlock';
[2] Fix | Delete
import { __ } from '@wordpress/i18n';
[3] Fix | Delete
import useForms from './hooks/useForms';
[4] Fix | Delete
import useCreateFormFromTemplate from './hooks/useCreateFormFromTemplate';
[5] Fix | Delete
import { FormType, isDefaultForm } from '../../constants/defaultFormOptions';
[6] Fix | Delete
import ErrorHandler from '../Common/ErrorHandler';
[7] Fix | Delete
[8] Fix | Delete
interface IFormSelectProps {
[9] Fix | Delete
formId: string;
[10] Fix | Delete
formName: string;
[11] Fix | Delete
handleChange: Function;
[12] Fix | Delete
origin: 'gutenberg' | 'elementor';
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
export default function FormSelect({
[16] Fix | Delete
formId,
[17] Fix | Delete
formName,
[18] Fix | Delete
handleChange,
[19] Fix | Delete
origin = 'gutenberg',
[20] Fix | Delete
}: IFormSelectProps) {
[21] Fix | Delete
const { search, formApiError, reset } = useForms();
[22] Fix | Delete
const {
[23] Fix | Delete
createFormByTemplate,
[24] Fix | Delete
reset: createReset,
[25] Fix | Delete
isCreating,
[26] Fix | Delete
hasError,
[27] Fix | Delete
formApiError: createApiError,
[28] Fix | Delete
} = useCreateFormFromTemplate(origin);
[29] Fix | Delete
const value =
[30] Fix | Delete
formId && formName
[31] Fix | Delete
? {
[32] Fix | Delete
label: formName,
[33] Fix | Delete
value: formId,
[34] Fix | Delete
}
[35] Fix | Delete
: null;
[36] Fix | Delete
[37] Fix | Delete
const handleLocalChange = (option: { value: FormType }) => {
[38] Fix | Delete
if (isDefaultForm(option.value)) {
[39] Fix | Delete
createFormByTemplate(option.value).then(({ guid, name }) => {
[40] Fix | Delete
handleChange({
[41] Fix | Delete
value: guid,
[42] Fix | Delete
label: name,
[43] Fix | Delete
});
[44] Fix | Delete
});
[45] Fix | Delete
} else {
[46] Fix | Delete
handleChange(option);
[47] Fix | Delete
}
[48] Fix | Delete
};
[49] Fix | Delete
[50] Fix | Delete
return isCreating ? (
[51] Fix | Delete
<LoadingBlock />
[52] Fix | Delete
) : formApiError || createApiError ? (
[53] Fix | Delete
<ErrorHandler
[54] Fix | Delete
status={formApiError ? formApiError.status : createApiError.status}
[55] Fix | Delete
resetErrorState={() => {
[56] Fix | Delete
if (hasError) {
[57] Fix | Delete
createReset();
[58] Fix | Delete
} else {
[59] Fix | Delete
reset();
[60] Fix | Delete
}
[61] Fix | Delete
}}
[62] Fix | Delete
errorInfo={{
[63] Fix | Delete
header: __('There was a problem retrieving your forms', 'leadin'),
[64] Fix | Delete
message: __(
[65] Fix | Delete
'Please refresh your forms or try again in a few minutes',
[66] Fix | Delete
'leadin'
[67] Fix | Delete
),
[68] Fix | Delete
action: __('Refresh forms', 'leadin'),
[69] Fix | Delete
}}
[70] Fix | Delete
/>
[71] Fix | Delete
) : (
[72] Fix | Delete
<FormSelector
[73] Fix | Delete
loadOptions={search}
[74] Fix | Delete
onChange={(option: { value: FormType }) => handleLocalChange(option)}
[75] Fix | Delete
value={value}
[76] Fix | Delete
/>
[77] Fix | Delete
);
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function