Added usage of MobileCard type on Service page

This commit is contained in:
Neshura 2022-12-23 18:41:10 +01:00
parent b9540478e5
commit ce0a7c43c0
No known key found for this signature in database
GPG key ID: ACDF5B6EBECF6B0A

View file

@ -4,17 +4,29 @@ import Dockerode from 'dockerode';
import { ReactElement } from 'react' import { ReactElement } from 'react'
import useSWR from 'swr'; import useSWR from 'swr';
import { CardContentService, PageContentBox, PageDescription, PageTitle } from '../components/styles/content'; import { CardContentService, PageContentBox, PageDescription, PageTitle } from '../components/styles/content';
import { ServiceCardMobile } from '../components/styles/cards/mobile';
import ServiceList from '../public/pages.json'; import ServiceList from '../public/pages.json';
import useWindowSize from '../components/windowsize';
const fetcher = (url: string) => fetch(url).then((res) => res.json()) const fetcher = (url: string) => fetch(url).then((res) => res.json())
function Services() { function Services() {
const { initialData, fullData, loadingFull, error } = useServices(); const { initialData, fullData, loadingFull, error } = useServices();
const isMobile = useWindowSize();
let content: ReactElement = <></>; let content: ReactElement = <></>;
if (error) { content = <div>Error loading data</div> } if (error) { content = <div>Error loading data</div> }
else if (loadingFull) { else if (loadingFull) {
if (isMobile) {
content =
<PageContentBox>
{initialData?.map((item: Service) => (
<ServiceCardMobile key={item.name} content={item} />
))}
</PageContentBox>
}
else {
content = content =
<PageContentBox> <PageContentBox>
{initialData?.map((item: Service) => ( {initialData?.map((item: Service) => (
@ -22,7 +34,17 @@ function Services() {
))} ))}
</PageContentBox> </PageContentBox>
} }
}
else if (fullData) { else if (fullData) {
if (isMobile) {
content =
<PageContentBox>
{fullData.map((item: Service) => (
<ServiceCardMobile key={item.name} content={item} />
))}
</PageContentBox>
}
else {
content = content =
<PageContentBox> <PageContentBox>
{fullData.map((item: Service) => ( {fullData.map((item: Service) => (
@ -30,6 +52,7 @@ function Services() {
))} ))}
</PageContentBox> </PageContentBox>
} }
}
else { else {
content = <div>Error loading data</div> content = <div>Error loading data</div>
} }