Skip to content

Commit

Permalink
Rework search page: show all service offerings [#88]
Browse files Browse the repository at this point in the history
- Re enable ServiceOffering component
- Simplify loading of the data in useEffect
- Use semantically correct components
- Introduce new generic components to structure better the component (Main, LoadingIndicator, CardContainer)
- Refactor css styling in order to match the new data structure
- Reorganize translations

Signed-off-by: Zoltan M. <[email protected]>
Signed-off-by: Zoltan Magyari <[email protected]>
  • Loading branch information
Magyari Zoltan authored and Zoltan Magyari committed Aug 22, 2024
1 parent 1e251d1 commit 0cdc562
Show file tree
Hide file tree
Showing 15 changed files with 166 additions and 236 deletions.
15 changes: 11 additions & 4 deletions public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
},
"left-menu": {
"home": "Startseite",
"service-offerings": "Service Offerings",
"resources": "Ressourcen",
"participants": "Teilnehmer",
"provide": "Bereitstellen",
Expand Down Expand Up @@ -507,10 +506,11 @@
"download-file": "Turtle-Datei herunterladen",
"download-json": "Json-Datei herunterladen"
},
"service-offerings": {
"title": "Dienstleistungen",
"titles": "Dienstleistungsangebote"
},
"resources": {
"is-gaia-x-compliant": "Gaia-X konform",
"not-gaia-x-compliant": "Nicht Gaia-X konform",
"not-authenticated": "Nicht berechtigt",
"search-bar-text": "Suchen Sie nach speziellen Ressourcen oder Angeboten"
},
"ontologies": {
Expand All @@ -529,5 +529,12 @@
"no-shapes-available": "Keine Shapes gefunden",
"related-shapes": "Verwandte Shapes",
"not-found": "Shape nicht gefunden"
},
"common": {
"is-gaia-x-compliant": "Gaia-X konform",
"not-gaia-x-compliant": "Nicht Gaia-X konform",
"not-authenticated": "Nicht berechtigt",
"results": "Ergebnisse",
"is-loading": "es wird geladen..."
}
}
15 changes: 11 additions & 4 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"left-menu": {
"home": "Home",
"resources": "Resources",
"service-offerings": "Service Offerings",
"services": "Services",
"data": "Data",
"provider": "Provider",
Expand Down Expand Up @@ -509,10 +508,11 @@
"download-file": "Download turtle file",
"download-json": "Download json file"
},
"service-offerings": {
"title": "Services",
"titles": "Service Offerings"
},
"resources": {
"is-gaia-x-compliant": "Gaia-X compliant",
"not-gaia-x-compliant": "Not Gaia-X compliant",
"not-authenticated": "Not authenticated",
"search-bar-text": "Search for special Resources or Service Offerings"
},
"ontologies": {
Expand All @@ -531,5 +531,12 @@
"no-shapes-available": "No shapes available",
"related-shapes": "Related Shapes",
"not-found": "Shape not found"
},
"common": {
"is-gaia-x-compliant": "Gaia-X compliant",
"not-gaia-x-compliant": "Not Gaia-X compliant",
"not-authenticated": "You are not authenticated!",
"results": "results",
"is-loading": "loading..."
}
}
16 changes: 16 additions & 0 deletions src/components/cardContainer/CardContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FC, ReactNode } from 'react';

interface IResultContainer {
children: ReactNode;
isLoaded: boolean;
}

const CardContainer: FC<IResultContainer> = ({ children, isLoaded }) => {
return (
<div className={'card-container'}>
{isLoaded && children}
</div>
)
}

export default CardContainer;
18 changes: 9 additions & 9 deletions src/components/cards/SelfDescriptionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Title from 'components/Title/Title';
import GaiaXButton from 'components/buttons/GaiaXButton';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { ServiceOffering, Resource } from 'utils/dataMapper';
import { Resource, ServiceOffering } from 'utils/dataMapper';

import { Ontology } from '../../utils/ontologyMapper';

Expand Down Expand Up @@ -46,18 +46,18 @@ export default function SelfDescriptionCard({
};

return (
<div className={styles.card}>
<div className={styles.label}>
<article className={styles.card}>
<section className={styles.label}>
<Title>{label}</Title>
{isGaiaXComlpiant === undefined ? null : (
isGaiaXComlpiant ? (
<p>{t('resources.is-gaia-x-compliant')}</p>
<p>{t('common.is-gaia-x-compliant')}</p>
) : (
<p>{t('resources.not-gaia-x-compliant')}</p>
<p>{t('common.not-gaia-x-compliant')}</p>
)
)}
</div>
<div className={styles.content}>
</section>
<section className={styles.content}>
<Title>{name}</Title>
<p>{description}</p>
<div className={styles.button}>
Expand All @@ -66,7 +66,7 @@ export default function SelfDescriptionCard({
handleOnClick={handleNavigationToDetailsPage}
/>
</div>
</div>
</div>
</section>
</article>
);
}
12 changes: 5 additions & 7 deletions src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ interface IHeader {

const Header: FC<IHeader> = ({ title }) => {
return (
<div className={styles['container']}>
<header className={styles['header-container']}>
<div className={styles['header-title']}>
<Title>{title}</Title>
</div>
</header>
</div>
<header className={styles['header-container']}>
<div className={styles['header-title']}>
<Title>{title}</Title>
</div>
</header>
);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/itemCard/ItemCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const ItemCard: FC<IItemCard> = ({ label, isGaiaXCompliant, ontology, shape }) =
<Title>{label}</Title>
{isGaiaXCompliant === undefined ? null : (
isGaiaXCompliant ? (
<p>{t('resources.is-gaia-x-compliant')}</p>
<p>{t('common.is-gaia-x-compliant')}</p>
) : (
<p>{t('resources.not-gaia-x-compliant')}</p>
<p>{t('common.not-gaia-x-compliant')}</p>
)
)}
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/components/loading_view/LoadingIndicator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.newCarLoader {
display: flex;
justify-content: center;
}

.car {
width: 100px;
height: 100px;
}

25 changes: 25 additions & 0 deletions src/components/loading_view/LoadingIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React, { FC } from 'react';
import { useTranslation } from 'react-i18next';

import car from '../../assets/car.gif';

import styles from './LoadingIndicator.css';

interface ILoadingIndicator {
isLoading: boolean
}

const LoadingIndicator: FC<ILoadingIndicator> = ({ isLoading }) => {
const { t } = useTranslation()

if (isLoading) {
return (
<div className={styles.newCarLoader}>
<img src={car} alt={t('common.is-loading')} className={'car'}/>
</div>
)
}
return <></>
}

export default LoadingIndicator
4 changes: 4 additions & 0 deletions src/components/main/Main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.content {
margin-top: 20px;
}

26 changes: 26 additions & 0 deletions src/components/main/Main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { FC, ReactNode, useContext } from 'react';
import { useTranslation } from 'react-i18next';

import { AuthContext } from '../../context/AuthContextProvider';

import styles from './Main.css'

interface IMain {
children: ReactNode
}

const Main: FC<IMain> = ({ children }) => {
const authContext = useContext(AuthContext);
const { t } = useTranslation();

if (authContext.isAuthenticated) {
return (
<main className={styles.content}>
{children}
</main>
)
}
return <p>{t('common.not-authenticated')}</p>
}

export default Main;
28 changes: 0 additions & 28 deletions src/components/serviceOfferings/ServiceOfferings.css

This file was deleted.

Loading

0 comments on commit 0cdc562

Please sign in to comment.