Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
content: ''
}

.title-skeleton{
display: block;
width: 100%;
max-width: 380px;
}

.title-skeleton::before {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ export const PreviewQuestionsItemSkeleton = () => {
return (
<li>
<Card withOutsideShadow size="small">
<Flex gap="8">
<div className={styles.link}>
{!isMobileS && <ImageWithWrapperSkeleton className={styles.image} />}
<Flex direction="column" gap="8">
<TextSkeleton
variant="body3-accent"
width={isMobileM ? 280 : 380}
width={isMobileM ? '100%' : 320}
className={classNames(styles.title, styles['title-skeleton'])}
/>
<QuestionGradeListSkeleton className={styles.params} size="small" />
</Flex>
</Flex>
</div>
</Card>
</li>
);
Expand Down
1 change: 1 addition & 0 deletions src/pages/admin/collection/collectionDetail/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { CollectionPage } from './ui/CollectionPage/CollectionPage';
export { CollectionPageContentSkeleton } from './ui/CollectionPageContent/CollectionPageContent.skeleton';
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,4 @@
width: 360px;
height: auto;
}
}

}
Comment thread
PerelomaDenis marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,139 +1,49 @@
import classNames from 'classnames';

import { useScreenSize } from '@/shared/libs';
import { Card } from '@/shared/ui/Card';
import { Skeleton } from '@/shared/ui/Skeleton';
import { BackHeaderSkeleton } from '@/shared/ui/BackHeader';
import { ButtonSkeleton } from '@/shared/ui/Button';

import { DeleteQuestionButtonSkeleton } from '@/features/question/deleteQuestion';

import {
AdditionalInfoSkeleton,
CollectionBodySkeleton,
CollectionHeaderSkeleton,
} from '@/widgets/Collection';
import { TasksControllerSkeleton } from '@/widgets/task/TasksList';

import styles from './CollectionPage.module.css';

export const CollectionPageSkeleton = () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[ISSUE] - Сейчас скелетон не отрабатывает корректно, так как в CollectionPage стоит проверка на наличие коллекции. Ее нужно убрать, так как до получения коллекции показывается заглушка, которой не должно быть
ПОсле того как уберешь это условие нао будет переместить все что передается в пропс content компонента PageWrapper в отдельный компонент CollectionPageContent. И соответственно скелетон также расположить

const { isMobile } = useScreenSize();
const { isSmallScreen } = useScreenSize();

