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 c3743ad4
authored
2024-04-23 15:57:31 +0530
by
Ravindra Kanojiya
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'master' of
https://git.logicloop.io/jaymehta/zango-strapi
2 parents
02b5ee04
0a2a9619
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
60 deletions
src/api/experience/content-types/experience/schema.json
src/api/experience/controllers/experience.js
src/api/time-slot/content-types/time-slot/schema.json
src/api/experience/content-types/experience/schema.json
View file @
c3743ad
...
@@ -72,12 +72,6 @@
...
@@ -72,12 +72,6 @@
"target"
:
"api::course-detail.course-detail"
,
"target"
:
"api::course-detail.course-detail"
,
"inversedBy"
:
"experience"
"inversedBy"
:
"experience"
},
},
"timeSlots"
:
{
"type"
:
"relation"
,
"relation"
:
"oneToMany"
,
"target"
:
"api::time-slot.time-slot"
,
"mappedBy"
:
"experience"
},
"masterMonths"
:
{
"masterMonths"
:
{
"type"
:
"relation"
,
"type"
:
"relation"
,
"relation"
:
"oneToMany"
,
"relation"
:
"oneToMany"
,
...
@@ -99,6 +93,39 @@
...
@@ -99,6 +93,39 @@
"giftSomeone"
:
{
"giftSomeone"
:
{
"type"
:
"boolean"
"type"
:
"boolean"
},
},
"availableOnMonday"
:
{
"type"
:
"boolean"
},
"availableOnTuesday"
:
{
"type"
:
"boolean"
},
"availableOnWednesday"
:
{
"type"
:
"boolean"
},
"availableOnThursday"
:
{
"type"
:
"boolean"
},
"availableOnFriday"
:
{
"type"
:
"boolean"
},
"availableOnSaturday"
:
{
"type"
:
"boolean"
},
"availableOnSunday"
:
{
"type"
:
"boolean"
},
"fromTime"
:
{
"type"
:
"time"
},
"toTime"
:
{
"type"
:
"time"
},
"fromDate"
:
{
"type"
:
"date"
},
"toDate"
:
{
"type"
:
"date"
},
"image"
:
{
"image"
:
{
"type"
:
"media"
,
"type"
:
"media"
,
"multiple"
:
false
,
"multiple"
:
false
,
...
@@ -110,8 +137,14 @@
...
@@ -110,8 +137,14 @@
"rating"
:
{
"rating"
:
{
"type"
:
"decimal"
"type"
:
"decimal"
},
},
"off"
:
{
"off
ers
"
:
{
"type"
:
"integer"
"type"
:
"integer"
},
"contactPersonForActivity"
:
{
"type"
:
"string"
},
"contactPersonForBooking"
:
{
"type"
:
"string"
}
}
}
}
}
}
src/api/experience/controllers/experience.js
View file @
c3743ad
...
@@ -19,31 +19,33 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -19,31 +19,33 @@ module.exports = createCoreController("api::experience.experience", () => ({
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"
);
}
}
const
months
=
ctx
.
request
.
body
.
data
.
months
;
//
const months = ctx.request.body.data.months;
if
(
!
months
||
!
months
.
length
>
0
)
{
//
if (!months || !months.length > 0) {
throw
new
ValidationError
(
"Months is a required field."
);
//
throw new ValidationError("Months is a required field.");
}
//
}
let
monthsIds
=
[];
//
let monthsIds = [];
for
(
let
index
=
0
;
index
<
months
.
length
;
index
++
)
{
//
for (let index = 0; index < months.length; index++) {
const
element
=
months
[
index
];
//
const element = months[index];
const
singleMonth
=
await
strapi
//
const singleMonth = await strapi
.
query
(
"api::master-month.master-month"
)
//
.query("api::master-month.master-month")
.
findOne
({
//
.findOne({
where
:
{
//
where: {
name
:
element
.
value
,
//
name: element.value,
},
//
},
});
//
});
// console.log("singleMonth", singleMonth);
//
// console.log("singleMonth", singleMonth);
monthsIds
=
[...
monthsIds
,
singleMonth
.
id
]
// monthsIds = [...monthsIds, singleMonth.id];
}
//
}
const
subCategory
=
await
strapi
.
query
(
"api::sub-categorie.sub-categorie"
).
findOne
({
const
subCategory
=
await
strapi
where
:
{
.
query
(
"api::sub-categorie.sub-categorie"
)
name
:
{
.
findOne
({
$eq
:
ctx
.
request
.
body
.
data
.
subCategory
where
:
{
}
name
:
{
}
$eq
:
ctx
.
request
.
body
.
data
.
subCategory
,
})
},
},
});
const
repeatedActivities
=
await
strapi
const
repeatedActivities
=
await
strapi
.
query
(
"api::experience.experience"
)
.
query
(
"api::experience.experience"
)
...
@@ -73,6 +75,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -73,6 +75,7 @@ module.exports = createCoreController("api::experience.experience", () => ({
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
,
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
,
...
@@ -83,40 +86,52 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -83,40 +86,52 @@ module.exports = createCoreController("api::experience.experience", () => ({
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
,
masterMonths
:
monthsIds
,
// masterMonths: monthsIds,
giftSomeone
:
ctx
.
request
.
body
.
data
.
giftSomeone
giftSomeone
:
ctx
.
request
.
body
.
data
.
giftSomeone
,
fromDate
:
ctx
.
request
.
body
.
data
.
fromDate
,
toDate
:
ctx
.
request
.
body
.
data
.
toDate
,
fromTime
:
ctx
.
request
.
body
.
data
.
fromTime
,
toTime
:
ctx
.
request
.
body
.
data
.
toTime
,
offers
:
ctx
.
request
.
body
.
data
.
offers
,
rating
:
ctx
.
request
.
body
.
data
.
rating
,
contactPersonForActivity
:
ctx
.
request
.
body
.
data
.
contactPersonForActivity
,
contactPersonForBooking
:
ctx
.
request
.
body
.
data
.
contactPersonForBooking
,
...
ctx
.
request
.
body
.
data
.
daysBoolean
,
},
},
}
}
);
);
// [{day: "monday", fromTime: "10:20:00", toTime: "18:30:00"}, {day: "tuesday", fromTime: "09:30:00", toTime: "20:00:00"}]
// [{day: "monday", fromTime: "10:20:00", toTime: "18:30:00"}, {day: "tuesday", fromTime: "09:30:00", toTime: "20:00:00"}]
const
timeSlotsArray
=
ctx
.
request
.
body
.
data
.
timeSlots
;
//
const timeSlotsArray = ctx.request.body.data.timeSlots;
if
(
!
timeSlotsArray
||
!
timeSlotsArray
.
length
>
0
)
{
//
if (!timeSlotsArray || !timeSlotsArray.length > 0) {
throw
new
ValidationError
(
"No time slots given."
);
//
throw new ValidationError("No time slots given.");
}
//
}
let
timeSlotIds
=
[];
//
let timeSlotIds = [];
for
(
let
index
=
0
;
index
<
timeSlotsArray
.
length
;
index
++
)
{
//
for (let index = 0; index < timeSlotsArray.length; index++) {
const
element
=
timeSlotsArray
[
index
];
//
const element = timeSlotsArray[index];
const
timeSlotEntry
=
await
strapi
.
entityService
.
create
(
//
const timeSlotEntry = await strapi.entityService.create(
"api::time-slot.time-slot"
,
//
"api::time-slot.time-slot",
{
//
{
data
:
{
//
data: {
masterDay
:
element
.
day
.
id
,
//
masterDay: element.day.id,
start
:
element
.
fromTime
,
//
start: element.fromTime,
end
:
element
.
toTime
,
//
end: element.toTime,
experience
:
activity
.
id
,
//
experience: activity.id,
},
//
},
}
//
}
);
//
);
timeSlotIds
=
[...
timeSlotIds
,
timeSlotEntry
];
//
timeSlotIds = [...timeSlotIds, timeSlotEntry];
}
//
}
ctx
.
send
({
ctx
.
send
({
success
:
true
,
success
:
true
,
message
:
"Activity Created"
,
message
:
"Activity Created"
,
data
:
{
...
activity
,
timeSlots
:
{
...
timeSlotIds
}
},
data
:
{
...
activity
,
// timeSlots: { ...timeSlotIds }
},
});
});
},
},
}));
}));
src/api/time-slot/content-types/time-slot/schema.json
View file @
c3743ad
...
@@ -22,12 +22,6 @@
...
@@ -22,12 +22,6 @@
"type"
:
"relation"
,
"type"
:
"relation"
,
"relation"
:
"oneToOne"
,
"relation"
:
"oneToOne"
,
"target"
:
"api::master-day.master-day"
"target"
:
"api::master-day.master-day"
},
"experience"
:
{
"type"
:
"relation"
,
"relation"
:
"manyToOne"
,
"target"
:
"api::experience.experience"
,
"inversedBy"
:
"timeSlots"
}
}
}
}
}
}
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