mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 03:07:32 +00:00
EditView: Display notification when a stage change was successful
This commit is contained in:
parent
25bdf083b2
commit
23abbc63d8
@ -4,6 +4,7 @@ import {
|
|||||||
useCMEditViewDataManager,
|
useCMEditViewDataManager,
|
||||||
useAPIErrorHandler,
|
useAPIErrorHandler,
|
||||||
useFetchClient,
|
useFetchClient,
|
||||||
|
useNotification,
|
||||||
} from '@strapi/helper-plugin';
|
} from '@strapi/helper-plugin';
|
||||||
import { Field, FieldLabel, FieldError, Flex } from '@strapi/design-system';
|
import { Field, FieldLabel, FieldError, Flex } from '@strapi/design-system';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
@ -24,18 +25,29 @@ export function InformationBoxEE() {
|
|||||||
const activeWorkflowStage = initialData?.[ATTRIBUTE_NAME] ?? null;
|
const activeWorkflowStage = initialData?.[ATTRIBUTE_NAME] ?? null;
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const { formatAPIError } = useAPIErrorHandler();
|
const { formatAPIError } = useAPIErrorHandler();
|
||||||
|
const toggleNotification = useNotification();
|
||||||
|
|
||||||
const { workflows: { data: [workflow] = [] } = {} } = useReviewWorkflows();
|
const { workflows: { data: [workflow] = [] } = {} } = useReviewWorkflows();
|
||||||
|
|
||||||
const { error, isLoading, mutateAsync } = useMutation(async ({ entityId, stageId, uid }) => {
|
const { error, isLoading, mutateAsync } = useMutation(
|
||||||
const {
|
async ({ entityId, stageId, uid }) => {
|
||||||
data: { data },
|
const {
|
||||||
} = await put(`/admin/content-manager/collection-types/${uid}/${entityId}/stage`, {
|
data: { data },
|
||||||
data: { id: stageId },
|
} = await put(`/admin/content-manager/collection-types/${uid}/${entityId}/stage`, {
|
||||||
});
|
data: { id: stageId },
|
||||||
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
onSuccess() {
|
||||||
|
toggleNotification({
|
||||||
|
type: 'success',
|
||||||
|
message: { id: 'notification.success.saved', defaultMessage: 'Saved' },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// stages are empty while the workflow is loading
|
// stages are empty while the workflow is loading
|
||||||
const options = (workflow?.stages ?? []).map(({ id, name }) => ({ value: id, label: name }));
|
const options = (workflow?.stages ?? []).map(({ id, name }) => ({ value: id, label: name }));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user