Commit a455c312 by jaymehta

.

1 parent 0574f7ae
...@@ -83,13 +83,26 @@ module.exports = createCoreController("api::vendor.vendor", () => ({ ...@@ -83,13 +83,26 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
console.log("should be here"); console.log("should be here");
} else { } else {
console.log("but is here"); console.log("but is here");
let final;
let str = ctx.request.body.data.name
// console.log()
let newStr = str.replace(/ /g,'').toUpperCase().replace(/[^a-zA-Z ]/g, "")
if (newStr.length >= 4) {
final = newStr.slice(0, 4);
console.log(final+String(Math.floor(Math.random() * 90000) + 10000))
} else {
final = newStr
console.log(final+String(Math.floor(Math.random() * 90000) + 10000))
}
ctx.request.body.data.user = currentUser.id; ctx.request.body.data.user = currentUser.id;
const response = await strapi.entityService.create("api::vendor.vendor", { const response = await strapi.entityService.create("api::vendor.vendor", {
data: { data: {
...ctx.request.body.data, ...ctx.request.body.data,
phone: ctx.request.body.data.mobileNo, phone: ctx.request.body.data.mobileNo,
publishedAt: date, publishedAt: date,
uniqueVendorId: str
}, },
}); });
console.log("response", response); console.log("response", response);
...@@ -230,7 +243,7 @@ module.exports = createCoreController("api::vendor.vendor", () => ({ ...@@ -230,7 +243,7 @@ module.exports = createCoreController("api::vendor.vendor", () => ({
async addVendorId(ctx) { async addVendorId(ctx) {
try { try {
// console.log(ctx.request.body) // console.log(ctx.request.body)
} catch (error) { } catch (error) {
} }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!