Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions admin/src/components/Action/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,27 @@ const Action = ({ mode, documentId, entitySlug }) => {
const handleOnSave = async () => {
setIsLoading(true);
// Create of update actie
if (!actionId) {
const { data: response } = await createAction({
mode,
entityId: documentId,
entitySlug,
executeAt,
});
if (response.data && response.data.id) {
setActionId(response.data.documentId);
try {
if (!actionId) {
const { data: response } = await createAction({
mode,
entityId: documentId,
entitySlug,
executeAt,
});
if (response.data && response.data.id) {
setActionId(response.data.documentId);
}
} else {
await updateAction({ id: actionId, body: { executeAt } });
}
} else {
await updateAction({ id: actionId, body: { executeAt } });
setIsCreating(false);
setIsEditing(true);
setIsLoading(false);
} catch (error) {
setIsLoading(false);
console.error('Error saving action:', error);
}

setIsCreating(false);
setIsEditing(true);
setIsLoading(false);
};

const handleOnDelete = async () => {
Expand Down
2 changes: 2 additions & 0 deletions server/middlewares/validate-before-scheduling.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const validationMiddleware = async (context, next) => {
const draft = await strapi.documents(entitySlug).findOne({
documentId: entityId,
status: 'draft',
populate: '*',
});

// Throw an error if there is no document with the given documentId.
Expand All @@ -45,6 +46,7 @@ const validationMiddleware = async (context, next) => {
const published = await strapi.documents(entitySlug).findOne({
documentId: entityId,
status: 'published',
populate: '*',
});

// Run the validations.
Expand Down