Merge remote-tracking branch 'origin/feature/IO-3255-parts-management-review1' into feature/IO-3255-simplified-part-management

This commit is contained in:
Dave
2025-08-28 14:06:07 -04:00
5 changed files with 37 additions and 27 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);
@@ -200,7 +201,7 @@ const partsManagementProvisioning = async (req, res) => {
appt_alt_transport: DefaultNewShop.appt_alt_transport,
md_jobline_presets: DefaultNewShop.md_jobline_presets,
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) {