feat: require brand description in create and update operations, add validation messages
This commit is contained in:
@@ -195,7 +195,7 @@ const createBrandMutation = useMutation({
|
||||
brandsApi.create({
|
||||
name: brandForm.name.trim(),
|
||||
website: brandForm.website.trim() || null,
|
||||
description: brandForm.description.trim() || null,
|
||||
description: brandForm.description.trim(),
|
||||
}),
|
||||
onSuccess: async (brand) => {
|
||||
message.success(t('brands.messages.createBrand'))
|
||||
@@ -212,6 +212,10 @@ async function submitBrand(): Promise<void> {
|
||||
if (!brandForm.name.trim()) {
|
||||
return
|
||||
}
|
||||
if (!brandForm.description.trim()) {
|
||||
message.warning(t('brands.messages.brandDescriptionRequired'))
|
||||
return
|
||||
}
|
||||
await createBrandMutation.mutateAsync()
|
||||
}
|
||||
|
||||
@@ -868,13 +872,13 @@ onBeforeUnmount(() => {
|
||||
@ok="submitBrand"
|
||||
>
|
||||
<a-form layout="vertical">
|
||||
<a-form-item :label="t('brands.form.brandName')">
|
||||
<a-form-item :label="t('brands.form.brandName')" required>
|
||||
<a-input v-model:value="brandForm.name" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('brands.form.brandWebsite')">
|
||||
<a-input v-model:value="brandForm.website" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('brands.form.brandDescription')">
|
||||
<a-form-item :label="t('brands.form.brandDescription')" required>
|
||||
<a-textarea v-model:value="brandForm.description" :rows="4" />
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
|
||||
Reference in New Issue
Block a user