Skip to content

Commit

Permalink
Merge pull request #4160 from traPtitech/feat/show_conflict_name_erro…
Browse files Browse the repository at this point in the history
…r_message

タグとグループで名前が重複しているときに適切なエラーメッセージを表示するように
  • Loading branch information
mehm8128 committed May 5, 2024
2 parents 8e7c016 + ef46078 commit 87d03ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/components/Modal/GroupCreateModal/GroupCreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import apis from '/@/lib/apis'
import { useToastStore } from '/@/store/ui/toast'
import { useModalStore } from '/@/store/ui/modal'
import { useMeStore } from '/@/store/domain/me'
import { AxiosError } from 'axios'
const { myId } = useMeStore()
const { addErrorToast } = useToastStore()
Expand All @@ -63,11 +64,14 @@ const create = async () => {
if (addMember.value) {
await apis.addUserGroupMember(group.id, { id: myIdV, role: '' })
}
} catch {
addErrorToast('グループの作成に失敗しました')
await popModal()
} catch (e) {
if (e instanceof AxiosError && e.response?.status === 409) {
addErrorToast('既に同じ名前のグループが存在しています')
} else {
addErrorToast('グループの作成に失敗しました')
}
}
await popModal()
}
</script>

Expand Down
9 changes: 7 additions & 2 deletions src/components/Modal/UserModal/TagsTabAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import apis from '/@/lib/apis'
import type { UserId } from '/@/types/entity-ids'
import useMaxLength from '/@/composables/utils/useMaxLength'
import { useToastStore } from '/@/store/ui/toast'
import { AxiosError } from 'axios'
const props = defineProps<{
userId: UserId
Expand All @@ -47,8 +48,12 @@ const addTag = async () => {
tag: newTagName.value
})
newTagName.value = ''
} catch {
addErrorToast('タグの追加に失敗しました')
} catch (e) {
if (e instanceof AxiosError && e.response?.status === 409) {
addErrorToast('既に同じ名前のタグがついています')
} else {
addErrorToast('タグの追加に失敗しました')
}
}
adding.value = false
}
Expand Down

0 comments on commit 87d03ae

Please sign in to comment.