mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +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 { retrieveComponentsThatHaveComponents } from './utils/retrieveComponentsThatHaveComponents';
|
||||
import makeUnique from '../../utils/makeUnique';
|
||||
import { getComponentsToPost, formatContentType } from './utils/cleanData';
|
||||
|
||||
const DataManagerProvider = ({ allIcons, children }) => {
|
||||
const [reducerState, dispatch] = useReducer(reducer, initialState, init);
|
||||
@ -238,6 +239,35 @@ const DataManagerProvider = ({ allIcons, children }) => {
|
||||
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) => {
|
||||
dispatch({
|
||||
type: 'UPDATE_SCHEMA',
|
||||
@ -276,6 +306,7 @@ const DataManagerProvider = ({ allIcons, children }) => {
|
||||
removeComponentFromDynamicZone,
|
||||
setModifiedData,
|
||||
sortedContentTypesList,
|
||||
submitData,
|
||||
updateSchema,
|
||||
}}
|
||||
>
|
||||
|
@ -36,6 +36,7 @@ const ListPage = () => {
|
||||
isInContentTypeView,
|
||||
// removeAttribute,
|
||||
// removeComponentFromDynamicZone,
|
||||
submitData,
|
||||
} = useDataManager();
|
||||
const { formatMessage } = useGlobalContext();
|
||||
const { push } = useHistory();
|
||||
@ -207,7 +208,7 @@ const ListPage = () => {
|
||||
},
|
||||
{
|
||||
color: 'success',
|
||||
onClick: () => {},
|
||||
onClick: () => submitData(),
|
||||
title: formatMessage({
|
||||
id: `${pluginId}.form.button.save`,
|
||||
}),
|
||||
|
Loading…
x
Reference in New Issue
Block a user