better handling for slate name taken

This commit is contained in:
Martina 2020-09-19 13:13:23 -07:00
parent dbee8e1d82
commit cfbaaabfd0
2 changed files with 12 additions and 0 deletions

View File

@ -66,6 +66,8 @@ export const error = {
SERVER_UPDATE_SLATE_MUST_PROVIDE_NAME: "Please provide a slate name",
SERVER_UPDATE_SLATE:
"We're having trouble updating that slate right now. Please try again later",
SERVER_UPDATE_SLATE_NAME_TAKEN:
"It looks like that slatename is taken. Please choose another",
V1_SERVER_UPLOAD_SLATE_NOT_FOUND:
"We're having trouble locating that slate right now. Please try again later",
V1_SERVER_API_KEY_NOT_FOUND:

View File

@ -56,6 +56,16 @@ export default async (req, res) => {
});
}
const existingSlate = await Data.getSlateByName({
slatename: req.body.data.data.name,
});
if (existingSlate) {
return res.status(500).send({
decorator: "SERVER_UPDATE_SLATE_NAME_TAKEN",
error: true,
});
}
const slate = await Data.updateSlateById({
id: response.id,
slatename: Strings.createSlug(req.body.data.data.name),