diff --git a/frontend/src/app/providers/userProvider.tsx b/frontend/src/app/providers/userProvider.tsx index eb3c61a..143b438 100644 --- a/frontend/src/app/providers/userProvider.tsx +++ b/frontend/src/app/providers/userProvider.tsx @@ -18,7 +18,9 @@ export default function UserProvider({ children }: IChildren) { const [user, setUser] = useState(undefined); const updateUser = () => { - getUser().then(setUser) + getUser() + .then(setUser) + .catch(() => setUser(null)) console.log(user) } diff --git a/frontend/src/entities/user/api.ts b/frontend/src/entities/user/api.ts index 7e9133a..4b19044 100644 --- a/frontend/src/entities/user/api.ts +++ b/frontend/src/entities/user/api.ts @@ -25,7 +25,7 @@ export async function editUser(newUser: User): Promise { } export async function updateAvatar(avatar: FormData) { - return UserClient.patch('/avatar', {avatar}) + return UserClient.patch('/avatar', avatar) .then(response => { return response.data }).catch(error => { diff --git a/frontend/src/pages/edit/ui/edit.tsx b/frontend/src/pages/edit/ui/edit.tsx index eccfe31..a60e327 100644 --- a/frontend/src/pages/edit/ui/edit.tsx +++ b/frontend/src/pages/edit/ui/edit.tsx @@ -4,7 +4,7 @@ import { addNotify, Card } from '../../../shared' import { ReactSVG } from 'react-svg' import PencilToSquareIcon from '@gravity-ui/icons/svgs/pencil-to-square.svg'; import {SealCheck} from '@gravity-ui/icons'; -import { Button, Icon, Portal } from '@gravity-ui/uikit' +import { Button, Icon } from '@gravity-ui/uikit' import { UserContext } from '../../../app/providers' import { ModalEdit } from './modal_edit'; import { ModalAbout, ModalName, ModalClass } from './modals'; @@ -19,6 +19,7 @@ interface Props { export function Edit({verifySend, verify_hook}: Props) { const [animEdit, setAnimEdit] = useState(false) const [editModal, setEdit] = useState(false) + const [isCrop, setCrop] = useState(false) const [img, setImg] = useState(undefined) const {user, setUser} = useContext(UserContext) @@ -28,6 +29,16 @@ export function Edit({verifySend, verify_hook}: Props) { setAnimEdit(false) } + const onClose = () => { + setEdit(false) + setAnimEdit(false) + } + + const imgUpload = (img: string) => { + setImg(img) + setCrop(true) + } + const [litera, setLitera] = useState(false) const [desc, setDesc] = useState(false) const [name, setName] = useState(false) @@ -52,10 +63,10 @@ export function Edit({verifySend, verify_hook}: Props) { title: 'Фото обновлено', content: 'Вы успешно обновили фотографию своего профиля' }) + setImg(undefined) } - const onPhoto = () => { - setAnimEdit(false) + const onPhoto = (img: string | undefined) => { if (img) { fetch(img) .then(res => res.blob()) @@ -63,36 +74,29 @@ export function Edit({verifySend, verify_hook}: Props) { const avatarForm = new FormData(); avatarForm.append('avatar', blob) updateAvatar(avatarForm).then(afterPhoto) + setAnimEdit(false) }) } } - if (user) - return
- - {img && - - - } - + if (img && user && isCrop){ + return setCrop(false)} + /> + } else if (user) { + return
openModal(setLitera)} open_desc={() => openModal(setDesc)} open_name={() => openModal(setName)} - set_photo={setImg} - close_hook={() => setEdit(false) - } + set_photo={imgUpload} + close_hook={onClose} /> - - - setDesc(false)} nowDesc={user.desc}> setName(false)} nowName={user.name} nowSur={user.surname}> setLitera(false)} nowClass={user.literal}> @@ -125,4 +129,5 @@ export function Edit({verifySend, verify_hook}: Props) {
+ } } \ No newline at end of file diff --git a/frontend/src/pages/edit/ui/modal_edit.tsx b/frontend/src/pages/edit/ui/modal_edit.tsx index c712038..042cdd5 100644 --- a/frontend/src/pages/edit/ui/modal_edit.tsx +++ b/frontend/src/pages/edit/ui/modal_edit.tsx @@ -11,7 +11,7 @@ interface Props { open_litera: () => void open_desc: () => void open_name: () => void - set_photo: React.Dispatch> + set_photo: (img: string) => void } export function ModalEdit({is_open, close_hook, open_desc, open_litera, open_name, set_photo}: Props): ReactElement { diff --git a/frontend/src/pages/edit/ui/style.module.scss b/frontend/src/pages/edit/ui/style.module.scss index cb1abe7..4726258 100644 --- a/frontend/src/pages/edit/ui/style.module.scss +++ b/frontend/src/pages/edit/ui/style.module.scss @@ -20,6 +20,10 @@ } } +.overlay { + height: 100%; +} + body { overflow: hidden; } diff --git a/frontend/src/pages/history/ui/history.tsx b/frontend/src/pages/history/ui/history.tsx index c92bb67..699c2e6 100644 --- a/frontend/src/pages/history/ui/history.tsx +++ b/frontend/src/pages/history/ui/history.tsx @@ -24,7 +24,7 @@ export function History() { name={{user.name}} description={{user.username}}> - + ) } @@ -35,105 +35,13 @@ export function History() { } } + if (user) { - const test =
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- } - name={{user.name}} - description={{'ramchike'}}> - - -
-
- return
- Взаимные лайки - {test} + return
+ {historyListComponent()}
} - return
- {historyListComponent()} -
+ } \ No newline at end of file diff --git a/frontend/src/shared/clients.ts b/frontend/src/shared/clients.ts index 7698a18..7dd06f4 100644 --- a/frontend/src/shared/clients.ts +++ b/frontend/src/shared/clients.ts @@ -7,8 +7,8 @@ export const UserClient = axios.create({ UserClient.interceptors.request.use(config => { - //config.headers['Tg-Authorization'] = Telegram.WebApp.initData; - config.headers['Tg-Authorization'] = "user%3D%7B%22id%22%3A1977502575%2C%22first_name%22%3A%22Zoom%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22ramchike%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%7D%26chat_instance%3D6800930143016803379%26chat_type%3Dsender%26auth_date%3D1729890471%26hash%3Dc98f9da098efdb0e642fdfb9b078f5e8e5bf3fcbfeef932cfecc3e5b540502ec" + config.headers['Tg-Authorization'] = Telegram.WebApp.initData; + //config.headers['Tg-Authorization'] = "user%3D%7B%22id%22%3A1977502575%2C%22first_name%22%3A%22Zoom%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22ramchike%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%7D%26chat_instance%3D6800930143016803379%26chat_type%3Dsender%26auth_date%3D1729890471%26hash%3Dc98f9da098efdb0e642fdfb9b078f5e8e5bf3fcbfeef932cfecc3e5b540502ec" return config }) diff --git a/frontend/src/widgets/crop/crop.tsx b/frontend/src/widgets/crop/crop.tsx index a026e6b..cbba07b 100644 --- a/frontend/src/widgets/crop/crop.tsx +++ b/frontend/src/widgets/crop/crop.tsx @@ -11,7 +11,7 @@ interface Props { } export function CropWidget({img, setImg, onComplete}: Props): ReactElement { - const [zoom, setZoom] = useState(1.4) + const [zoom, setZoom] = useState(1) const [crop, setCrop] = useState({x: 0, y: 0}) const [area, setArea] = useState(null) diff --git a/frontend/src/widgets/crop/style.module.scss b/frontend/src/widgets/crop/style.module.scss index 5d9115a..31fbee6 100644 --- a/frontend/src/widgets/crop/style.module.scss +++ b/frontend/src/widgets/crop/style.module.scss @@ -1,7 +1,6 @@ .main { - position: relative; background: black; - height: 100vh; + height: 100%; .container-cropper { height: 100%; }