IO-3255 Review comments.

This commit is contained in:
Patrick Fic
2025-08-27 11:50:00 -07:00
parent 5b400dce4f
commit 553c154e46
5 changed files with 38 additions and 28 deletions

View File

@@ -123,7 +123,7 @@ const insertUserAssociation = async (uid, email, shopId) => {
authid: uid,
validemail: true,
associations: {
data: [{ shopid: shopId, authlevel: 80, active: true }]
data: [{ shopid: shopId, authlevel: 99, active: true }]
}
}
};
@@ -140,6 +140,7 @@ const insertUserAssociation = async (uid, email, shopId) => {
const partsManagementProvisioning = async (req, res) => {
const { logger } = req;
const p = { ...req.body, userEmail: req.body.userEmail?.toLowerCase() };
// Can p be renamed to be more descriptive?
try {
await ensureEmailNotRegistered(p.userEmail);
@@ -191,7 +192,7 @@ const partsManagementProvisioning = async (req, res) => {
md_messaging_presets: DefaultNewShop.md_messaging_presets,
md_rbac: DefaultNewShop.md_rbac,
md_classes: DefaultNewShop.md_classes,
md_ins_cos: DefaultNewShop.md_ins_cos, // TODO need?
md_ins_cos: DefaultNewShop.md_ins_cos, // TODO need? //PF: Can ignore from here down for shop settings. Doesn't hurt to prepopulate. Required for graduation path.
md_categories: DefaultNewShop.md_categories, // TODO need?
md_labor_rates: DefaultNewShop.md_labor_rates, // TODO need?
md_payment_types: DefaultNewShop.md_payment_types, // TODO need?
@@ -200,7 +201,7 @@ const partsManagementProvisioning = async (req, res) => {
appt_alt_transport: DefaultNewShop.appt_alt_transport, // TODO need?
md_jobline_presets: DefaultNewShop.md_jobline_presets, // TODO need?
vendors: {
data: p.vendors.map((v) => ({
data: p.vendors.map((v) => ({ //Many of these will be empty, but good to call out explicitly to self document.
name: v.name,
street1: v.street1 || null,
street2: v.street2 || null,
@@ -226,13 +227,14 @@ const partsManagementProvisioning = async (req, res) => {
if (!p.userPassword) resetLink = await generateResetLink(p.userEmail);
const createdUser = await insertUserAssociation(userRecord.uid, p.userEmail, newShopId);
//Association can be included in shop creation call, but this is also prescriptive and fine.
return res.status(200).json({
shop: { id: newShopId, shopname: p.shopname },
user: {
id: createdUser.id,
email: createdUser.email,
resetLink: resetLink || undefined
resetLink: resetLink || undefined //Does WE know to expect this?
}
});
} catch (err) {