mirror of
https://github.com/strapi/strapi.git
synced 2025-09-27 01:09:49 +00:00
Handle submit content type
This commit is contained in:
parent
7fb450ebfd
commit
adb4330811
@ -17,6 +17,7 @@ import retrieveComponentsFromSchema from './utils/retrieveComponentsFromSchema';
|
|||||||
import retrieveNestedComponents from './utils/retrieveNestedComponents';
|
import retrieveNestedComponents from './utils/retrieveNestedComponents';
|
||||||
import { retrieveComponentsThatHaveComponents } from './utils/retrieveComponentsThatHaveComponents';
|
import { retrieveComponentsThatHaveComponents } from './utils/retrieveComponentsThatHaveComponents';
|
||||||
import makeUnique from '../../utils/makeUnique';
|
import makeUnique from '../../utils/makeUnique';
|
||||||
|
import { getComponentsToPost, formatContentType } from './utils/cleanData';
|
||||||
|
|
||||||
const DataManagerProvider = ({ allIcons, children }) => {
|
const DataManagerProvider = ({ allIcons, children }) => {
|
||||||
const [reducerState, dispatch] = useReducer(reducer, initialState, init);
|
const [reducerState, dispatch] = useReducer(reducer, initialState, init);
|
||||||
@ -238,6 +239,35 @@ const DataManagerProvider = ({ allIcons, children }) => {
|
|||||||
return makeUnique(composWithCompos);
|
return makeUnique(composWithCompos);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const submitData = async () => {
|
||||||
|
console.log('will submit', currentUid);
|
||||||
|
try {
|
||||||
|
// const mainDataUID =
|
||||||
|
// Temporary works only for creating ct
|
||||||
|
const body = {
|
||||||
|
components: getComponentsToPost(
|
||||||
|
modifiedData.components,
|
||||||
|
components,
|
||||||
|
currentUid,
|
||||||
|
true
|
||||||
|
),
|
||||||
|
contentType: formatContentType(modifiedData.contentType),
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await request(
|
||||||
|
`/${pluginId}/content-types`,
|
||||||
|
{ method: 'POST', body },
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log({ response });
|
||||||
|
|
||||||
|
console.log({ body });
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const updateSchema = (data, schemaType) => {
|
const updateSchema = (data, schemaType) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'UPDATE_SCHEMA',
|
type: 'UPDATE_SCHEMA',
|
||||||
@ -276,6 +306,7 @@ const DataManagerProvider = ({ allIcons, children }) => {
|
|||||||
removeComponentFromDynamicZone,
|
removeComponentFromDynamicZone,
|
||||||
setModifiedData,
|
setModifiedData,
|
||||||
sortedContentTypesList,
|
sortedContentTypesList,
|
||||||
|
submitData,
|
||||||
updateSchema,
|
updateSchema,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -36,6 +36,7 @@ const ListPage = () => {
|
|||||||
isInContentTypeView,
|
isInContentTypeView,
|
||||||
// removeAttribute,
|
// removeAttribute,
|
||||||
// removeComponentFromDynamicZone,
|
// removeComponentFromDynamicZone,
|
||||||
|
submitData,
|
||||||
} = useDataManager();
|
} = useDataManager();
|
||||||
const { formatMessage } = useGlobalContext();
|
const { formatMessage } = useGlobalContext();
|
||||||
const { push } = useHistory();
|
const { push } = useHistory();
|
||||||
@ -207,7 +208,7 @@ const ListPage = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
color: 'success',
|
color: 'success',
|
||||||
onClick: () => {},
|
onClick: () => submitData(),
|
||||||
title: formatMessage({
|
title: formatMessage({
|
||||||
id: `${pluginId}.form.button.save`,
|
id: `${pluginId}.form.button.save`,
|
||||||
}),
|
}),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user