update ConfigurationsProvider with new logo

This commit is contained in:
ronronscelestes 2022-04-12 15:23:56 +02:00
parent 681f095455
commit c2605de89a
3 changed files with 12 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import {
request,
useNotification,
TrackingContext,
prefixFileUrlWithBackendUrl,
} from '@strapi/helper-plugin';
import { SkipToContent } from '@strapi/design-system/Main';
import { useIntl } from 'react-intl';
@ -71,7 +72,7 @@ function App() {
data: { hasAdmin, uuid, menuLogo },
} = await request('/admin/init', { method: 'GET' });
setCustomLogo(menuLogo, 'menu');
setCustomLogo(prefixFileUrlWithBackendUrl(menuLogo), 'menu');
if (uuid) {
try {

View File

@ -17,6 +17,7 @@ import { Link } from '@strapi/design-system/Link';
import { Button } from '@strapi/design-system/Button';
import ExternalLink from '@strapi/icons/ExternalLink';
import Check from '@strapi/icons/Check';
import { useConfigurations } from '../../../../hooks';
import Form from './components/Form';
import { fetchProjectSettings, updateProjectSettings } from './utils/api';
import { getFormData } from './utils/getFormData';
@ -30,6 +31,10 @@ const ApplicationInfosPage = () => {
useFocusWhenNavigate();
const appInfos = useAppInfos();
const { shouldUpdateStrapi, latestStrapiReleaseTag, strapiVersion } = appInfos;
const {
setCustomLogo,
logos: { menu },
} = useConfigurations();
const { data } = useQuery('project-settings', fetchProjectSettings);
@ -38,8 +43,9 @@ const ApplicationInfosPage = () => {
: 'app.components.UpgradePlanModal.text-ee';
const submitMutation = useMutation(body => updateProjectSettings(body), {
onSuccess: async () => {
onSuccess: async ({ menuLogo }) => {
await queryClient.invalidateQueries('project-settings', { refetchActive: true });
setCustomLogo(menuLogo?.url || menu.default, 'menu');
},
});

View File

@ -8,7 +8,9 @@ const fetchProjectSettings = async () => {
};
const updateProjectSettings = async body => {
await axiosInstance.post('/admin/project-settings', body);
const { data } = await axiosInstance.post('/admin/project-settings', body);
return prefixAllUrls(data);
};
export { fetchProjectSettings, updateProjectSettings };