mirror of
https://github.com/strapi/strapi.git
synced 2026-01-07 12:45:45 +00:00
Apply feedback
This commit is contained in:
parent
4157fcc331
commit
b002e21ff5
@ -1,6 +1,7 @@
|
||||
import { useCallback, useReducer, useEffect, useRef } from 'react';
|
||||
import { request, useNotification } from '@strapi/helper-plugin';
|
||||
import { useNotification } from '@strapi/helper-plugin';
|
||||
import reducer, { initialState } from './reducer';
|
||||
import axiosIntance from '../../utils/axiosInstance';
|
||||
import pluginId from '../../pluginId';
|
||||
|
||||
const useFetchRole = id => {
|
||||
@ -26,7 +27,9 @@ const useFetchRole = id => {
|
||||
|
||||
const fetchRole = async roleId => {
|
||||
try {
|
||||
const { role } = await request(`/${pluginId}/roles/${roleId}`, { method: 'GET' });
|
||||
const {
|
||||
data: { role },
|
||||
} = await axiosIntance.get(`/${pluginId}/roles/${roleId}`);
|
||||
|
||||
// Prevent updating state on an unmounted component
|
||||
if (isMounted.current) {
|
||||
|
||||
@ -108,7 +108,7 @@ const EditPage = () => {
|
||||
paddingRight={7}
|
||||
>
|
||||
<Stack size={4}>
|
||||
<H3>
|
||||
<H3 as="h2">
|
||||
{formatMessage({
|
||||
id: getTrad('EditPage.form.roles'),
|
||||
defaultMessage: 'Role details',
|
||||
@ -126,7 +126,7 @@ const EditPage = () => {
|
||||
})}
|
||||
error={
|
||||
errors.name
|
||||
? formatMessage({ id: errors.name, defaultMessage: errors.name })
|
||||
? formatMessage({ id: errors.name, defaultMessage: 'Invalid value' })
|
||||
: null
|
||||
}
|
||||
/>
|
||||
@ -144,7 +144,7 @@ const EditPage = () => {
|
||||
errors.description
|
||||
? formatMessage({
|
||||
id: errors.description,
|
||||
defaultMessage: errors.description,
|
||||
defaultMessage: 'Invalid value',
|
||||
})
|
||||
: null
|
||||
}
|
||||
|
||||
@ -30,11 +30,8 @@ jest.mock('../../../../hooks', () => {
|
||||
|
||||
function makeAndRenderApp() {
|
||||
const history = createMemoryHistory();
|
||||
const messages = {
|
||||
'components.Input.error.validation.required': 'This value is required.',
|
||||
};
|
||||
const app = (
|
||||
<IntlProvider locale="en" messages={messages} textComponent="span">
|
||||
<IntlProvider locale="en" messages={{ en: {} }} textComponent="span">
|
||||
<ThemeProvider theme={lightTheme}>
|
||||
<Router history={history}>
|
||||
<Switch>
|
||||
@ -570,11 +567,11 @@ describe('Admin | containers | RoleEditPage', () => {
|
||||
<div
|
||||
class="c16"
|
||||
>
|
||||
<h3
|
||||
<h2
|
||||
class="c17"
|
||||
>
|
||||
Role details
|
||||
</h3>
|
||||
</h2>
|
||||
<div
|
||||
class="c7 c18"
|
||||
>
|
||||
@ -688,7 +685,7 @@ describe('Admin | containers | RoleEditPage', () => {
|
||||
// Show errors after form submit
|
||||
await userEvent.click(saveButton);
|
||||
await waitFor(() => expect(saveButton).not.toBeDisabled());
|
||||
const errorMessages = await getAllByText(/this value is required/i);
|
||||
const errorMessages = await getAllByText(/invalid value/i);
|
||||
errorMessages.forEach(errorMessage => expect(errorMessage).toBeInTheDocument());
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user