Commit 9ce10768 authored by konstantin-smirnov's avatar konstantin-smirnov

DMVP-1080 - Изменить запрос на получение карточки профиля по uuid в административном сервисе

parent 5682d794
......@@ -10,6 +10,8 @@ import {
Input as TextField
} from '@chakra-ui/react';
import { useGetProfileByIdQuery } from '_store';
import { BaseData, SpecialityData, AddressData } from './components';
import './profilesEdition.scss';
import { } from "react-router-dom";
......@@ -18,6 +20,7 @@ const ProfilesEdition = () => {
const navigate = useNavigate();
const { pathname } = useLocation();
const profileId = pathname.split('/').pop();
const { isLoading, isSuccess, data: profile = {}} = useGetProfileByIdQuery(profileId);
return (
<div className='settings-layout'>
......@@ -65,10 +68,17 @@ const ProfilesEdition = () => {
</TabList>
<TabPanels>
<TabPanel>
<BaseData id={profileId} />
<BaseData
id={profileId}
isLoading={isLoading}
isSuccess={isSuccess}
profile={profile}
/>
</TabPanel>
<TabPanel>
<SpecialityData id={profileId} />
<SpecialityData
id={profileId}
/>
</TabPanel>
<TabPanel>
<AddressData id={profileId} />
......
......@@ -23,7 +23,6 @@ import {
} from '@chakra-ui/react';
import {
useGetProfileByIdQuery,
useUpdateProfileMutation,
useFetchRolesQuery,
useUpdateCredentialsMutation
......@@ -33,6 +32,9 @@ import '../../profilesEdition.scss';
const BaseData = ({
id,
isLoading,
isSuccess,
profile
}) => {
const [firstName, setFirstName] = useState();
const [lastName, setLastName] = useState();
......@@ -42,12 +44,11 @@ const BaseData = ({
const [isActive, setIsActive] = useState(false);
const [isVerified, setIsVerified] = useState(false);
const [showPassword, setShowPassword] = useState(false);
const [isEmailError, setIsEmailError] = useState(false);
const [roles, setRoles] = useState([]);
const [error, setError] = useState(false);
const [isModalOpen, setIsModalOpen] = useState(false);
const [validError, setValidError] = useState(false);
const { isLoading, isSuccess, data: profile = {}} = useGetProfileByIdQuery(id);
const [ updateProfile, {isLoading: isProfileUpdating, isSuccess: isProfileUpdated}] = useUpdateProfileMutation();
const [ updatePassword, {isLoading: isCredentialsUpdating, isSuccess: isCredentialsUpdated}] = useUpdateCredentialsMutation();
const { data: rolesList = [] } = useFetchRolesQuery();
......@@ -58,10 +59,11 @@ const BaseData = ({
useEffect(() => {
if (profile) {
setEmail(profile.email);
setFirstName(profile.fullName);
setFirstName(profile.firstName);
setLastName(profile.lastName);
setIsVerified(profile.verified);
setIsActive(profile.active);
//setRoles(profile?.roles || [])
setRoles(profile?.roles || [])
}
}, [profile, isSuccess])
......@@ -335,7 +337,7 @@ const BaseData = ({
}}
>
{
rolesList.map(({code, name}, index) => (
rolesList?.map(({code, name}, index) => (
<option key={index} value={code}>{name}</option>
))
}
......
......@@ -38,7 +38,7 @@ import { LanguagesLoader } from './dictionaryLoaders/languages';
import '../../profilesEdition.scss';
const SpecialityData = ({
id = null,
id = null
}) => {
const isLoading = false;
const [file, setFile] = useState([]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment