Merged in feature/IO-3187-Admin-Enhancements (pull request #2231)
IO-3187 Admin Enhancements Approved-by: Dave Richer
This commit is contained in:
@@ -39,12 +39,14 @@ exports.createShop = async (req, res) => {
|
||||
|
||||
try {
|
||||
const result = await client.request(
|
||||
`mutation INSERT_BODYSHOPS($bs: bodyshops_insert_input!){
|
||||
insert_bodyshops_one(object:$bs){
|
||||
id
|
||||
|
||||
}
|
||||
}`,
|
||||
`mutation INSERT_BODYSHOPS($bs: bodyshops_insert_input!) {
|
||||
insert_bodyshops_one(object: $bs) {
|
||||
id
|
||||
vendors {
|
||||
id
|
||||
}
|
||||
}
|
||||
}`,
|
||||
{
|
||||
bs: {
|
||||
...bodyshop,
|
||||
@@ -54,12 +56,39 @@ exports.createShop = async (req, res) => {
|
||||
{ countertype: "ihbnum", count: 1 },
|
||||
{ countertype: "paymentnum", count: 1 }
|
||||
]
|
||||
},
|
||||
vendors: {
|
||||
data: [{ name: "In-House" }]
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
res.json(result);
|
||||
const bodyshopId = result.insert_bodyshops_one.id;
|
||||
const vendorId = result.insert_bodyshops_one.vendors[0].id;
|
||||
|
||||
if (!bodyshopId || !vendorId) {
|
||||
throw new Error("Failed to create bodyshop or vendor");
|
||||
}
|
||||
|
||||
const updateBodyshop = await client.request(
|
||||
`mutation UPDATE_BODYSHOP($id: uuid!, $inhousevendorid: uuid!) {
|
||||
update_bodyshops_by_pk(pk_columns: { id: $id }, _set: { inhousevendorid: $inhousevendorid }) {
|
||||
id
|
||||
}
|
||||
}`,
|
||||
{
|
||||
id: bodyshopId,
|
||||
inhousevendorid: vendorId
|
||||
}
|
||||
);
|
||||
res.status(200).json(updateBodyshop);
|
||||
} catch (error) {
|
||||
logger.log("admin-create-shop-error", "error", req.user.email, null, {
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
request: req.body,
|
||||
ioadmin: true
|
||||
});
|
||||
res.status(500).json(error);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user