add create user and login user parts
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
// app/utils/users/createBusinessCustomer.util.js
|
||||
|
||||
const db = require("../../models");
|
||||
|
||||
const {
|
||||
generateBusinessCustomerId,
|
||||
} = require("../idGen.util");
|
||||
|
||||
const BusinessCustomer = db.BusinessCustomer;
|
||||
|
||||
|
||||
/**
|
||||
* Create business-customer-specific details
|
||||
*/
|
||||
const createBusinessCustomerDetails = async (
|
||||
userId,
|
||||
businessData,
|
||||
transaction
|
||||
) => {
|
||||
|
||||
const {
|
||||
businessName,
|
||||
businessRegistrationNumber,
|
||||
businessType,
|
||||
contactName,
|
||||
phoneNumber,
|
||||
businessEmail,
|
||||
expectedMonthlyVolume,
|
||||
note,
|
||||
} = businessData;
|
||||
|
||||
|
||||
if (
|
||||
!businessName ||
|
||||
!businessRegistrationNumber ||
|
||||
!businessType ||
|
||||
!contactName ||
|
||||
!phoneNumber ||
|
||||
!businessEmail ||
|
||||
!expectedMonthlyVolume
|
||||
) {
|
||||
throw new Error(
|
||||
"Required business customer details are missing"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const businessCustomer =
|
||||
await BusinessCustomer.create(
|
||||
{
|
||||
business_customer_id:
|
||||
generateBusinessCustomerId(),
|
||||
|
||||
user_id:
|
||||
userId,
|
||||
|
||||
businessName,
|
||||
|
||||
businessRegistrationNumber,
|
||||
|
||||
businessType,
|
||||
|
||||
contactName,
|
||||
|
||||
phoneNumber,
|
||||
|
||||
businessEmail,
|
||||
|
||||
expectedMonthlyVolume,
|
||||
|
||||
note:
|
||||
note || null,
|
||||
},
|
||||
{
|
||||
transaction,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
return businessCustomer;
|
||||
};
|
||||
|
||||
|
||||
module.exports = {
|
||||
createBusinessCustomerDetails,
|
||||
};
|
||||
Reference in New Issue
Block a user