Skip to content

Commit

Permalink
add photosSwiper in profilePost (#152)
Browse files Browse the repository at this point in the history
* refactor project - add photosSwiper to posts, add some props to right render of swiper, refactor paths when modal close

* add photosSwiper in Profile page

---------

Co-authored-by: Daniil <daniilminin1990@yandex.ru>
  • Loading branch information
momecaptr and daniilminin1990 authored Dec 6, 2024
1 parent a60de79 commit d44975f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/pagesComponents/profile/Profile.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
margin-top: 53px;

.postWrapper {
width: 100%;
width: 300px;
height: 300px;
background-color: var(--dark-500);

.usersPostPhotosSwiper {
width: 100%;
height: 100%;
}

img {
cursor: pointer;
width: 100%;
Expand Down
19 changes: 13 additions & 6 deletions src/pagesComponents/profile/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react';
import { useEffect, useState } from 'react';
import { useEffect, useRef, useState } from 'react';

import { useMeQuery } from '@/shared/api/auth/authApi';
import { GetPostsResponse, GetPublicUserProfileResponse } from '@/shared/api/public/publicTypes';
import { ModalKey, useModal } from '@/shared/lib';
import { PhotoProfile, Typography, Wrapper } from '@/shared/ui';
import { PhotoProfile, PhotosSwiper, Typography, Wrapper } from '@/shared/ui';
import { PostModal } from '@/widget';
import Link from 'next/link';
import { useRouter } from 'next/router';
Expand All @@ -24,6 +24,7 @@ export const Profile = ({ postsUser, user }: Props) => {
const { isOpen, setOpen } = useModal(ModalKey.ViewPhoto);
const postId = Number(router.query.postId);
const { query, ...path } = router;
const divRef = useRef(null);

useEffect(() => {
if (router.isReady && !isOpen && postId && postsUser?.items.find((post) => post.id === postId)) {
Expand Down Expand Up @@ -57,6 +58,10 @@ export const Profile = ({ postsUser, user }: Props) => {
}
};

useEffect(() => {
console.log({ ref: divRef.current });
}, [divRef]);

if (!user) {
return <>НИХРЕНА НЕТ</>;
}
Expand Down Expand Up @@ -109,14 +114,16 @@ export const Profile = ({ postsUser, user }: Props) => {
return (
<div className={s.postWrapper} key={post.id}>
{post.images && post.images.length > 0 ? (
<img
<div
onClick={() => {
setPickedId(post.id);
showPostModalHandler(true, post.id);
}}
alt={'post'}
src={post.images[0].url}
/>
ref={divRef}
style={{ height: '100%', width: '100%' }}
>
<PhotosSwiper className={s.usersPostPhotosSwiper} classNameImage={s.img} sliders={post.images} />
</div>
) : (
<div>No image available</div> // Здесь можно разместить заглушку или текст
)}
Expand Down

0 comments on commit d44975f

Please sign in to comment.