Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(response => {
const options = isArray(response)
? map(response, item => ({
value: item,
label: templateObject(
{ mainField: this.props.relation.displayedAttribute },
item,
).mainField,
}))
: [
{
value: response,
label: templateObject(
{ mainField: this.props.relation.displayedAttribute },
response,
).mainField,
},
];
const newOptions = cloneDeep(this.state.options);
options.map(option => {
// Don't add the values when searching
if (
findIndex(newOptions, o => o.value.id === option.value.id) === -1
) {
return newOptions.push(option);
}
});
strapi.notification.success(`${pluginId}.success.record.delete`);
redirectToPreviousPage();
} catch (err) {
setIsSubmitting(false);
strapi.notification.error(`${pluginId}.error.record.delete`);
}
};
const displayedFieldNameInHeader = get(
layout,
['settings', 'mainField'],
'id'
);
const pluginHeaderTitle = isCreatingEntry
? { id: `${pluginId}.containers.Edit.pluginHeader.title.new` }
: templateObject({ mainField: displayedFieldNameInHeader }, initialData)
.mainField;
const displayedRelations = get(layout, ['layouts', 'editRelations'], []);
const hasRelations = displayedRelations.length > 0;
const fields = get(layout, ['layouts', 'edit'], []);
const checkFormErrors = async () => {
const schema = createYupSchema(layout, { groups: groupLayoutsData });
let errors = {};
try {
// Validate the form using yup
await schema.validate(modifiedData, { abortEarly: false });
} catch (err) {
errors = get(err, 'inner', []).reduce((acc, curr) => {
acc[
curr.path
strapi.notification.success(`${pluginId}.success.record.delete`);
redirectToPreviousPage();
} catch (err) {
setIsSubmitting(false);
strapi.notification.error(`${pluginId}.error.record.delete`);
}
};
const displayedFieldNameInHeader = get(
layout,
['settings', 'mainField'],
'id'
);
const pluginHeaderTitle = isCreatingEntry
? { id: `${pluginId}.containers.Edit.pluginHeader.title.new` }
: templateObject({ mainField: displayedFieldNameInHeader }, initialData)
.mainField;
const displayedRelations = get(layout, ['layouts', 'editRelations'], []);
const hasRelations = displayedRelations.length > 0;
const fields = get(layout, ['layouts', 'edit'], []);
const checkFormErrors = async () => {
const schema = createYupSchema(layout, { groups: groupLayoutsData });
let errors = {};
try {
// Validate the form using yup
await schema.validate(modifiedData, { abortEarly: false });
} catch (err) {
errors = getYupInnerErrors(err);
}
<select value="{" id="{this.props.relation.alias}">
);
}
}</select>
setIsSubmitting,
slug,
} = useDataManager();
const currentContentTypeMainField = get(
layout,
['settings', 'mainField'],
'id'
);
const isCreatingEntry = id === 'create';
const headerTitle = isCreatingEntry
? formatMessage({
id: `${pluginId}.containers.Edit.pluginHeader.title.new`,
})
: templateObject({ mainField: currentContentTypeMainField }, initialData)
.mainField;
const getHeaderActions = () => {
const headerActions = [
{
onClick: () => {
toggleWarningCancel();
},
color: 'cancel',
title: formatMessage({
id: `${pluginId}.containers.Edit.reset`,
}),
type: 'button',
style: {
paddingLeft: 15,
paddingRight: 15,
? map(response, item => ({
value: item,
label: templateObject(
{ mainField: this.props.relation.displayedAttribute },
item,
).mainField,
}))
: [