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 bc6ae555
authored
11 months ago
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
.
1 parent
0223f390
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
123 deletions
src/api/experience/content-types/experience/schema.json
src/api/experience/controllers/experience.js
src/api/experience/content-types/experience/schema.json
View file @
bc6ae55
...
@@ -129,10 +129,6 @@
...
@@ -129,10 +129,6 @@
"target"
:
"api::categorie.categorie"
,
"target"
:
"api::categorie.categorie"
,
"inversedBy"
:
"experiences"
"inversedBy"
:
"experiences"
},
},
"approved"
:
{
"type"
:
"boolean"
,
"default"
:
false
},
"rejectionReason"
:
{
"rejectionReason"
:
{
"type"
:
"string"
,
"type"
:
"string"
,
"default"
:
"Yet to approve"
"default"
:
"Yet to approve"
...
@@ -160,6 +156,14 @@
...
@@ -160,6 +156,14 @@
"relation"
:
"manyToOne"
,
"relation"
:
"manyToOne"
,
"target"
:
"api::sub-categorie.sub-categorie"
,
"target"
:
"api::sub-categorie.sub-categorie"
,
"inversedBy"
:
"experience"
"inversedBy"
:
"experience"
},
"approved"
:
{
"type"
:
"enumeration"
,
"enum"
:
[
"approved"
,
"rejected"
,
"pending"
]
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/api/experience/controllers/experience.js
View file @
bc6ae55
...
@@ -105,125 +105,125 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -105,125 +105,125 @@ module.exports = createCoreController("api::experience.experience", () => ({
});
});
},
},
//
async update(ctx) {
async
update
(
ctx
)
{
//
// if (!ctx.request.body.data.vendor) {
// if (!ctx.request.body.data.vendor) {
//
// throw new ValidationError("Vendor is a mandatory field.");
// throw new ValidationError("Vendor is a mandatory field.");
//
// }
// }
//
console.log("ctx>", ctx.request.body);
console
.
log
(
"ctx>"
,
ctx
.
request
.
body
);
//
if (!ctx.request.body.data.pincode) {
if
(
!
ctx
.
request
.
body
.
data
.
pincode
)
{
//
throw new ValidationError("Pincode is a mandatory field.");
throw
new
ValidationError
(
"Pincode is a mandatory field."
);
//
}
}
//
if (!ctx.request.body.data.subCategory) {
if
(
!
ctx
.
request
.
body
.
data
.
subCategory
)
{
//
throw new ValidationError("Subcategory is a mandatory field");
throw
new
ValidationError
(
"Subcategory is a mandatory field"
);
//
}
}
//
if (!ctx.request.body.data.category) {
if
(
!
ctx
.
request
.
body
.
data
.
category
)
{
//
throw new ValidationError("Category is a mandatory field");
throw
new
ValidationError
(
"Category is a mandatory field"
);
//
}
}
//
console.log("subcategoyr", ctx.params);
console
.
log
(
"subcategoyr"
,
ctx
.
params
);
//
const { id } = ctx.params;
const
{
id
}
=
ctx
.
params
;
//
const subCategory = await strapi
const
subCategory
=
await
strapi
//
.query("api::sub-categorie.sub-categorie")
.
query
(
"api::sub-categorie.sub-categorie"
)
//
.findOne({
.
findOne
({
//
where: {
where
:
{
//
name: {
name
:
{
//
$eq: ctx.request.body.data.subCategory,
$eq
:
ctx
.
request
.
body
.
data
.
subCategory
,
//
},
},
//
},
},
//
});
});
//
const category = await strapi.query("api::categorie.categorie").findOne({
const
category
=
await
strapi
.
query
(
"api::categorie.categorie"
).
findOne
({
//
where: {
where
:
{
//
name: {
name
:
{
//
$eq: ctx.request.body.data.category,
$eq
:
ctx
.
request
.
body
.
data
.
category
,
//
},
},
//
},
},
//
});
});
//
console.log(
console
.
log
(
//
"ctx.request.body.data.activityId",
"ctx.request.body.data.activityId"
,
//
ctx.request.body.data.activityId
ctx
.
request
.
body
.
data
.
activityId
//
);
);
//
const updatedExperience = await strapi
const
updatedExperience
=
await
strapi
//
.query("api::experience.experience")
.
query
(
"api::experience.experience"
)
//
.update(
.
update
(
//
{ id },
{
id
},
//
{
{
//
name: ctx.request.body.data.name,
name
:
ctx
.
request
.
body
.
data
.
name
,
//
description: ctx.request.body.data.description,
description
:
ctx
.
request
.
body
.
data
.
description
,
//
pricePerPerson: ctx.request.body.data.pricePerPerson,
pricePerPerson
:
ctx
.
request
.
body
.
data
.
pricePerPerson
,
//
address: ctx.request.body.data.address,
address
:
ctx
.
request
.
body
.
data
.
address
,
//
masterPincode: ctx.request.body.data.pincode.id,
masterPincode
:
ctx
.
request
.
body
.
data
.
pincode
.
id
,
//
minimumDuration: ctx.request.body.data.minimumDuration,
minimumDuration
:
ctx
.
request
.
body
.
data
.
minimumDuration
,
//
maximumDuration: ctx.request.body.data.maximumDuration,
maximumDuration
:
ctx
.
request
.
body
.
data
.
maximumDuration
,
//
duration: ctx.request.body.data.duration,
duration
:
ctx
.
request
.
body
.
data
.
duration
,
//
ageLowerLimit: ctx.request.body.data.ageLowerLimit,
ageLowerLimit
:
ctx
.
request
.
body
.
data
.
ageLowerLimit
,
//
ageNotes: ctx.request.body.data.ageNotes,
ageNotes
:
ctx
.
request
.
body
.
data
.
ageNotes
,
//
phoneNumber: ctx.request.body.data.phoneNumber,
phoneNumber
:
ctx
.
request
.
body
.
data
.
phoneNumber
,
//
minGroupSize: ctx.request.body.data.minGroupSize,
minGroupSize
:
ctx
.
request
.
body
.
data
.
minGroupSize
,
//
maxGroupSize: ctx.request.body.data.maxGroupSize,
maxGroupSize
:
ctx
.
request
.
body
.
data
.
maxGroupSize
,
//
activityType: ctx.request.body.data.activityType,
activityType
:
ctx
.
request
.
body
.
data
.
activityType
,
//
link: ctx.request.body.data.link,
link
:
ctx
.
request
.
body
.
data
.
link
,
//
cancellationPolicy: ctx.request.body.data.cancellationPolicy,
cancellationPolicy
:
ctx
.
request
.
body
.
data
.
cancellationPolicy
,
//
// vendor: ctx.request.body.data.vendor.id,
// vendor: ctx.request.body.data.vendor.id,
//
subCategory: subCategory.id,
subCategory
:
subCategory
.
id
,
//
category: category.id,
category
:
category
.
id
,
//
giftSomeone: ctx.request.body.data.giftSomeone,
giftSomeone
:
ctx
.
request
.
body
.
data
.
giftSomeone
,
//
fromDate: ctx.request.body.data.fromDate,
fromDate
:
ctx
.
request
.
body
.
data
.
fromDate
,
//
toDate: ctx.request.body.data.toDate,
toDate
:
ctx
.
request
.
body
.
data
.
toDate
,
//
fromTime: ctx.request.body.data.fromTime,
fromTime
:
ctx
.
request
.
body
.
data
.
fromTime
,
//
toTime: ctx.request.body.data.toTime,
toTime
:
ctx
.
request
.
body
.
data
.
toTime
,
//
offers: ctx.request.body.data.offers,
offers
:
ctx
.
request
.
body
.
data
.
offers
,
//
rating: ctx.request.body.data.rating,
rating
:
ctx
.
request
.
body
.
data
.
rating
,
//
contactPersonForActivity:
contactPersonForActivity
:
//
ctx.request.body.data.contactPersonForActivity,
ctx
.
request
.
body
.
data
.
contactPersonForActivity
,
//
contactPersonForBooking:
contactPersonForBooking
:
//
ctx.request.body.data.contactPersonForBooking,
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
//
...ctx.request.body.data.daysBoolean,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
//
}
}
//
);
);
//
// const activity = await strapi.entityService.update(
// const activity = await strapi.entityService.update(
//
// "api::experience.experience",
// "api::experience.experience",
//
// { id: ctx.request.body.data.activityId },
// { id: ctx.request.body.data.activityId },
//
// {
// {
//
// name: ctx.request.body.data.name,
// name: ctx.request.body.data.name,
//
// description: ctx.request.body.data.description,
// description: ctx.request.body.data.description,
//
// pricePerPerson: ctx.request.body.data.pricePerPerson,
// pricePerPerson: ctx.request.body.data.pricePerPerson,
//
// address: ctx.request.body.data.address,
// address: ctx.request.body.data.address,
//
// masterPincode: ctx.request.body.data.pincode.id,
// masterPincode: ctx.request.body.data.pincode.id,
//
// minimumDuration: ctx.request.body.data.minimumDuration,
// minimumDuration: ctx.request.body.data.minimumDuration,
//
// maximumDuration: ctx.request.body.data.maximumDuration,
// maximumDuration: ctx.request.body.data.maximumDuration,
//
// duration: ctx.request.body.data.duration,
// duration: ctx.request.body.data.duration,
//
// ageLowerLimit: ctx.request.body.data.ageLowerLimit,
// ageLowerLimit: ctx.request.body.data.ageLowerLimit,
//
// ageNotes: ctx.request.body.data.ageNotes,
// ageNotes: ctx.request.body.data.ageNotes,
//
// phoneNumber: ctx.request.body.data.phoneNumber,
// phoneNumber: ctx.request.body.data.phoneNumber,
//
// minGroupSize: ctx.request.body.data.minGroupSize,
// minGroupSize: ctx.request.body.data.minGroupSize,
//
// maxGroupSize: ctx.request.body.data.maxGroupSize,
// maxGroupSize: ctx.request.body.data.maxGroupSize,
//
// activityType: ctx.request.body.data.activityType,
// activityType: ctx.request.body.data.activityType,
//
// link: ctx.request.body.data.link,
// link: ctx.request.body.data.link,
//
// cancellationPolicy: ctx.request.body.data.cancellationPolicy,
// cancellationPolicy: ctx.request.body.data.cancellationPolicy,
//
// // vendor: ctx.request.body.data.vendor.id,
// // vendor: ctx.request.body.data.vendor.id,
//
// subCategory: subCategory.id,
// subCategory: subCategory.id,
//
// category: category.id,
// category: category.id,
//
// giftSomeone: ctx.request.body.data.giftSomeone,
// giftSomeone: ctx.request.body.data.giftSomeone,
//
// fromDate: ctx.request.body.data.fromDate,
// fromDate: ctx.request.body.data.fromDate,
//
// toDate: ctx.request.body.data.toDate,
// toDate: ctx.request.body.data.toDate,
//
// fromTime: ctx.request.body.data.fromTime,
// fromTime: ctx.request.body.data.fromTime,
//
// toTime: ctx.request.body.data.toTime,
// toTime: ctx.request.body.data.toTime,
//
// offers: ctx.request.body.data.offers,
// offers: ctx.request.body.data.offers,
//
// rating: ctx.request.body.data.rating,
// rating: ctx.request.body.data.rating,
//
// contactPersonForActivity:
// contactPersonForActivity:
//
// ctx.request.body.data.contactPersonForActivity,
// ctx.request.body.data.contactPersonForActivity,
//
// contactPersonForBooking: ctx.request.body.data.contactPersonForBooking,
// contactPersonForBooking: ctx.request.body.data.contactPersonForBooking,
//
// ...ctx.request.body.data.daysBoolean,
// ...ctx.request.body.data.daysBoolean,
//
// }
// }
//
// );
// );
//
console.log("updatedExperience", updatedExperience);
console
.
log
(
"updatedExperience"
,
updatedExperience
);
//
ctx.send({
ctx
.
send
({
//
success: true,
success
:
true
,
//
message: "Activity updated",
message
:
"Activity updated"
,
//
data: {
data
:
{
//
...updatedExperience,
...
updatedExperience
,
//
},
},
//
});
});
//
},
},
}));
}));
This diff is collapsed.
Click to expand it.
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