2023-06-07 03:38:39 +03:00
|
|
|
import React, { FC } from 'react';
|
|
|
|
import { useGetItemsBySectionType } from 'hooks/useFetchItems';
|
|
|
|
import globalize from 'scripts/globalize';
|
|
|
|
|
|
|
|
import Loading from 'components/loading/LoadingComponent';
|
|
|
|
import { appRouter } from 'components/router/appRouter';
|
|
|
|
import SectionContainer from './SectionContainer';
|
|
|
|
|
|
|
|
import { Sections } from 'types/suggestionsSections';
|
2023-10-04 23:14:14 +03:00
|
|
|
import { ParentId } from 'types/library';
|
2023-06-07 03:38:39 +03:00
|
|
|
|
|
|
|
interface SuggestionsSectionContainerProps {
|
2023-10-04 23:14:14 +03:00
|
|
|
parentId: ParentId;
|
2023-06-07 03:38:39 +03:00
|
|
|
section: Sections;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SuggestionsSectionContainer: FC<SuggestionsSectionContainerProps> = ({
|
|
|
|
parentId,
|
|
|
|
section
|
|
|
|
}) => {
|
|
|
|
const getRouteUrl = () => {
|
|
|
|
return appRouter.getRouteUrl('list', {
|
|
|
|
serverId: window.ApiClient.serverId(),
|
|
|
|
itemTypes: section.type,
|
|
|
|
parentId: parentId
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const { isLoading, data: items } = useGetItemsBySectionType(
|
|
|
|
section,
|
|
|
|
parentId
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isLoading) {
|
|
|
|
return <Loading />;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<SectionContainer
|
|
|
|
sectionTitle={globalize.translate(section.name)}
|
2023-10-04 23:14:14 +03:00
|
|
|
items={items ?? []}
|
2023-06-07 03:38:39 +03:00
|
|
|
url={getRouteUrl()}
|
|
|
|
cardOptions={{
|
|
|
|
...section.cardOptions
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default SuggestionsSectionContainer;
|