diff --git a/src/actions/hooks/useProfileSettings.ts b/src/actions/hooks/useProfileSettings.ts index bff3878..365d08d 100644 --- a/src/actions/hooks/useProfileSettings.ts +++ b/src/actions/hooks/useProfileSettings.ts @@ -1,6 +1,6 @@ 'use client' -import { useCallback, useEffect, useState } from 'react'; +import { useCallback, useState } from 'react'; import { ProfileData, ProfileRequest } from '../../types/profile'; import { getPersonalData, setPersonData } from '../profile'; import { useLocalStorage } from '../../hooks/useLocalStorage'; @@ -18,7 +18,7 @@ export const useProfileSettings = (locale: string) => { setProfileSettings(data); }) .catch((err) => { - + console.log(err); }) .finally(() => { setFetchLoading(false); diff --git a/src/app/[locale]/account/(account)/messages/page.tsx b/src/app/[locale]/account/(account)/messages/page.tsx index 2038deb..630fed0 100644 --- a/src/app/[locale]/account/(account)/messages/page.tsx +++ b/src/app/[locale]/account/(account)/messages/page.tsx @@ -18,7 +18,7 @@ export default function Messages({ params: { locale } }: { params: { locale: str
@@ -42,7 +42,7 @@ export default function Messages({ params: { locale } }: { params: { locale: str
@@ -63,7 +63,7 @@ export default function Messages({ params: { locale } }: { params: { locale: str
diff --git a/src/components/Account/ProfileSettings.tsx b/src/components/Account/ProfileSettings.tsx index cfbb04b..2194da7 100644 --- a/src/components/Account/ProfileSettings.tsx +++ b/src/components/Account/ProfileSettings.tsx @@ -1,8 +1,8 @@ 'use client'; import React, { FC, useEffect, useState } from 'react'; -import { Button, Form, message, Upload } from 'antd'; -import type { GetProp, UploadFile, UploadProps } from 'antd'; +import { Form, message, Upload } from 'antd'; +import type { UploadFile } from 'antd'; import ImgCrop from 'antd-img-crop'; import { CameraOutlined, DeleteOutlined } from '@ant-design/icons'; import { useRouter } from '../../navigation'; @@ -12,17 +12,14 @@ import { validateImage } from '../../utils/account'; import { useProfileSettings } from '../../actions/hooks/useProfileSettings'; import { CustomInput } from '../view/CustomInput'; import { OutlinedButton } from '../view/OutlinedButton'; -import {FilledButton, FilledSquareButton, FilledYellowButton} from '../view/FilledButton'; +import { FilledSquareButton, FilledYellowButton } from '../view/FilledButton'; import { DeleteAccountModal } from '../Modals/DeleteAccountModal'; import { Loader } from '../view/Loader'; -import {ButtonProps} from "antd/es/button/button"; type ProfileSettingsProps = { locale: string; }; -type FileType = Parameters>[0]; - export const ProfileSettings: FC = ({ locale }) => { const [form] = Form.useForm(); const { profileSettings, fetchProfileSettings, save, fetchLoading } = useProfileSettings(locale); @@ -58,7 +55,7 @@ export const ProfileSettings: FC = ({ locale }) => { const onSaveProfile = () => { form.validateFields() .then(({ login, surname, username }) => { - const { phone, role, languagesLinks } = profileSettings; + const { phone, role, languagesLinks } = profileSettings || {}; const newProfile: ProfileRequest = { phone, role, @@ -75,7 +72,7 @@ export const ProfileSettings: FC = ({ locale }) => { reader.readAsDataURL(photo as File); reader.onloadend = () => { const newReg = new RegExp('data:image/(png|jpg|jpeg);base64,') - newProfile.faceImage = reader.result.replace(newReg, ''); + newProfile.faceImage = reader?.result?.replace(newReg, ''); newProfile.isFaceImageKeepExisting = false; onSave(newProfile); @@ -181,7 +178,7 @@ export const ProfileSettings: FC = ({ locale }) => { > {i18nText('save', locale)} - router.push('change-password')}> + router.push('settings/change-password')}> {i18nText('changePass', locale)} { const [userData] = useLocalStorage(AUTH_USER, ''); const { id: userId = 0 } = userData ? JSON.parse(userData) : {}; const router = useRouter(); + const pathname = usePathname(); const fetchData = () => { setErrorData(undefined); @@ -66,7 +67,7 @@ export const SessionsTabs = ({ locale, activeTab }: SessionsTabsProps) => { const onClickSession = (event: MouseEvent, id: number) => { event.stopPropagation(); event.preventDefault(); - router.push(`${id}`); + router.push(`${pathname}/${id}`); }; const getChildren = (list?: Session[]) => ( diff --git a/src/components/Modals/authModalContent/EnterContent.tsx b/src/components/Modals/authModalContent/EnterContent.tsx index 004a776..6bcc377 100644 --- a/src/components/Modals/authModalContent/EnterContent.tsx +++ b/src/components/Modals/authModalContent/EnterContent.tsx @@ -6,7 +6,7 @@ import { AUTH_USER } from '../../../constants/common'; import { SocialConfig } from '../../../constants/social'; import { useOauthWindow } from '../../../hooks/useOauthWindow'; import { getAuth } from '../../../actions/auth'; -import { getPersonalData } from '../../../actions/profile'; +import {getPersonalData, getUserData} from '../../../actions/profile'; import { CustomInput } from '../../view/CustomInput'; import { CustomInputPassword } from '../../view/CustomInputPassword'; import { FilledButton } from '../../view/FilledButton'; @@ -39,7 +39,7 @@ export const EnterContent: FC = ({ getAuth(locale, { login, password }) .then((data) => { if (data.jwtToken) { - getPersonalData(locale, data.jwtToken) + getUserData(locale, data.jwtToken) .then((profile) => { localStorage.setItem(AUTH_USER, JSON.stringify(profile)); updateToken(data.jwtToken);