if (isMobile) {
if (isSmallScreen) {
return (
<section className={classNames(styles.wrapper, styles.mobile)}>
<Card>
<div className={styles.header}>
<Skeleton width={54} height={56} borderRadius={16} style={{ flexShrink: 0 }} />
<div className={styles['title-wrapper']}>
<Skeleton width="80%" height={22} />
<Skeleton width="40%" height={22} />
</div>
<Skeleton width={54} height={19} borderRadius={30} style={{ marginLeft: 'auto' }} />
</div>
</Card>
<Card>
<Skeleton width={120} height={22} style={{ marginBottom: '16px' }} />
<Skeleton width="60%" height={22} style={{ marginBottom: '10px' }} />
<Skeleton width="100%" height={16} />
</Card>
<Card>
<div className={styles.info}>
<Skeleton width={50} height={22} />
<div className={styles.params}>
<Skeleton width={100} height={30} />
<Skeleton width={150} height={30} />
</div>
</div>
<div className={styles.info}>
<Skeleton width={50} height={22} />
<div className={styles.params}>
<Skeleton width={100} height={42} />
<Skeleton width={140} height={42} />
<Skeleton width={90} height={42} />
</div>
</div>
<div className={styles.info}>
<Skeleton width={50} height={22} />
<div className={styles.params}>
<Skeleton width={100} height={22} />
<Skeleton width={160} height={22} />
<Skeleton width={110} height={22} />
</div>
</div>
</Card>
<Skeleton width={150} height={22} style={{ marginInline: 'auto' }} />
<Card className={styles['actions-wrapper']}>
<div className={styles.actions}>
<Skeleton width={130} height={48} borderRadius={16} />
<Skeleton width={130} height={48} borderRadius={16} />
<Skeleton width={130} height={48} borderRadius={16} />
</div>
</Card>
<Card>
<Skeleton width={140} height={22} style={{ marginBottom: '20px' }} />
<Skeleton height={200} width="100%" />
</Card>
<Card>
<Skeleton width={140} height={22} style={{ marginBottom: '20px' }} />
<Skeleton height={200} />
</Card>
<BackHeaderSkeleton>
<DeleteQuestionButtonSkeleton isDetailPage />
<ButtonSkeleton width={180} />
</BackHeaderSkeleton>
<CollectionHeaderSkeleton />
<CollectionBodySkeleton />
<TasksControllerSkeleton />
</section>
);
}

return (
<section className={styles.wrapper}>
<div className={styles.main}>
<Card>
<div className={styles.header}>
<Skeleton width={170} height={114} borderRadius={24} style={{ flexShrink: 0 }} />
<div className={styles['title-wrapper']}>
<Skeleton width="80%" height={44} />
<Skeleton width="50%" height={22} />
</div>
<Skeleton style={{ marginLeft: 'auto' }} width={78} height={19} borderRadius={30} />
</div>
</Card>
<Card className={styles['actions-wrapper']}>
<div className={styles.actions}>
<Skeleton width={130} height={48} borderRadius={16} />
<Skeleton width={130} height={48} borderRadius={16} />
<Skeleton width={130} height={48} borderRadius={16} />
</div>
</Card>
<Card>
<Skeleton width={140} height={22} style={{ marginBottom: '20px' }} />
<Skeleton height={200} />
</Card>
<Card>
<Skeleton width={170} height={22} style={{ marginBottom: '20px' }} />
<Skeleton height={350} />
</Card>
</div>
<div className={styles.additional}>
<Card>
<Skeleton width={120} height={22} style={{ marginBottom: '16px' }} />
<Skeleton width="60%" height={22} style={{ marginBottom: '10px' }} />
<Skeleton height={16} />
</Card>
<Card>
<div className={styles.info}>
<Skeleton width={50} height={22} />
<div className={styles.params}>
<Skeleton width={100} height={30} />
<Skeleton width={150} height={30} />
</div>
</div>
<div className={styles.info}>
<Skeleton width={50} height={22} />
<div className={styles.params}>
<Skeleton width={100} height={42} />
<Skeleton width={140} height={42} />
<Skeleton width={90} height={42} />
</div>
</div>
<div className={styles.info}>
<Skeleton width={50} height={22} />
<div className={styles.params}>
<Skeleton width={100} height={22} />
<Skeleton width={160} height={22} />
<Skeleton width={110} height={22} />
</div>
</div>
</Card>
<Skeleton width={150} height={22} style={{ marginInline: 'auto' }} />
<BackHeaderSkeleton>
<DeleteQuestionButtonSkeleton isDetailPage />
<ButtonSkeleton width={180} />
</BackHeaderSkeleton>
<CollectionHeaderSkeleton />
<CollectionBodySkeleton />
<TasksControllerSkeleton />
</div>
<AdditionalInfoSkeleton />
</section>
);
};
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
import classNames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { NavLink, useParams } from 'react-router-dom';
import { useParams } from 'react-router-dom';

import { Collections, i18Namespace, ROUTES, Translation } from '@/shared/config';
import { route, useAppSelector, useScreenSize } from '@/shared/libs';
import { BackHeader } from '@/shared/ui/BackHeader';
import { Button } from '@/shared/ui/Button';
import { Tooltip } from '@/shared/ui/Tooltip';
import { Collections, i18Namespace } from '@/shared/config';
import { useAppSelector } from '@/shared/libs';

import { useGetCollectionByIdQuery } from '@/entities/collection';
import { getIsAuthor, getProfileId, getUserId } from '@/entities/profile';
import { useGetQuestionsListQuery } from '@/entities/question';
import { useGetTasksListQuery } from '@/entities/task';

import { DeleteCollectionButton } from '@/features/collections/deleteCollection';

import {
AdditionalInfo,
CollectionAdditionalInfoDrawer,
CollectionBody,
CollectionHeader,
} from '@/widgets/Collection';
import { PageWrapper, PageWrapperStubs } from '@/widgets/PageWrapper';
import { TasksController } from '@/widgets/task/TasksList';

