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 19abb7f4
authored
2024-05-09 17:52:16 +0530
by
jaymehta
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
end user sign up
1 parent
9ac2ea61
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
14 deletions
src/api/course-detail/content-types/course-detail/schema.json
src/api/end-user/content-types/end-user/schema.json
src/api/end-user/controllers/end-user.js
src/api/experience/content-types/experience/schema.json
src/api/experience/controllers/experience.js
src/api/course-detail/content-types/course-detail/schema.json
View file @
19abb7f
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
"type"
:
"relation"
,
"type"
:
"relation"
,
"relation"
:
"oneToOne"
,
"relation"
:
"oneToOne"
,
"target"
:
"api::end-user.end-user"
,
"target"
:
"api::end-user.end-user"
,
"
invers
edBy"
:
"courseDetail"
"
mapp
edBy"
:
"courseDetail"
},
},
"experience"
:
{
"experience"
:
{
"type"
:
"relation"
,
"type"
:
"relation"
,
...
...
src/api/end-user/content-types/end-user/schema.json
View file @
19abb7f
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
"name"
:
{
"name"
:
{
"type"
:
"string"
"type"
:
"string"
},
},
"
number
"
:
{
"
phone
"
:
{
"type"
:
"string"
"type"
:
"string"
},
},
"age"
:
{
"age"
:
{
...
@@ -26,6 +26,9 @@
...
@@ -26,6 +26,9 @@
"relation"
:
"oneToOne"
,
"relation"
:
"oneToOne"
,
"target"
:
"api::course-detail.course-detail"
,
"target"
:
"api::course-detail.course-detail"
,
"inversedBy"
:
"endUser"
"inversedBy"
:
"endUser"
},
"email"
:
{
"type"
:
"string"
}
}
}
}
}
}
src/api/end-user/controllers/end-user.js
View file @
19abb7f
'use strict'
;
"use strict"
;
/**
/**
* end-user controller
* end-user controller
*/
*/
const
{
createCoreController
}
=
require
(
'@strapi/strapi'
).
factories
;
const
{
createCoreController
}
=
require
(
"@strapi/strapi"
).
factories
;
module
.
exports
=
createCoreController
(
'api::end-user.end-user'
);
module
.
exports
=
createCoreController
(
"api::end-user.end-user"
,
()
=>
({
async
create
(
ctx
)
{
// console.log("ctx", ctx.request.body);
// Get user from user entity
const
currentUser
=
await
strapi
.
query
(
"plugin::users-permissions.user"
)
.
findOne
({
populate
:
[
"user"
],
where
:
{
$and
:
[{
email
:
ctx
.
request
.
body
.
data
.
email
}],
},
});
// Check if its already existing in vendor entity
console
.
log
(
"currentUser"
,
currentUser
);
console
.
log
(
"phoneNumber"
,
ctx
.
request
.
body
.
data
.
mobileNo
,
ctx
.
request
.
body
.
data
.
email
);
let
existingUser
;
existingUser
=
await
strapi
.
entityService
.
findMany
(
"api::end-user.end-user"
,
{
// fields: ["id"],
filters
:
{
phone
:
{
$eq
:
ctx
.
request
.
body
.
data
.
mobileNo
}
},
});
console
.
log
(
"existingUser> 1"
,
existingUser
);
if
(
!
existingUser
)
{
existingUser
=
await
strapi
.
entityService
.
findMany
(
"api::end-user.end-user"
,
{
// fields: ["id"],
filters
:
{
email
:
{
$eq
:
ctx
.
request
.
body
.
data
.
email
}
},
});
}
console
.
log
(
"existingUser > 2"
,
existingUser
);
// Generate one time password (otp)
const
oneTimePassword
=
Math
.
floor
(
1000
+
Math
.
random
()
*
9000
);
await
strapi
.
entityService
.
update
(
"plugin::users-permissions.user"
,
currentUser
.
id
,
{
data
:
{
oneTimePassword
:
`
${
oneTimePassword
}
`
,
},
}
);
const
date
=
new
Date
();
// TODO: Code to send OTP on email
// TODO: Code to send OTP on SMS
console
.
log
(
"ctx.request.body.data"
,
ctx
.
request
.
body
.
data
);
console
.
log
(
"existingUser"
,
existingUser
);
if
(
existingUser
&&
existingUser
.
length
!==
0
)
{
}
else
{
ctx
.
request
.
body
.
data
.
user
=
currentUser
.
id
;
const
response
=
await
strapi
.
entityService
.
create
(
"api::end-user.end-user"
,
{
data
:
{
...
ctx
.
request
.
body
.
data
,
phone
:
ctx
.
request
.
body
.
data
.
mobileNo
,
publishedAt
:
date
,
},
});
console
.
log
(
"response"
,
response
);
return
{
otpSent
:
true
,
data
:
response
};
// ctx.request.body.data.user = currentUser;
// console.log("ctx.request.body.data", ctx.request.body.data);
// return await super.create(ctx);
}
ctx
.
send
({
ok
:
true
,
message
:
"Existing vendor found, skipping creation only sent OTP."
,
});
},
}));
src/api/experience/content-types/experience/schema.json
View file @
19abb7f
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
"description"
:
""
"description"
:
""
},
},
"options"
:
{
"options"
:
{
"draftAndPublish"
:
tru
e
"draftAndPublish"
:
fals
e
},
},
"pluginOptions"
:
{},
"pluginOptions"
:
{},
"attributes"
:
{
"attributes"
:
{
...
...
src/api/experience/controllers/experience.js
View file @
19abb7f
...
@@ -119,7 +119,8 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -119,7 +119,8 @@ module.exports = createCoreController("api::experience.experience", () => ({
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
.
request
.
body
.
data
.
subCategory
);
console
.
log
(
"subcategoyr"
,
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"
)
...
@@ -137,12 +138,15 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -137,12 +138,15 @@ module.exports = createCoreController("api::experience.experience", () => ({
},
},
},
},
});
});
console
.
log
(
const
activity
=
await
strapi
.
entityService
.
update
(
"ctx.request.body.data.activityId"
,
"api::experience.experience"
,
ctx
.
request
.
body
.
data
.
activityId
{
id
:
ctx
.
request
.
body
.
data
.
activityId
},
);
const
updatedExperience
=
await
strapi
.
query
(
"api::experience.experience"
)
.
update
(
{
id
},
{
{
data
:
{
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
,
...
@@ -174,15 +178,51 @@ module.exports = createCoreController("api::experience.experience", () => ({
...
@@ -174,15 +178,51 @@ module.exports = createCoreController("api::experience.experience", () => ({
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(
// "api::experience.experience",
// { id: ctx.request.body.data.activityId },
// {
// name: ctx.request.body.data.name,
// description: ctx.request.body.data.description,
// pricePerPerson: ctx.request.body.data.pricePerPerson,
// address: ctx.request.body.data.address,
// masterPincode: ctx.request.body.data.pincode.id,
// minimumDuration: ctx.request.body.data.minimumDuration,
// maximumDuration: ctx.request.body.data.maximumDuration,
// duration: ctx.request.body.data.duration,
// ageLowerLimit: ctx.request.body.data.ageLowerLimit,
// ageNotes: ctx.request.body.data.ageNotes,
// phoneNumber: ctx.request.body.data.phoneNumber,
// minGroupSize: ctx.request.body.data.minGroupSize,
// maxGroupSize: ctx.request.body.data.maxGroupSize,
// activityType: ctx.request.body.data.activityType,
// link: ctx.request.body.data.link,
// cancellationPolicy: ctx.request.body.data.cancellationPolicy,
// // vendor: ctx.request.body.data.vendor.id,
// subCategory: subCategory.id,
// category: category.id,
// 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,
// }
// );
console
.
log
(
"updatedExperience"
,
updatedExperience
);
ctx
.
send
({
ctx
.
send
({
success
:
true
,
success
:
true
,
message
:
"Activity updated"
,
message
:
"Activity updated"
,
data
:
{
data
:
{
...
activity
,
...
updatedExperience
,
},
},
});
});
},
},
...
...
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