mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
fix: move the me endpoint to generic useApiQuery
This commit is contained in:
@@ -43,7 +43,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { z } from 'zod';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { notify, PageHeader } from '@ema-platform/ui';
|
||||
import { useApiMutation, useGetMeQuery, baseApi } from '@ema-platform/api';
|
||||
import { useApiMutation, useApiQuery } from '@ema-platform/api';
|
||||
import type { AuthUser } from '@ema-platform/auth';
|
||||
import { SUPPORTED_LANGUAGES, type AppLanguage } from '../../../i18n/config';
|
||||
import { useAppDispatch, useAppSelector } from '../../../store/hooks';
|
||||
@@ -76,9 +76,9 @@ export function ProfilePage() {
|
||||
const { colorScheme, setColorScheme } = useMantineColorScheme();
|
||||
const layoutMode = useAppSelector((state) => state.preferences.layoutMode);
|
||||
|
||||
const { data: me } = useGetMeQuery();
|
||||
const { data: me, refetch: refetchMe } = useApiQuery<AuthUser>({ url: '/auth/me', method: 'GET' });
|
||||
const storeUser = useAppSelector((state) => state.auth.user);
|
||||
const user = (me as AuthUser | undefined) ?? storeUser;
|
||||
const user = me ?? storeUser;
|
||||
const [updateTrigger] = useApiMutation<AuthUser>();
|
||||
const [passwordTrigger] = useApiMutation<unknown>();
|
||||
|
||||
@@ -133,7 +133,7 @@ export function ProfilePage() {
|
||||
},
|
||||
}).unwrap();
|
||||
|
||||
dispatch(baseApi.util.invalidateTags(['Me']));
|
||||
refetchMe();
|
||||
notify.success(t('profile.profileUpdated'));
|
||||
} catch {
|
||||
notify.error(t('profile.updateFailed'));
|
||||
|
||||
Reference in New Issue
Block a user