- added bando preview page;
- added bando form preview;
This commit is contained in:
@@ -4,14 +4,15 @@ import { Controller } from 'react-hook-form';
|
||||
import { InputTextarea } from 'primereact/inputtextarea';
|
||||
|
||||
const TextArea = ({
|
||||
fieldName,
|
||||
label,
|
||||
control,
|
||||
errors,
|
||||
defaultValue,
|
||||
config = {},
|
||||
infoText = null
|
||||
}) => {
|
||||
fieldName,
|
||||
label,
|
||||
control,
|
||||
rows = 4,
|
||||
errors,
|
||||
defaultValue,
|
||||
config = {},
|
||||
infoText = null
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
|
||||
@@ -24,6 +25,7 @@ const TextArea = ({
|
||||
rules={config}
|
||||
render={({ field, fieldState }) => (
|
||||
<InputTextarea id={field.name}
|
||||
rows={rows}
|
||||
{...field}
|
||||
className={classNames({ 'p-invalid': fieldState.invalid })}/>
|
||||
)}/>
|
||||
|
||||
@@ -48,6 +48,7 @@ const FormFieldRepeater = ({
|
||||
const newData = stateFieldData.map((o, i) => {
|
||||
if (i === index) {
|
||||
o.value = e.value;
|
||||
o.id = e.id;
|
||||
}
|
||||
return o;
|
||||
})
|
||||
|
||||
@@ -53,6 +53,7 @@ const FormFieldRepeaterCriteria = ({
|
||||
if (i === index) {
|
||||
o.value = targetedOption.value;
|
||||
o.score = targetedOption.score;
|
||||
o.id = targetedOption.id;
|
||||
}
|
||||
return o;
|
||||
});
|
||||
@@ -91,7 +92,7 @@ const FormFieldRepeaterCriteria = ({
|
||||
|
||||
useEffect(() => {
|
||||
const storeFieldData = data[fieldName] ?? [];
|
||||
const newData = storeFieldData.map(o => ({ ...o, status: o.id ? 'existing' : 'new' }))
|
||||
const newData = storeFieldData.map(o => ({ ...o, status: o.id ? 'existing' : 'new' }));
|
||||
setStateFieldData(newData);
|
||||
setThreshold(data['threshold'])
|
||||
register(fieldName, config)
|
||||
|
||||
@@ -40,17 +40,6 @@ const FormFieldRepeaterFaq = ({
|
||||
setStateFieldData([...stateFieldData, chosen]);
|
||||
}
|
||||
|
||||
const onInputChange = (e, index) => {
|
||||
const { value } = e.target;
|
||||
const newData = stateFieldData.map((o, i) => {
|
||||
if (i === index) {
|
||||
o.value = value;
|
||||
}
|
||||
return o;
|
||||
})
|
||||
setStateFieldData(newData);
|
||||
}
|
||||
|
||||
const addNewItem = () => {
|
||||
const newItem = { id: 0, status: 'new', question: '', answer: '', visible: true };
|
||||
setStateFieldData([...stateFieldData, newItem]);
|
||||
|
||||
@@ -8,7 +8,7 @@ const UnsavedChangesDetector = ({ initialData, getValuesFn }) => {
|
||||
const [initial] = useState(initialData);
|
||||
|
||||
const warnIfUnsavedChanges = useCallback((event) => {
|
||||
const updatedData = getValuesFn()
|
||||
const updatedData = getValuesFn();
|
||||
const isEqual = equal(initial, updatedData);
|
||||
|
||||
if (!isEqual) {
|
||||
|
||||
Reference in New Issue
Block a user