Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Jay Mehta
/
zango-strapi
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Registry
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 78b76b2e
authored
2024-05-23 17:23:55 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
images
1 parent
5bfb95cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
0 deletions
src/api/experience/controllers/experience.js
src/api/experience/routes/custom-routes.js
src/api/experience/controllers/experience.js
View file @
78b76b2
...
@@ -92,6 +92,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -92,6 +92,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
contactPersonForBooking
:
contactPersonForBooking
:
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
approved
:
ctx
.
request
.
body
.
data
.
approved
,
approved
:
ctx
.
request
.
body
.
data
.
approved
,
imagesComponent
:
ctx
.
request
.
body
.
data
.
imagesArrayComponent
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
},
},
}
}
...
@@ -203,6 +204,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -203,6 +204,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
contactPersonForBooking
:
contactPersonForBooking
:
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
approved
:
ctx
.
request
.
body
.
data
.
approved
,
approved
:
ctx
.
request
.
body
.
data
.
approved
,
imagesComponent
:
ctx
.
request
.
body
.
data
.
imagesArrayComponent
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
},
},
});
});
...
@@ -252,4 +254,44 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -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
);
}
},
}));
}));
src/api/experience/routes/custom-routes.js
0 → 100644
View file @
78b76b2
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
\ No newline at end of file
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment