fix: improve error message for channel deletion
This commit is contained in:
parent
32f2edd7fc
commit
8bb4ef8b54
@ -2,6 +2,7 @@ import { useRouter } from 'next/router'
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Form } from 'react-component-form'
|
import { Form } from 'react-component-form'
|
||||||
import useTranslation from 'next-translate/useTranslation'
|
import useTranslation from 'next-translate/useTranslation'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
import { HandleSubmitCallback, useForm } from '../../../hooks/useForm'
|
import { HandleSubmitCallback, useForm } from '../../../hooks/useForm'
|
||||||
import { FormState } from '../../design/FormState'
|
import { FormState } from '../../design/FormState'
|
||||||
@ -81,9 +82,13 @@ export const ChannelSettings: React.FC<ChannelSettingsProps> = (props) => {
|
|||||||
await router.push(`/application/${guild.id}/${data.defaultChannelId}`)
|
await router.push(`/application/${guild.id}/${data.defaultChannelId}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setFetchState('error')
|
setFetchState('error')
|
||||||
|
if (axios.isAxiosError(error) && error.response?.status === 400) {
|
||||||
|
setMessageTranslationKey('application:delete-channel-only-one')
|
||||||
|
} else {
|
||||||
setMessageTranslationKey('errors:server-error')
|
setMessageTranslationKey('errors:server-error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"create": "Create",
|
"create": "Create",
|
||||||
"status": "Status",
|
"status": "Status",
|
||||||
"create-a-channel": "Create a channel",
|
"create-a-channel": "Create a channel",
|
||||||
|
"delete-channel-only-one": "The guild should have at least one channel. You can't delete the only channel of the guild.",
|
||||||
"create-a-guild": "Create a Guild",
|
"create-a-guild": "Create a Guild",
|
||||||
"create-a-guild-description": "Create your own guild and manage everything.",
|
"create-a-guild-description": "Create your own guild and manage everything.",
|
||||||
"join-a-guild": "Join a Guild",
|
"join-a-guild": "Join a Guild",
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"create": "Créer",
|
"create": "Créer",
|
||||||
"status": "Statut",
|
"status": "Statut",
|
||||||
"create-a-channel": "Créer un channel",
|
"create-a-channel": "Créer un channel",
|
||||||
|
"delete-channel-only-one": "La guilde doit avoir au moins un channel. Vous ne pouvez pas supprimer le seul channel de la guilde.",
|
||||||
"create-a-guild": "Créer une Guilde",
|
"create-a-guild": "Créer une Guilde",
|
||||||
"create-a-guild-description": "Créez votre propre guilde et gérez tout.",
|
"create-a-guild-description": "Créez votre propre guilde et gérez tout.",
|
||||||
"join-a-guild": "Rejoindre une Guilde",
|
"join-a-guild": "Rejoindre une Guilde",
|
||||||
|
Reference in New Issue
Block a user