Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

タグとグループで名前が重複しているときに適切なエラーメッセージを表示するように #4160

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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