Commit 78b76b2e by jaymehta

images

1 parent 5bfb95cc
......@@ -92,6 +92,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
contactPersonForBooking:
ctx.request.body.data.contactPersonForBooking,
approved: ctx.request.body.data.approved,
imagesComponent: ctx.request.body.data.imagesArrayComponent,
...ctx.request.body.data.daysBoolean,
},
}
......@@ -203,6 +204,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
contactPersonForBooking:
ctx.request.body.data.contactPersonForBooking,
approved: ctx.request.body.data.approved,
imagesComponent: ctx.request.body.data.imagesArrayComponent,
...ctx.request.body.data.daysBoolean,
},
});
......@@ -252,4 +254,44 @@ module.exports = createCoreController("api::experience.experience", () => ({
},
});
},
async updateImage(ctx) {
console.log(ctx.request.body);
const id = ctx.request.body.id; // Get the ID of the experience entry
if (!id) {
return ctx.notFound("Please mention experience ID");
}
if (!ctx.request.body.newComponentData > 0) {
return ctx.notFound("Please mention the URLs");
}
const newComponentData = ctx.request.body.newComponentData; // Get the new data for the repeatable component
try {
const existingExperience = await strapi.entityService.findOne(
"api::experience.experience",
id
);
if (!existingExperience) {
return ctx.notFound("Experience with the given ID not found.");
}
// Clear the existing repeatable component data
await strapi.entityService.update("api::experience.experience", id, {
data: { imagesComponent: [] },
});
// Update the entry with new data
const updatedExperience = await strapi.entityService.update(
"api::experience.experience",
id,
{
data: { imagesComponent: newComponentData },
}
);
return ctx.send(updatedExperience);
} catch (error) {
ctx.throw(500, error);
}
},
}));
const routes = {
routes: [
{
method: "POST",
path: "/experience/update-images",
handler: "api::experience.experience.updateImage",
config: {
//some Configuration
},
}
],
};
module.exports = routes;
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!