import styles from './CollectionPage.module.css';
import { CollectionPageSkeleton } from './CollectionPage.skeleton';
import { CollectionPageContent } from '../CollectionPageContent/CollectionPageContent';
import { CollectionPageContentSkeleton } from '../CollectionPageContent/CollectionPageContent.skeleton';

export const CollectionPage = () => {
const { t } = useTranslation(i18Namespace.translation);
const { isSmallScreen } = useScreenSize();
const { collectionId } = useParams<{ collectionId: string }>();
const {
data: collection,
Expand Down Expand Up @@ -66,7 +52,7 @@ export const CollectionPage = () => {
);

const questions = response?.data ?? [];
const hasData = questions.length > 0;
const hasData = questions.length > 0 || isLoading;
const stubs: PageWrapperStubs = {
empty: {
title: t(Collections.STUB_EMPTY_COLLECTION_TITLE),
Expand All @@ -77,108 +63,27 @@ export const CollectionPage = () => {
error: { onClick: () => refetch() },
};

if (!collection) {
return null;
}

const {
createdBy,
questionsCount,
tasksCount,
isFree,
company,
specializations,
keywords,
title,
description,
imageSrc: collectionImageSrc,
} = collection;

const isDisabled = isAuthor && createdBy?.id !== userId;
const imageSrc = collectionImageSrc ?? company?.imageSrc;
const renderMobileOrTablet = isSmallScreen && (
<>
<section
className={classNames(styles.wrapper, {
[styles.mobile]: isSmallScreen,
})}
>
<CollectionHeader
renderDrawer={() => <CollectionAdditionalInfoDrawer collection={collection} />}
title={title}
description={description}
imageSrc={imageSrc}
company={company}
/>{' '}
<CollectionBody isFree={isFree} isAdmin questions={questions} />
{tasks?.length ? <TasksController isFree={Boolean(isFree)} isAdmin tasks={tasks} /> : null}
</section>
</>
const isDisabled = isAuthor && collection?.createdBy?.id !== userId;
const content = (
<CollectionPageContent
collection={collection}
questions={questions}
tasks={tasks}
isDisabled={isDisabled}
isLoading={isLoading}
/>
);

return (
<PageWrapper
roles={['admin', 'author']}
isLoading={isLoading || isFetching}
// isLoading={true}
hasError={isCollectionError || isQuestionsError}
hasData={hasData}
stubs={stubs}
skeleton={<CollectionPageSkeleton />}
content={
<>
<BackHeader>
<DeleteCollectionButton
collectionId={collection.id}
isDetailPage
disabled={isDisabled}
/>

<Tooltip
title={t(Translation.TOOLTIP_COLLECTION_DISABLED_INFO)}
placement="bottom-start"
color="red"
offsetTooltip={10}
shouldShowTooltip={isDisabled}
>
<NavLink
style={{ marginLeft: 'auto' }}
to={route(ROUTES.admin.collections.edit.page, collection.id)}
>
<Button disabled={isDisabled}>{t(Translation.EDIT)}</Button>
</NavLink>
</Tooltip>
</BackHeader>

{renderMobileOrTablet || (
<section className={styles.wrapper}>
<div className={styles.main}>
<CollectionHeader
renderDrawer={() => <CollectionAdditionalInfoDrawer collection={collection} />}
title={title}
description={description}
imageSrc={imageSrc}
company={company}
/>{' '}
<CollectionBody isFree={isFree} isAdmin questions={questions} />
{tasks?.length ? (
<TasksController isFree={Boolean(isFree)} isAdmin tasks={tasks} />
) : null}
</div>
<div className={styles.additional}>
<AdditionalInfo
createdBy={createdBy}
questionsCount={questionsCount}
tasksCount={tasksCount}
isFree={isFree}
company={company}
specializations={specializations}
keywords={keywords}
/>
</div>
</section>
)}
</>
}
skeleton={<CollectionPageContentSkeleton />}
content={content}
>
{({ content }) => content}
</PageWrapper>
Expand Down
Loading
Loading